URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [boehm-gc/] [doc/] [README.macros] - Rev 721
Compare with Previous | Blame | View Log
The collector uses a large amount of conditional compilation in order todeal with platform dependencies. This violates a number of known codingstandards. On the other hand, it seems to be the only practical way tosupport this many platforms without excessive code duplication.A few guidelines have mostly been followed in order to keep this manageable:1) #if and #ifdef directives are properly indented whenever easily possible.All known C compilers allow whitespace between the "#" and the "if" to makethis possible. ANSI C also allows white space before the "#", though weavoid that. It has the known disadvantages that it differs from the normalGNU conventions, and that it makes patches larger than otherwise necessary.In my opinion, it's still well worth it, for the same reason that we indentordinary "if" statements.2) Whenever possible, tests are performed on the macros defined in gcconfig.hinstead of directly testing patform-specific predefined macros. This makes itrelatively easy to adapt to new compilers with a different set of predefinedmacros. Currently these macros generally identify platforms instead offeatures. In many cases, this is a mistake.3) The code currently avoids #elif, eventhough that would make it morereadable. This was done since #elif would need to be understood by ALLcompilers used to build the collector, and that hasn't always been the case.It makes sense to reconsider this decision at some point, since #elif has beenstandardized at least since 1989.Many of the tested configuration macros are at least somewhat defined ineither include/private/gcconfig.h or in Makefile.direct. Here is an attemptat defining some of the remainder: (Thanks to Walter Bright for suggestingthis. This is a work in progress)MACRO EXPLANATION----- -----------__DMC__ Always #define'd by the Digital Mars compiler. Expandsto the compiler version number in hex, i.e. 0x810 isversion 8.1b0_ENABLE_ARRAYNEW#define'd by the Digital Mars C++ compiler whenoperator new[] and delete[] are separatelyoverloadable. Used in gc_cpp.h._MSC_VER Expands to the Visual C++ compiler version. Assumed tonot be defined for other compilers (at least if they behaveappreciably differently)._DLL Defined by Visual C++ if dynamic libraries are being builtor used. Used to test whether __declspec(dllimport) or__declspec(dllexport) needs to be added to declarationsto support the case in which the collector is in a dll.GC_DLL User-settable macro that forces the effect of _DLL. Setby gc.h if _DLL is defined and GC_NOT_DLL is undefined.This is the macro that is tested internally to determinewhether the GC is in its own dynamic library. May needto be set by clients before including gc.h. Note thatinside the GC implementation it indicates that thecollector is in its own dynamic library, should exportits symbols, etc. But in clients it indicates that theGC resides in a different DLL, its entry points shouldbe referenced accordingly, and precautions may need tobe taken to properly deal with statically allocatedvariables in the main program. Used only for MS Windows.GC_NOT_DLL User-settable macro that overrides _DLL, e.g. if dynamiclibraries are used, but the collector is in a static library.__STDC__ Assumed to be defined only by compilers that understandprototypes and other C89 features. Its value is generallynot used, since we are fine with most nonconforming extensions.SUNOS5SIGS Solaris-like signal handling. This is probably misnamed,since it really doesn't guarantee much more than Posix.Currently set only for Solaris2.X, HPUX, and DRSNX. Shouldprobably be set for some other platforms.PCR Set if the collector is being built as part of the XeroxPortable Common Runtime.SRC_M3 Set if the collector is being built as a replacement of theone in the DEC/Compaq SRC Modula-3 runtime. I suspect thiswas last used around 1994, and no doubt broke a long time ago.It's there primarily incase someone wants to port to a similarsystem.USE_COMPILER_TLS Assume the existence of __thread-style thread-localstorage. Set automatically for thread-local allocation withthe HP/UX vendor compiler. Usable with gcc on sufficientlyup-to-date ELF platforms.
