annotate src/fftw-3.3.3/CONVENTIONS @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 37bf6b4a2645
children
rev   line source
Chris@10 1 Code conventions used internally by fftw3 (not in API):
Chris@10 2
Chris@10 3 LEARN FROM THE MASTERS: read Ken Thompson's C compiler in Plan 9.
Chris@10 4 Avoid learning from C++/Java programs.
Chris@10 5
Chris@10 6 INDENTATION: K&R, 5 spaces/tab. In case of doubt, indent -kr -i5.
Chris@10 7
Chris@10 8 NAMES: keep them short. Shorter than you think. The Bible was written
Chris@10 9 without vowels. Don't outsmart the Bible.
Chris@10 10
Chris@10 11 Common names:
Chris@10 12
Chris@10 13 R : real type, aka fftw_real
Chris@10 14 E : real type for local variables (possibly extra precision)
Chris@10 15 C : complex type
Chris@10 16 sz : size
Chris@10 17 vecsz : vector size
Chris@10 18 is, os : input/output stride
Chris@10 19 ri, ii : real/imag input (complex data)
Chris@10 20 ro, io : real/imag output (complex data)
Chris@10 21 I, O : real input/output (real data)
Chris@10 22 A : assert
Chris@10 23 CK : check
Chris@10 24 S : solver, defined internally to each solver file
Chris@10 25 P : plan, defined internally to each solver file
Chris@10 26 k : codelet
Chris@10 27 X(...) : used for mangling of external names (see below)
Chris@10 28 K(...) : floating-point constant, in E precision
Chris@10 29
Chris@10 30 If a name is used often and must have the form fftw_foo to avoid
Chris@10 31 namespace pollution, #define FOO fftw_foo and use the short name.
Chris@10 32
Chris@10 33 Leave that hungarian crap to MS. foo_t counts as hungarian: use
Chris@10 34 foo instead. foo is lowercase so that it does not look like a DOS
Chris@10 35 program. Exception: typedef struct foo_s {...} foo; instead of
Chris@10 36 typedef struct foo {...} foo; for C++ compatibility.
Chris@10 37
Chris@10 38 NAME MANGLING: use X(foo) for external names instead of fftw_foo.
Chris@10 39 X(foo) expands to fftwf_foo or fftw_foo, depending on the
Chris@10 40 precision. (Unfortunately, this is a ugly form of hungarian
Chris@10 41 notation. Grrr...) Names that are not exported do not need to be
Chris@10 42 mangled.
Chris@10 43
Chris@10 44 REPEATED CODE: favor a table. E.g., do not write
Chris@10 45
Chris@10 46 foo("xxx", 1);
Chris@10 47 foo("yyy", 2);
Chris@10 48 foo("zzz", -1);
Chris@10 49
Chris@10 50 Instead write
Chris@10 51
Chris@10 52 struct { const char *nam, int arg } footab[] = {
Chris@10 53 { "xxx", 1 },
Chris@10 54 { "yyy", 2 },
Chris@10 55 { "zzz", -1 }
Chris@10 56 };
Chris@10 57
Chris@10 58 and loop over footab. Rationale: it saves code space.
Chris@10 59 Similarly, replace a switch statement with a table whenever
Chris@10 60 possible.
Chris@10 61
Chris@10 62 C++: The code should compile as a C++ program. Run the code through
Chris@10 63 gcc -xc++ . The extra C++ restrictions are unnecessary, of
Chris@10 64 course, but this will save us from a flood of complaints when
Chris@10 65 we release the code.