source: trunk/gcc/boehm-gc/doc/README.macros@ 3003

Last change on this file since 3003 was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 3.4 KB
Line 
1The collector uses a large amount of conditional compilation in order to
2deal with platform dependencies. This violates a number of known coding
3standards. On the other hand, it seems to be the only practical way to
4support this many platforms without excessive code duplication.
5
6A few guidelines have mostly been followed in order to keep this manageable:
7
81) #if and #ifdef directives are properly indented whenever easily possible.
9All known C compilers allow whitespace between the "#" and the "if" to make
10this possible. ANSI C also allows white space before the "#", though we
11avoid that. It has the known disadvantages that it differs from the normal
12GNU conventions, and that it makes patches larger than otherwise necessary.
13In my opinion, it's still well worth it, for the same reason that we indent
14ordinary "if" statements.
15
162) Whenever possible, tests are performed on the macros defined in gcconfig.h
17instead of directly testing patform-specific predefined macros. This makes it
18relatively easy to adapt to new compilers with a different set of predefined
19macros. Currently these macros generally identify platforms instead of
20features. In many cases, this is a mistake.
21
223) The code currently avoids #elif, eventhough that would make it more
23readable. This was done since #elif would need to be understood by ALL
24compilers used to build the collector, and that hasn't always been the case.
25It makes sense to reconsider this decision at some point, since #elif has been
26standardized at least since 1989.
27
28Many of the tested configuration macros are at least somewhat defined in
29either include/private/gcconfig.h or in Makefile.direct. Here is an attempt
30at defining some of the remainder: (Thanks to Walter Bright for suggesting
31this. This is a work in progress)
32
33MACRO EXPLANATION
34----- -----------
35
36__DMC__ Always #define'd by the Digital Mars compiler. Expands
37 to the compiler version number in hex, i.e. 0x810 is
38 version 8.1b0
39
40_ENABLE_ARRAYNEW
41 #define'd by the Digital Mars C++ compiler when
42 operator new[] and delete[] are separately
43 overloadable. Used in gc_cpp.h.
44
45_MSC_VER Expands to the Visual C++ compiler version. Assumed to
46 not be defined for other compilers (at least if they behave
47 appreciably differently).
48
49_DLL Defined by Visual C++ if dynamic libraries are being built
50 or used. Used to test whether __declspec(dllimport) or
51 __declspec(dllexport) needs to be added to declarations
52 to support the case in which the collector is in a dll.
53
54GC_DLL User-settable macro that forces the effect of _DLL.
55
56GC_NOT_DLL User-settable macro that overrides _DLL, e.g. if dynamic
57 libraries are used, but the collector is in a static library.
58
59__STDC__ Assumed to be defined only by compilers that understand
60 prototypes and other C89 features. Its value is generally
61 not used, since we are fine with most nonconforming extensions.
62
63SUNOS5SIGS Solaris-like signal handling. This is probably misnamed,
64 since it really doesn't guarantee much more than Posix.
65 Currently set only for Solaris2.X, HPUX, and DRSNX. Should
66 probably be set for some other platforms.
67
68PCR Set if the collector is being built as part of the Xerox
69 Portable Common Runtime.
70
71SRC_M3 Set if the collector is being built as a replacement of the
72 one in the DEC/Compaq SRC Modula-3 runtime. I suspect this
73 was last used around 1994, and no doubt broke a long time ago.
74 It's there primarily incase someone wants to port to a similar
75 system.
76
77
78
Note: See TracBrowser for help on using the repository browser.