/src/lispbibl.d
D | 12025 lines | 7981 code | 741 blank | 3303 comment | 1075 complexity | c404e42f858ad768575a5be350bf7543 MD5 | raw file
Possible License(s): LGPL-2.0, GPL-2.0, BSD-3-Clause
Large files files are truncated, but you can click here to view the full file
- /*
- * Main include-file for CLISP
- * Bruno Haible 1990-2008
- * Marcus Daniels 11.11.1994
- * Sam Steingold 1998-2008
- * German comments translated into English: Stefan Kain 2001-09-24
- Flags intended to be set through CFLAGS:
- Readline library:
- NO_READLINE
- Termcap/ncurses library:
- NO_TERMCAP_NCURSES
- Internationalization:
- NO_GETTEXT, UNICODE
- Fault handling:
- NO_SIGSEGV
- Foreign function interface:
- DYNAMIC_FFI
- Dynamic loading of modules:
- DYNAMIC_MODULES
- Safety level:
- SAFETY={0,1,2,3}
- Exploit GCC global register variables:
- USE_GCC_REGISTER_VARIABLES
- Debugging (turned on by --with-debug configure option):
- DEBUG_GCSAFETY (requires G++)
- DEBUG_OS_ERROR
- DEBUG_SPVW
- DEBUG_BYTECODE
- DEBUG_BACKTRACE
- DEBUG_COMPILER
- Flags that may be set through CFLAGS, in order to override the defaults:
- Object representation (on 32-bit platforms only):
- TYPECODES, HEAPCODES, STANDARD_HEAPCODES, LINUX_NOEXEC_HEAPCODES, WIDE
- Advanced memory management:
- NO_SINGLEMAP, NO_TRIVIALMAP, NO_MULTIMAP_FILE, NO_MULTIMAP_SHM,
- NO_VIRTUAL_MEMORY, CONS_HEAP_GROWS_DOWN, CONS_HEAP_GROWS_UP,
- NO_MORRIS_GC, NO_GENERATIONAL_GC
- String representation:
- NO_SMALL_SSTRING
- Implementation is prepared for the following computers,
- operating systems and c-compilers
- (Only a rough listing, check the file PLATFORMS for further details.)
- Machine Producer Operating system C-Compiler recognized through
- AMIGA Commodore AMIGA-OS (AMIGADOS) GNU amiga or AMIGA, __GNUC__, maybe MC68000 or AMIGA3000
- any any UNIX GNU unix, __GNUC__, ...
- any any UNIX CC unix, ...
- Amiga 3000 Commodore Amiga UNIX 2.1 SVR4.0 GNU unix, __unix__, AMIX, __AMIX__, __svr4__, m68k, __m68k__, __motorola__, __GNUC__
- SUN-3 Sun SUN-OS3 (UNIX BSD 4.2) GNU sun, unix, mc68020, __GNUC__
- SUN-3 Sun SUN-OS4 (UNIX SUNOS 4.1) GNU sun, unix, mc68020, __GNUC__
- SUN-386 Sun SUN-OS4 (UNIX SUNOS 4.0) GNU sun, unix, sun386, i386, __GNUC__
- SUN-386 Sun SUN-OS4 (UNIX SUNOS 4.0) CC sun, unix, sun386, i386
- SUN-4 Sun SUN-OS4 (UNIX SUNOS 4.1) GNU sun, unix, sparc, __GNUC__
- SUN-4 Sun SUN-OS4 (UNIX SUNOS 4.1) CC sun, unix, sparc
- SUN-4 Sun SUN-OS5 (UNIX Solaris) GCC sun, unix, sparc, __GNUC__
- UltraSparc Sun Solaris 7 (UNIX SUNOS 5.7) CC sun, unix, __sparc, __sparcv9
- UltraSparc Sun Solaris 7 (UNIX SUNOS 5.7) GCC sun, unix, __sparc, __arch64__, __GNUC__
- IBM-PC/386 any SUN-OS5 (UNIX Solaris) GCC sun, unix, __svr4__, i386, __GNUC__
- HP9000-300 Hewlett-Packard NetBSD 0.9 (UNIX BSD 4.3) GNU unix, __NetBSD__, mc68000, __GNUC__
- HP9000-300 Hewlett-Packard HP-UX 8.0 (UNIX SYS V) GNU [__]hpux, [__]unix, [__]hp9000s300, mc68000, __GNUC__
- HP9000-800 Hewlett-Packard HP-UX 8.0 (UNIX SYS V) GNU [__]hpux, [__]unix, [__]hp9000s800
- IRIS Silicon Graphics IRIX (UNIX SYS V 3.2) GNU unix, SVR3, mips, sgi, __GNUC__
- IRIS Silicon Graphics IRIX (UNIX SYS V) cc -ansi [__]unix, [__]SVR3, [__]mips, [__]sgi
- IRIS Silicon Graphics IRIX 5 (UNIX SYS V 4) GNU [__]unix, [__]SYSTYPE_SVR4, [__]mips, [__]host_mips, [__]MIPSEB, [__]sgi, __DSO__, [__]_MODERN_C, __GNUC__
- DECstation 5000 RISC/OS (Ultrix V4.2A) GNU unix, [__]mips, [__]ultrix
- DG-UX 88k Data General DG/UX GNU unix, m88000, DGUX
- DEC Alpha DEC OSF/1 1.3 cc [unix,] __unix__, __osf__, __alpha
- DEC Alpha DEC OSF/1 1.3 GNU unix, __unix__, __osf__, __alpha, __alpha__, _LONGLONG
- Apple MacII Apple A/UX (UNIX SYS V 2) GNU [__]unix, [__]AUX, [__]macII, [__]m68k, mc68020, mc68881, __GNUC__
- NeXT NeXT NeXTstep 3.1 (UNIX) cc NeXT, m68k
- PowerPC Apple Mach 3.0 + MkLinux GNU unix, __powerpc__, __PPC__, _ARCH_PPC, _CALL_SYSV, __ELF__, __linux__
- PowerPC Apple Mach + Rhapsody cc __MACH__, __APPLE__, __ppc[__], __GNUC__, __APPLE_CC__
- PowerPC Apple Mach + MacOS X cc __MACH__, __APPLE__, __ppc__, __GNUC__, __APPLE_CC__
- Sequent Sequent PTX 3.2.0 V2.1.0 i386 (SYS V) GNU unix, i386, _SEQUENT_, __GNUC__
- Sequent Sequent PTX V4.1.3 GNU unix, i386, _SEQUENT_, __svr4__, __GNUC__
- Convex C2 Convex ConvexOS 10.1 GNU __convex__, __GNUC__
- IBM RS/6000 IBM AIX 3.2 GNU _AIX, _AIX32, _IBMR2, __CHAR_UNSIGNED__, __GNUC__
- IBM-PC/386 any LINUX (free UNIX) GNU unix, linux, i386, __GNUC__
- IBM-PC/386 any LINUX (free UNIX) Intel 5.0 __unix__, __linux__, __INTEL_COMPILER, __ICC, __USLC__
- IBM-PC/386 any 386BSD 0.1 (UNIX BSD 4.2) GNU unix, __386BSD__, i386, __GNUC__
- IBM-PC/386 any NetBSD 0.9 (UNIX BSD 4.3) GNU unix, __NetBSD__, i386, __GNUC__
- IBM-PC/386 any FreeBSD 4.0 (UNIX BSD 4.4) GNU unix, __FreeBSD__, i386, __GNUC__
- IBM-PC/386 any EMX 0.9c (UNIXlike on OS/2) GNU [unix,] i386, __GNUC__, __EMX__
- IBM-PC/386 any Cygwin32 on WinNT/Win95 GNU _WIN32, __WINNT__, __CYGWIN32__, __POSIX__, _X86_, i386, __GNUC__
- IBM-PC/386 any Mingw32 on WinNT/Win95 GNU _WIN32, __WINNT__, __MINGW32__, _X86_, i386, __GNUC__
- IBM-PC/386 any WinNT/Win95 MSVC _WIN32, _M_IX86, _MSC_VER
- IBM-PC/386 any WinNT/Win95 Borland 5.0 __WIN32__, _M_IX86, __TURBOC__, __BORLANDC__
- IBM-PC/386 any WinNT/Win95 and Cygwin32 GNU _WIN32, __WINNT__, __CYGWIN32__, __POSIX__, __i386__, _X86_, __GNUC__
- IBM-PC/586 any BeOS 5 GNU __BEOS__, __INTEL__, __i386__, _X86_, __GNUC__
- IBM-PC/586 any HP NUE/ski, Linux GNU unix, linux, __ia64[__], __GNUC__, __LP64__
- RM400 Siemens-Nixdorf SINIX-N 5.42 c89 unix, mips, MIPSEB, host_mips, sinix, SNI, _XPG_IV
- Acorn Risc PC RISC OS 3.x GNU [__]arm, [__]riscos, __GNUC__
- Acorn Risc PC RISC OS 3.x Norcroft [__]arm, [__]riscos
- APPLE IIGS Apple ?? ??
- For ANSI-C-Compiler: use pre-processors comment5, varbrace
- (and maybe gcc-cpp, ccpaux).
- this machine: WIN32 or GENERIC_UNIX */
- #if (defined(__unix) || defined(__unix__) || defined(_AIX) || defined(sinix) || defined(__MACH__) || defined(__POSIX__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__BEOS__)) && !defined(unix)
- #define unix
- #endif
- #if (defined(_WIN32) && (defined(_MSC_VER) || defined(__MINGW32__))) || (defined(__WIN32__) && defined(__BORLANDC__))
- #undef WIN32 /* because of __MINGW32__ */
- #define WIN32
- #endif
- #if !defined(WIN32)
- #if defined(unix)
- #define GENERIC_UNIX
- #else
- #error "Unknown machine type -- set machine again!"
- #endif
- #endif
- /* additional specification of the machine: */
- #if defined(WIN32)
- /* declare availability of typical PC facilities,
- like a console with a graphics mode that differs from the text mode,
- or a keyboard with function keys F1..F12. */
- #define PC386 /* IBMPC-compatible with 80386/80486-processor */
- #endif
- #ifdef GENERIC_UNIX
- #if (defined(sun) && defined(unix) && defined(sun386))
- #define SUN386
- #endif
- #if (defined(unix) && (defined(linux) || defined(__CYGWIN32__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)) && (defined(i386) || defined(__i386__) || defined(__x86_64__) || defined(__amd64__)))
- #define PC386
- #endif
- #if (defined(sun) && defined(unix) && defined(mc68020))
- #define SUN3
- #endif
- #if (defined(sun) && defined(unix) && defined(sparc))
- #define SUN4
- #endif
- #if defined(sparc) || defined(__sparc__)
- /* maybe SUN4_29 if only addresses <2^29 are supported */
- #endif
- #if defined(hp9000s800) || defined(__hp9000s800)
- #define HP8XX
- #endif
- #endif
- /* Determine the processor:
- MC680X0 == all processors of the Motorola 68000 series
- MC680Y0 == all processors of the Motorola 68000 series, starting at MC68020
- SPARC == the Sun SPARC processor
- HPPA == all processors of the HP Precision Architecture
- MIPS == all processors of the MIPS series
- M88000 == all processors of the Motorola 88000 series
- POWERPC == the IBM RS/6000 and PowerPC processor family
- I80386 == all processors of the Intel 8086 series, starting at 80386,
- nowadays called IA32
- VAX == the VAX processor
- ARM == the ARM processor
- DECALPHA == the DEC Alpha superchip
- IA64 == the Intel IA-64 latecomer chip
- AMD64 == the AMD hammer chip
- S390 == the IBM S/390 processor */
- #if defined(__vax__)
- #define VAX
- #endif
- #if defined(arm) || defined(__arm) || defined(__arm__)
- #define ARM
- #endif
- #ifdef WIN32
- #if defined(_M_IX86) || defined(_X86_)
- #define I80386
- #endif
- #endif
- #ifdef GENERIC_UNIX
- #if defined(m68k) || defined(__m68k__) || defined(mc68000)
- #define MC680X0
- #endif
- #if defined(mc68020) || defined(__mc68020__) || (defined(m68k) && defined(NeXT))
- #define MC680X0
- #define MC680Y0
- #endif
- #if defined(i386) || defined(__i386) || defined(__i386__) || defined(_I386)
- #define I80386
- #endif
- #if defined(sparc) || defined(__sparc__)
- #define SPARC
- #if defined(__sparcv9) || defined(__arch64__)
- #define SPARC64
- #endif
- #endif
- #if defined(mips) || defined(__mips) || defined(__mips__)
- #define MIPS
- #if defined(_MIPS_SZLONG)
- #if (_MIPS_SZLONG == 64)
- /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
- #define MIPS64
- #endif
- #endif
- #endif
- #if defined(HP8XX) || defined(hppa) || defined(__hppa) || defined(__hppa__)
- #define HPPA
- #endif
- #if defined(m88000) || defined(__m88k__)
- #define M88000
- #endif
- #if defined(_IBMR2) || defined(__powerpc) || defined(__ppc) || defined(__ppc__) || defined(__powerpc__)
- #define POWERPC
- #endif
- #ifdef __alpha
- #define DECALPHA
- #endif
- #ifdef __ia64__
- #define IA64
- #endif
- #if defined(__x86_64__) || defined(__amd64__)
- #define AMD64
- #endif
- #ifdef __s390__
- #define S390
- #endif
- #endif
- /* Selection of the operating system */
- #ifdef WIN32
- /* Windows NT, Windows 95 */
- #define WIN32_NATIVE /* native NT API, no DOS calls */
- #endif
- #ifdef GENERIC_UNIX
- #define UNIX
- #ifdef __linux__
- #define UNIX_LINUX /* Linux (Linus Torvalds Unix) */
- #endif
- #ifdef __GNU__
- #define UNIX_HURD /* the GNU system (Hurd + glibc) */
- #endif
- #ifdef __NetBSD__
- #define UNIX_NETBSD
- #endif
- #if defined(__FreeBSD__) || defined(__DragonFly__)
- /* FreeBSD or its fork called DragonFly BSD. */
- #define UNIX_FREEBSD
- #endif
- #ifdef __OpenBSD__
- #define UNIX_OPENBSD
- #endif
- #if defined(hpux) || defined(__hpux)
- #define UNIX_HPUX /* HP-UX */
- #endif
- #if defined(SVR3) || defined(__SVR3) || defined(SVR4) || defined(__SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4) || defined(__svr4__) || defined(USG) || defined(UNIX_HPUX) /* ?? */
- #define UNIX_SYSV /* UNIX System V */
- #endif
- #if defined(UNIX_SYSV) && (defined(sgi) || defined(__sgi))
- #define UNIX_IRIX /* Irix */
- #if defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4)
- #define UNIX_IRIX5 /* Irix 5 */
- #endif
- #endif
- #if defined(MIPS) && (defined(ultrix) || defined(__ultrix))
- #define UNIX_DEC_ULTRIX /* DEC's (or IBM's ?) RISC/OS Ultrix on DEC MIPS */
- #ifdef __GNUC__
- #define UNIX_DEC_ULTRIX_GCCBUG /* work around a bug in GCC 2.3.3 */
- #endif
- #endif
- #if defined(MIPS) && defined(sinix) /* && defined(SNI) */
- #define UNIX_SINIX /* Siemens is nix */
- #endif
- #if defined(USL) || (defined(__svr4__) && defined(I80386) && !defined(__sun))
- /* A couple of Unices for 386s (all running under different names)
- derive from USL SysV R 4:
- 386 UHC UNIX System V release 4
- Consensys System V 4.2
- Onsite System V 4.2
- SINIX-Z
- DYNIX/ptx V4.1.3
- SunOS 5 */
- #define UNIX_SYSV_USL /* Unix System V R 4 by AT&T's subsidiary USL */
- #define UNIX_SYSV_UHC_1 /* treat like HPPA && UNIX_HPUX */
- #ifdef SNI
- #define UNIX_SINIX /* Siemens is nix */
- #endif
- #endif
- #if defined(_SEQUENT_) && !defined(__svr4__)
- #define UNIX_SYSV_PTX /* Dynix/ptx v. 2 or 3 */
- #endif
- #ifdef _AIX
- #define UNIX_AIX /* IBM AIX */
- #endif
- #ifdef DGUX
- #define UNIX_DGUX /* Data General DG/UX */
- #endif
- #ifdef __osf__
- #define UNIX_OSF /* OSF/1 */
- #endif
- #ifdef AUX
- #define UNIX_AUX /* Apple A/UX, a spiced-up SVR2 */
- #endif
- #ifdef NeXT
- #define UNIX_NEXTSTEP /* NeXTstep */
- #endif
- #if defined(__APPLE__) && defined(__MACH__)
- #define UNIX_MACOSX /* MacOS X */
- #endif
- #ifdef AMIX
- #define UNIX_AMIX /* Amiga UNIX */
- #endif
- #ifdef __CYGWIN32__
- #define UNIX_CYGWIN32 /* Cygwin32 (UNIXlike on WinNT/Win95) */
- #endif
- #ifdef __BEOS__
- #define UNIX_BEOS /* BeOS (UNIXlike) */
- #endif
- #endif
- %% #ifdef WIN32_NATIVE
- %% puts("#define WIN32_NATIVE");
- %% #endif
- %% #ifdef UNIX
- %% puts("#define UNIX");
- %% #endif
- /* Determine properties of compiler and environment: */
- #if defined(UNIX) || defined(__MINGW32__)
- #include "config.h" /* configuration generated by configure */
- #include "intparam.h" /* integer-type characteristics created by the machine */
- #include "floatparam.h" /* floating-point type characteristics */
- #elif defined(WIN32) && !defined(__MINGW32__)
- #include "version.h" /* defines PACKAGE_* */
- #define char_bitsize 8
- #define short_bitsize 16
- #define int_bitsize 32
- #if defined(I80386)
- #define long_bitsize 32
- #elif defined(DECALPHA)
- #define long_bitsize 64
- #endif
- #if defined(I80386)
- #define pointer_bitsize 32
- #elif defined(DECALPHA)
- #define pointer_bitsize 64
- #endif
- #define alignment_long 4
- #if defined(I80386) || defined(VAX) || defined(ARM) || defined(DECALPHA)
- #define short_little_endian
- #define long_little_endian
- #endif
- #define stack_grows_down
- #define CODE_ADDRESS_RANGE 0
- #define MALLOC_ADDRESS_RANGE 0
- #define SHLIB_ADDRESS_RANGE 0
- #define STACK_ADDRESS_RANGE ~0UL
- #define ICONV_CONST
- #else
- #error "where is the configuration for your platform?"
- #endif
- /* A more precise classification of the operating system: */
- #if defined(UNIX) && defined(SIGNALBLOCK_BSD) && !defined(SIGNALBLOCK_SYSV)
- #define UNIX_BSD /* BSD Unix */
- #endif
- #if (defined(SUN3) || defined(SUN386) || defined(SUN4)) && defined(HAVE_MMAP) && defined(HAVE_VADVISE)
- #define UNIX_SUNOS4 /* Sun OS Version 4 */
- #endif
- #if (defined(SUN4) || (defined(I80386) && defined(__svr4__) && defined(__sun))) && !defined(HAVE_VADVISE) /* && !defined(HAVE_GETPAGESIZE) */
- #define UNIX_SUNOS5 /* Sun OS Version 5.[1-5] (Solaris 2) */
- #endif
- #if defined(UNIX_MACOSX) && !defined(HAVE_MSYNC)
- #define UNIX_RHAPSODY /* MacOS X Server, a.k.a. Rhapsody */
- #endif
- #if defined(UNIX_MACOSX) && defined(HAVE_MSYNC)
- #define UNIX_DARWIN /* MacOS X, a.k.a. Darwin */
- #endif
- /* Choose the character set: */
- #if defined(UNIX) || defined(WIN32)
- #define ISOLATIN_CHS /* ISO 8859-1, see isolatin.chs */
- /* Most Unix systems today support the ISO Latin-1 character set, in
- particular because they have X11 and the X11 fonts are in ISO Latin-1.
- Exceptions below.
- On Win32, the standard character set is ISO-8859-1. Only the DOS box
- displays CP437, but we convert from ISO-8859-1 to CP437 in the
- low-level output routine full_write(). */
- #endif
- #ifdef UNIX_BEOS
- /* The default encoding on BeOS is UTF-8, not ISO 8859-1.
- If compiling with Unicode support, we use it. Else fall back to ASCII. */
- #undef ISOLATIN_CHS
- #ifdef UNICODE
- #define UTF8_CHS /* UTF-8 */
- #endif
- #endif
- #ifdef HP8XX
- #undef ISOLATIN_CHS
- #define HPROMAN8_CHS /* HP-Roman8, see hproman8.chs */
- /* under X-Term however: #define ISOLATIN_CHS ?? */
- #endif
- #ifdef UNIX_NEXTSTEP
- #undef ISOLATIN_CHS
- #define NEXTSTEP_CHS /* NeXTstep, see nextstep.chs */
- #endif
- #if !(defined(ISOLATIN_CHS) || defined(HPROMAN8_CHS) || defined(NEXTSTEP_CHS))
- #define ASCII_CHS /* Default: plain ASCII charset without special chars */
- #endif
- /* Choose the compiler: */
- #if defined(__GNUC__)
- #define GNU
- #endif
- #if defined(__STDC__) || defined(__BORLANDC__) || defined(__cplusplus)
- /* ANSI C compilers define __STDC__ (but some define __STDC__=0 !).
- Borland C has an ANSI preprocessor and compiler, but fails to define
- __STDC__.
- HP aCC is an example of a C++ compiler which defines __cplusplus but
- not __STDC__. */
- #define ANSI
- #endif
- #if defined(_MSC_VER)
- #define MICROSOFT
- #endif
- #if defined(__BORLANDC__)
- #define BORLAND
- #endif
- #if defined(__INTEL_COMPILER)
- #define INTEL
- #endif
- /* Selection of floating-point capabilities:
- FAST_DOUBLE should be defined if there is a floating-point coprocessor
- with a 'double'-type IEEE-Floating-Points with 64 Bits.
- FAST_FLOAT should be defined if there is a floating-point co-processor
- with a 'float'-type IEEE-Floating-Points with 32 Bits,
- and a C-Compiler that generates 'float'-operations
- instead of 'double'-operations */
- #if (float_mant_bits == 24) && (float_rounds == rounds_to_nearest) && float_rounds_correctly && !defined(FLOAT_OVERFLOW_EXCEPTION) && !defined(FLOAT_UNDERFLOW_EXCEPTION) && !defined(FLOAT_INEXACT_EXCEPTION)
- #define FAST_FLOAT
- #endif
- #if (double_mant_bits == 53) && (double_rounds == rounds_to_nearest) && double_rounds_correctly && !defined(DOUBLE_OVERFLOW_EXCEPTION) && !defined(DOUBLE_UNDERFLOW_EXCEPTION) && !defined(DOUBLE_INEXACT_EXCEPTION)
- #define FAST_DOUBLE
- #endif
- #ifdef ARM
- /* The processor is little-endian w.r.t. integer types but stores 'double'
- floats in big-endian word order! */
- #undef FAST_DOUBLE
- #endif
- #ifdef NO_FAST_DOUBLE
- #undef FAST_DOUBLE
- #endif
- #ifdef NO_FAST_FLOAT
- #undef FAST_FLOAT
- #endif
- /* Selection of the language: */
- #ifdef ENGLISH
- #undef ENGLISH
- #define ENGLISH 1
- #define LANGUAGE_STATIC
- #endif
- /* Selection of the safety-level:
- SAFETY=0 : all optimizations are turned on
- SAFETY=1 : all optimizations on, but keep STACKCHECKs
- SAFETY=2 : only simple assembler-support
- SAFETY=3 : no optimizations */
- #ifndef SAFETY
- #define SAFETY 0
- #endif
- #if SAFETY >= 3
- #define NO_ASM
- #define NO_ARI_ASM
- #define NO_FAST_DISPATCH
- #endif
- /* We don't support pre-ANSI-C compilers any more. */
- #if !defined(ANSI)
- #error "An ANSI C or C++ compiler is required to compile CLISP!"
- #endif
- /* gcc-2.7.2 has a bug: it interpretes `const' as meaning `not modified by
- other parts of the program', and thus miscompiles at least justify_empty_2
- and pr_enter_1 in io.d. */
- #if defined(GNU) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 7)
- #undef const
- #define const
- #define __const const
- /* We define __const to const, not to empty, to avoid warnings on
- UNIX_RHAPSODY, which unconditionally defines __const to const when
- <sys/cdefs.h> is included via <setjmp.h> below. */
- #ifdef MULTITHREAD
- #warning "Multithreading will not be efficient because of a workaround to a gcc bug."
- #warning "Get a newer version of gcc."
- #endif
- #endif
- /* A property of the processor:
- The sequence in which words/long-words are being put into bytes */
- #if defined(short_little_endian) || defined(int_little_endian) || defined(long_little_endian)
- /* Z80, VAX, I80386, DECALPHA, MIPSEL, IA64, AMD64, ...:
- Low Byte is the lowest, High Byte in a higher address */
- #if defined(BIG_ENDIAN_P)
- #error "Bogus BIG_ENDIAN_P -- set BIG_ENDIAN_P again!"
- #endif
- #define BIG_ENDIAN_P 0
- #endif
- #if defined(short_big_endian) || defined(int_big_endian) || defined(long_big_endian)
- /* MC680X0, SPARC, HPPA, MIPSEB, M88000, POWERPC, S390, ...:
- High Byte is the lowest, Low Byte is a higher adress (easier to read) */
- #if defined(BIG_ENDIAN_P)
- #error "Bogus BIG_ENDIAN_P -- set BIG_ENDIAN_P again"
- #endif
- #define BIG_ENDIAN_P 1
- #endif
- #if !defined(BIG_ENDIAN_P)
- #error "Bogus BIG_ENDIAN_P -- set BIG_ENDIAN_P again!"
- #endif
- %% export_def(BIG_ENDIAN_P);
- /* A property of the processor (and C compiler): The alignment of C functions.
- (See gcc's machine descriptions, macro FUNCTION_BOUNDARY, for information.) */
- #if defined(IA64)
- #define C_CODE_ALIGNMENT 16
- #define log2_C_CODE_ALIGNMENT 4
- #endif
- #if defined(DECALPHA)
- #define C_CODE_ALIGNMENT 8
- #define log2_C_CODE_ALIGNMENT 3
- #endif
- #if (defined(I80386) && defined(GNU)) || defined(SPARC) || defined(MIPS) || defined(M88000) || defined(POWERPC) || defined(ARM) || defined(AMD64) || defined(S390)
- /* When using gcc on i386, this assumes that -malign-functions has not been
- used to specify an alignment smaller than 4 bytes. */
- #define C_CODE_ALIGNMENT 4
- #define log2_C_CODE_ALIGNMENT 2
- #endif
- #if defined(HPPA)
- /* A function pointer on hppa is either
- - a code pointer == 0 mod 4, or
- - a pointer to a two-word structure (first word: a code pointer,
- second word: a value which will be put in register %r19),
- incremented by 2, hence == 2 mod 4.
- The current compilers only emit the second kind of function pointers,
- hence we can assume that all function pointers are == 2 mod 4. */
- #define C_CODE_ALIGNMENT 2
- #define log2_C_CODE_ALIGNMENT 1
- #endif
- #if defined(MC680X0)
- #define C_CODE_ALIGNMENT 2
- #define log2_C_CODE_ALIGNMENT 1
- #endif
- #if !defined(C_CODE_ALIGNMENT) /* e.g. (defined(I80386) && defined(MICROSOFT)) */
- #define C_CODE_ALIGNMENT 1
- #define log2_C_CODE_ALIGNMENT 0
- #endif
- /* Flags for the system's include files. */
- #ifdef MULTITHREAD
- #if defined(UNIX_GNU) || defined(UNIX_SUNOS5)
- #define _REENTRANT
- #endif
- #if defined(__GNUC__)
- #define per_thread __thread
- #else
- #error "how does your compiler specify per-thread storage class?"
- #endif
- #else
- #define per_thread
- #endif
- /* Width of object representation:
- WIDE means than an object (pointer) occupies 64 bits (instead of 32 bits).
- WIDE_HARD means on a 64-bit platform.
- WIDE_SOFT means on a 32-bit platform, each object pointer occupies 2 words.
- WIDE_AUXI means on a 32-bit platform, each object occupies 2 words, the
- pointer and some auxiliary word. */
- #if defined(DECALPHA) || defined(MIPS64) || defined(SPARC64) || defined(IA64) || defined(AMD64)
- #define WIDE_HARD
- #endif
- #if defined(WIDE_SOFT_LARGEFIXNUM) && !defined(WIDE_SOFT)
- #define WIDE_SOFT
- #endif
- #if defined(WIDE) && !(defined(WIDE_HARD) || defined(WIDE_SOFT) || defined(WIDE_AUXI))
- #define WIDE_SOFT
- #endif
- #if (defined(WIDE_HARD) || defined(WIDE_SOFT) || defined(WIDE_AUXI)) && !defined(WIDE)
- #define WIDE
- #endif
- /* Now: defined(WIDE) == defined(WIDE_HARD) || defined(WIDE_SOFT) || defined(WIDE_AUXI) */
- /* Global register declarations.
- Speed benefit: Just putting the STACK into a register, brought 5% of speed
- around 1992. Now, with an AMD Athlon CPU from 2000, with good caches, it
- still brings 4%.
- The declarations must occur before any system include files define any
- inline function, which is the case on UNIX_DGUX and UNIX_GNU.
- Only GCC supports global register variables. Not Apple's variant of GCC.
- And only the C frontend, not the C++ frontend, understands the syntax.
- And gcc-3.0 to 3.3.3 has severe bugs with global register variables, see
- CLISP bugs 710737 and 723097 and
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7871
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10684
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14937
- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14938
- Likewise, gcc-4.2 has severe bugs with global register variables, see
- CLISP bug 1836142 and http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34300
- Likewise for gcc-4.3-20080215 and probably future versions of GCC as well.
- Therefore for these versions of gcc enable the global register variables
- only when USE_GCC_REGISTER_VARIABLES is explicitly defined. */
- #if defined(GNU) && !(__APPLE_CC__ > 1) && !defined(__cplusplus) && !(__GNUC__ == 3 && (__GNUC_MINOR__ < 3 || (__GNUC_MINOR__ == 3 && __GNUC_PATCHLEVEL__ < 4))) && !(((__GNUC__ == 4 && __GNUC_MINOR__ >= 2) || __GNUC__ > 4) && !defined(USE_GCC_REGISTER_VARIABLES)) && !defined(MULTITHREAD) && (SAFETY < 2) && !defined(USE_JITC)
- /* Overview of use of registers in gcc terminology:
- fixed: mentioned in FIXED_REGISTERS
- used: mentioned in CALL_USED_REGISTERS but not FIXED_REGISTERS
- (i.e. caller-saved)
- save: otherwise (i.e. call-preserved, callee-saved)
- STACK mv_count value1 back_trace
- MC680X0 used
- I80386 save
- SPARC (gcc2) fixed fixed fixed used
- MIPS
- HPPA save save save save
- M88000 save save save
- ARM save
- DECALPHA save save save
- IA64
- AMD64
- S390 save
- Special notes:
- - gcc3/Sparc (Linux & Solaris) handles registers differently from gcc2. FIXME
- - If STACK is in a "used"/"save" register, it needs to be saved into
- saved_STACK upon begin_call(), so that asynchronous interrupts will
- be able to restore it.
- - All of the "used" registers need to be backed up upon begin_call()
- and restored during end_call().
- - All of the "save" registers need to be backed up upon begin_callback()
- and restored during end_callback().
- - When the interpreter does a longjmp(), the registers STACK, mv_count,
- value1 may need to be temporarily saved. This is highly machine
- dependent and is indicated by the NEED_temp_xxxx macros.
- * Register for STACK. */
- #if defined(MC680X0)
- #define STACK_register "a4" /* highest address register after sp=A7,fp=A6/A5 */
- #endif
- #if defined(I80386) && !defined(UNIX_BEOS) && !defined(DYNAMIC_MODULES)
- /* On BeOS, everything is compiled as PIC, hence %ebx is already booked.
- If DYNAMIC_MODULES is defined, external modules are compiled as PIC,
- which is why %ebx is already in use. */
- #if (__GNUC__ >= 2) /* The register names have changed */
- #define STACK_register "%ebx" /* one of the call-saved registers without special hardware commands */
- #else
- #define STACK_register "bx"
- #endif
- #endif
- #if defined(SPARC)
- #define STACK_register "%g5" /* a global register */
- #endif
- #if defined(HPPA) && (__GNUC__*100 + __GNUC_MINOR__ >= 2*100+7) /* gcc versions earlier than 2.7 had bugs */
- #define STACK_register "%r10" /* one of the general registers %r5..%r18 */
- #endif
- #if defined(M88000)
- #define STACK_register "%r14" /* one of the general registers %r14..%r25 */
- #endif
- #if defined(ARM)
- #define STACK_register "%r8" /* one of the general registers %r4..%r8 */
- #endif
- #if defined(DECALPHA)
- #define STACK_register "$9" /* one of the general registers $9..$14 */
- #endif
- #if defined(S390) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
- /* global register assignment did not work on s390 until gcc 3.1 */
- #define STACK_register "9" /* one of the general registers %r8..%r9 */
- #endif
- /* What about NEED_temp_STACK ?? Needed if STACK is in a "used" register??
- Register for mv_count. */
- #if defined(SPARC)
- #define mv_count_register "%g6"
- #if defined(UNIX_NETBSD)
- #define NEED_temp_mv_count
- #endif
- #endif
- #if defined(HPPA)
- #define mv_count_register "%r11" /* one of the general registers %r5..%r18 */
- #define NEED_temp_mv_count
- #endif
- #if defined(M88000)
- #define mv_count_register "%r15" /* one of the general registers %r14..%r25 */
- #define NEED_temp_mv_count
- #endif
- #if defined(DECALPHA)
- #define mv_count_register "$10" /* one of the general registers $9..$14 */
- #define NEED_temp_mv_count
- #endif
- /* Register for value1. */
- #if !(defined(WIDE) && !defined(WIDE_HARD))
- #if defined(SPARC)
- #define value1_register "%g7"
- #if defined(UNIX_NETBSD)
- #define NEED_temp_value1
- #endif
- #endif
- #if defined(HPPA)
- #define value1_register "%r12" /* one of the general registers %r5..%r18 */
- #define NEED_temp_value1
- #endif
- #if defined(M88000)
- #define value1_register "%r16" /* one of the general registers %r14..%r25 */
- #define NEED_temp_value1
- #endif
- #if defined(DECALPHA)
- #define value1_register "$11" /* one of the general registers $9..$14 */
- #define NEED_temp_value1
- #endif
- #endif
- /* Register for back_trace. */
- #if !(defined(WIDE) && !defined(WIDE_HARD))
- #if defined(SPARC)
- #define back_trace_register "%g4" /* a global register */
- /* %g4 seems to be a scratch-register as of lately with gcc 2.3
- This causes problems with libc.so.1.6.1 (and higher) (in getwd())
- That's why HAVE_SAVED_back_trace has been defined above. */
- #endif
- #if defined(HPPA)
- #define back_trace_register "%r13" /* one of the general registers %r5..%r18 */
- #endif
- #endif
- /* Declare the registers now (before any system include file which could
- contain some inline functions). */
- #ifdef STACK_register
- register long STACK_reg __asm__(STACK_register);
- #endif
- #ifdef mv_count_register
- register long mv_count_reg __asm__(mv_count_register);
- #endif
- #ifdef value1_register
- register long value1_reg __asm__(value1_register);
- #endif
- #ifdef back_trace_register
- register long back_trace_reg __asm__(back_trace_register);
- #endif
- /* Saving "save" registers. */
- #if (defined(I80386) || defined(HPPA) || defined(M88000) || defined(ARM) || defined(DECALPHA) || defined(S390)) && (defined(STACK_register) || defined(mv_count_register) || defined(value1_register) || defined(back_trace_register))
- #define HAVE_SAVED_REGISTERS
- struct registers {
- #ifdef STACK_register
- long STACK_register_contents;
- #endif
- #ifdef mv_count_register
- long mv_count_register_contents;
- #endif
- #ifdef value1_register
- long value1_register_contents;
- #endif
- #ifdef back_trace_register
- long back_trace_register_contents;
- #endif
- };
- extern per_thread struct registers * callback_saved_registers;
- #ifdef STACK_register
- #define SAVE_STACK_register(registers) \
- registers->STACK_register_contents = STACK_reg
- #define RESTORE_STACK_register(registers) \
- STACK_reg = registers->STACK_register_contents
- #else
- #define SAVE_STACK_register(registers)
- #define RESTORE_STACK_register(registers)
- #endif
- #ifdef mv_count_register
- #define SAVE_mv_count_register(registers) \
- registers->mv_count_register_contents = mv_count_reg
- #define RESTORE_mv_count_register(registers) \
- mv_count_reg = registers->mv_count_register_contents
- #else
- #define SAVE_mv_count_register(registers)
- #define RESTORE_mv_count_register(registers)
- #endif
- #ifdef value1_register
- #define SAVE_value1_register(registers) \
- registers->value1_register_contents = value1_reg
- #define RESTORE_value1_register(registers) \
- value1_reg = registers->value1_register_contents
- #else
- #define SAVE_value1_register(registers)
- #define RESTORE_value1_register(registers)
- #endif
- #ifdef back_trace_register
- #define SAVE_back_trace_register(registers) \
- registers->back_trace_register_contents = back_trace_reg
- #define RESTORE_back_trace_register(registers) \
- back_trace_reg = registers->back_trace_register_contents
- #else
- #define SAVE_back_trace_register(registers)
- #define RESTORE_back_trace_register(registers)
- #endif
- #define SAVE_REGISTERS(inner_statement) \
- do { \
- var struct registers * registers = alloca(sizeof(struct registers)); \
- SAVE_STACK_register(registers); \
- SAVE_mv_count_register(registers); \
- SAVE_value1_register(registers); \
- SAVE_back_trace_register(registers); \
- inner_statement; \
- { var gcv_object_t* top_of_frame = STACK; \
- pushSTACK(fake_gcv_object((aint)callback_saved_registers)); \
- finish_frame(CALLBACK); \
- } \
- callback_saved_registers = registers; \
- } while(0)
- #define RESTORE_REGISTERS(inner_statement) \
- do { \
- var struct registers * registers = callback_saved_registers; \
- if (!(framecode(STACK_0) == CALLBACK_frame_info)) abort(); \
- callback_saved_registers = (struct registers *)(aint)as_oint(STACK_1);\
- skipSTACK(2); \
- inner_statement; \
- RESTORE_STACK_register(registers); \
- RESTORE_mv_count_register(registers); \
- RESTORE_value1_register(registers); \
- RESTORE_back_trace_register(registers); \
- } while(0)
- #endif
- /* Saving the STACK (for asynchronous interrupts).
- If STACK is a global variable or lies in a register which is left
- untouched by operating system and library (this is the case on SUN4),
- we don't need to worry about it. */
- #if defined(STACK_register) && !defined(SUN4)
- #define HAVE_SAVED_STACK
- #endif
- /* Saving "used" registers. */
- #if defined(mv_count_register) && 0
- #define HAVE_SAVED_mv_count
- #endif
- #if defined(value1_register) && 0
- #define HAVE_SAVED_value1
- #endif
- #if defined(back_trace_register) && defined(SPARC)
- #define HAVE_SAVED_back_trace
- #endif
- #endif
- #ifndef HAVE_SAVED_REGISTERS
- #define SAVE_REGISTERS(inner_statement)
- #define RESTORE_REGISTERS(inner_statement)
- #endif
- %% #ifdef HAVE_SAVED_REGISTERS
- %% puts("#ifndef IN_MODULE_CC");
- %% #ifdef STACK_register
- %% printf("register long STACK_reg __asm__(\"%s\");\n",STACK_register);
- %% #endif
- %% #ifdef mv_count_register
- %% printf("register long mv_count_reg __asm__(\"%s\");\n",mv_count_register);
- %% #endif
- %% #ifdef value1_register
- %% printf("register long value1_reg __asm__(\"%s\");\n",value1_register);
- %% #endif
- %% #ifdef back_trace_register
- %% printf("register long back_trace_reg __asm__(\"%s\");\n",back_trace_register);
- %% #endif
- %% printf("struct registers { ");
- %% #ifdef STACK_register
- %% printf("long STACK_register_contents; ");
- %% #endif
- %% #ifdef mv_count_register
- %% printf("long mv_count_register_contents; ");
- %% #endif
- %% #ifdef value1_register
- %% printf("long value1_register_contents; ");
- %% #endif
- %% #ifdef back_trace_register
- %% printf("long back_trace_register_contents; ");
- %% #endif
- %% puts("};");
- %% puts("extern struct registers * callback_saved_registers;");
- %% puts("#endif");
- %% #endif
- #define VALUES_IF(cond) \
- do { value1 = (cond) ? T : NIL; mv_count = 1; } while (0)
- %% export_def(VALUES_IF(C));
- #define VALUES0 \
- do { value1 = NIL; mv_count = 0; } while (0)
- %% export_def(VALUES0);
- #define VALUES1(A) \
- do { value1 = (A); mv_count = 1; } while (0)
- %% export_def(VALUES1(A));
- #define VALUES2(A,B) \
- do { value1 = (A); value2 = (B); mv_count = 2; } while (0)
- %% export_def(VALUES2(A,B));
- #define VALUES3(A,B,C) \
- do { value1 = (A); value2 = (B); value3 = (C); mv_count = 3; } while (0)
- %% export_def(VALUES3(A,B,C));
- /* ###################### Macros for C #################### */
- #if !defined(return_void)
- /* To return a type of value void: return_void(...); */
- #ifdef GNU
- #define return_void return /* 'return void;' is admissible */
- #else
- /* In general it is not legal to return `void' values. */
- #define return_void /* Don't use 'return' for expressions of type 'void'. */
- #endif
- #endif
- #if defined(GNU) && defined(__GNUG__)
- /* Although legal, g++ warns about 'return void;'. Shut up the warning. */
- #undef return_void
- #define return_void
- #endif
- #if !defined(GNU) && !defined(inline)
- #define inline /* inline foo() {...} --> foo() {...} */
- #endif
- %% puts("#if !defined(__GNUC__) && !defined(inline)");
- %% puts("#define inline");
- %% puts("#endif");
- /* Definitions for C++-Compilers: */
- #ifdef __cplusplus
- #define BEGIN_DECLS extern "C" {
- #define END_DECLS }
- #else
- #define BEGIN_DECLS
- #define END_DECLS
- #endif
- %% export_def(BEGIN_DECLS);
- %% export_def(END_DECLS);
- /* Empty macro-arguments:
- Some compilers (ie. cc under HP-UX) seem to interpret a macro call
- foo(arg1,...,argn,) as equivalent to foo(arg1,...,argn), which will
- yield an error. _EMA_ stands for "empty macro argument".
- It will be inserted by CC_NEED_DEEMA,
- each time between comma and closing parentheses.
- It is also needed when potentially empty arguments
- are returned to other macros */
- #define _EMA_
- /* Concatenation of two macro-expanded tokens:
- Example:
- #undef x
- #define y 16
- CONCAT(x,y) ==> 'x16' (not 'xy' !) */
- #define CONCAT_(xxx,yyy) xxx##yyy
- #define CONCAT3_(aaa,bbb,ccc) aaa##bbb##ccc
- #define CONCAT4_(aaa,bbb,ccc,ddd) aaa##bbb##ccc##ddd
- #define CONCAT5_(aaa,bbb,ccc,ddd,eee) aaa##bbb##ccc##ddd##eee
- #define CONCAT6_(aaa,bbb,ccc,ddd,eee,fff) aaa##bbb##ccc##ddd##eee##fff
- #define CONCAT7_(aaa,bbb,ccc,ddd,eee,fff,ggg) aaa##bbb##ccc##ddd##eee##fff##ggg
- #define CONCAT(xxx,yyy) CONCAT_(xxx,yyy)
- #define CONCAT3(aaa,bbb,ccc) CONCAT3_(aaa,bbb,ccc)
- #define CONCAT4(aaa,bbb,ccc,ddd) CONCAT4_(aaa,bbb,ccc,ddd)
- #define CONCAT5(aaa,bbb,ccc,ddd,eee) CONCAT5_(aaa,bbb,ccc,ddd,eee)
- #define CONCAT6(aaa,bbb,ccc,ddd,eee,fff) CONCAT6_(aaa,bbb,ccc,ddd,eee,fff)
- #define CONCAT7(aaa,bbb,ccc,ddd,eee,fff,ggg) CONCAT7_(aaa,bbb,ccc,ddd,eee,fff,ggg)
- %% puts("#define CONCAT_(xxx,yyy) xxx##yyy");
- %% puts("#define CONCAT3_(aaa,bbb,ccc) aaa##bbb##ccc");
- %% #if notused
- %% puts("#define CONCAT4_(aaa,bbb,ccc,ddd) aaa##bbb##ccc##ddd");
- %% puts("#define CONCAT5_(aaa,bbb,ccc,ddd,eee) aaa##bbb##ccc##ddd##eee");
- %% #endif
- %% puts("#define CONCAT(xxx,yyy) CONCAT_(xxx,yyy)");
- %% puts("#define CONCAT3(aaa,bbb,ccc) CONCAT3_(aaa,bbb,ccc)");
- %% #if notused
- %% puts("#define CONCAT4(aaa,bbb,ccc,ddd) CONCAT4_(aaa,bbb,ccc,ddd)");
- %% puts("#define CONCAT5(aaa,bbb,ccc,ddd,eee) CONCAT5_(aaa,bbb,ccc,ddd,eee)");
- %% #endif
- /* Generation of goto-tag macros:
- GENTAG(end) ==> end116
- This allows a macro defining marks to be used more than once per function
- but still only once per source-line. */
- #define GENTAG(xxx) CONCAT(xxx,__LINE__)
- /* Converting tokens to strings:
- STRING(token) ==> "token" */
- #define STRING(token) #token
- #define STRINGIFY(token) STRING(token)
- %% puts("#define STRING(token) #token");
- %% puts("#define STRINGIFY(token) STRING(token)");
- /* Storage-Class-Specifier in top-level-declarations:
- for variables:
- global globally visible variable
- local variable that is only visible in the file (local)
- extern pointer to a variable that's defined externally
- for functions:
- global globally visible function
- local function that is only visible in the file (local)
- extern pointer to a function that's defined externally
- extern_C pointer to a c-function that's defined externally
- nonreturning function that will never return
- maygc function that can trigger GC */
- #define global
- #define local static
- /* #define extern extern */
- #ifdef __cplusplus
- #define extern_C extern "C"
- #else
- #define extern_C extern
- #endif
- /* Declaration of a function that will never return (nonreturning function)
- nonreturning_function(extern,abort,(void)); == extern void abort (void); */
- #if defined(GNU) && !(__APPLE_CC__ > 1)
- #if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7))
- /* Note:
- storclass __attribute__((__noreturn__)) void funname arguments
- works in gcc 2.95 or newer, and in g++ 2.7.2 or newer.
- storclass void __attribute__((__noreturn__)) funname arguments
- works in gcc 2.7.2 or newer and in g++ 2.7.2 or newer.
- storclass void funname arguments __attribute__((__noreturn__))
- works in gcc 2.7.2 or newer and in g++ 2.7.2 or newer, but
- only when followed by a semicolon, not in a function definition. */
- #define nonreturning_function(storclass,funname,arguments) \
- storclass void __attribute__((__noreturn__)) funname arguments
- #else
- #define nonreturning_function(storclass,funname,arguments) \
- storclass void funname arguments
- #endif
- #elif defined(MICROSOFT)
- #define nonreturning_function(storclass,funname,arguments) \
- __declspec(noreturn) storclass void funname arguments
- #else
- #define nonreturning_function(storclass,funname,arguments) \
- storclass void funname arguments
- #endif
- %% export_def(nonreturning_function(storclass,funname,arguments));
- /* A function that can trigger GC is declared either as
- - maygc, if (1) all callers must assume the worst case: that it triggers GC,
- and (2) the function uses only the 'object's passed as arguments and
- on the STACK, but no objects stored in other non-GCsafe locations.
- - /*maygc*/ otherwise. If (1) is not fulfilled, the functions begins
- with an appropriate GCTRIGGER_IF statement. If (2) is not
- fulfilled, the GCTRIGGER call needs to mention all other
- non-GCsafe locations whose values are used by the function,
- such as 'value1' or 'mv_space'. */
- #define maygc
- /* Storage-Class-Specifier in declarations at the beginning of a block:
- var will lead a variable declaration
- used by utils/varbrace to allow declarations mixed with other statements */
- #define var
- /* Ignore C++ keyword. */
- #define export export_sym
- /* Swap the contents of two variables: swap(register int, x1, x2); */
- #define swap(swap_type,swap_var1,swap_var2) \
- do { var swap_type swap_temp; \
- swap_temp = swap_var1; swap_var1 = swap_var2; swap_var2 = swap_temp; \
- } while(0)
- /* Marking a program line that may not be reached: NOTREACHED; */
- #define NOTREACHED error_notreached(__FILE__,__LINE__)
- %% puts("#define NOTREACHED error_notreached(__FILE__,__LINE__)");
- /* Asserting an arithmetic expression: ASSERT(expr); */
- #define ASSERT(expr) do { if (!(expr)) NOTREACHED; } while(0)
- %% puts("#define ASSERT(expr) do { if (!(expr)) NOTREACHED; } while(0)");
- /* alloca() */
- #ifdef GNU
- #define alloca __builtin_alloca
- #elif defined(MICROSOFT)
- #include <malloc.h>
- #define alloca _alloca
- #elif defined(HAVE_ALLOCA_H)
- #include <alloca.h>
- #ifndef alloca /* Manche definieren 'alloca' als Macro... */
- #if !(defined(UNIX_OSF) || defined(UNIX_DEC_ULTRIX))
- /* OSF/1 V3 declares `alloca' as returning char*, but in OSF/1 V4
- it returns void*. I don't know how to distinguish the two. */
- extern_C void* alloca (int size); /* see MALLOC(3V) */
- #endif
- #endif
- #elif defined(_AIX)
- #pragma alloca /* AIX requires this to be the first thing in the file. */
- #elif defined(BORLAND)
- #include <malloc.h> /* defines 'alloca' as macro */
- #elif !defined(NO_ALLOCA)
- extern_C void* alloca (int size); /* see MALLOC(3V) */
- #endif
- %% #ifdef GNU
- %% emit_define("alloca","__builtin_alloca");
- %% #elif defined(MICROSOFT)
- %% puts("#include <malloc.h>");
- %% emit_define("alloca","_alloca");
- %% #elif defined(HAVE_ALLOCA_H)
- %% puts("#include <alloca.h>");
- %% #ifndef alloca
- %% #if !(defined(UNIX_OSF) || defined(UNIX_DEC_ULTRIX))
- %% puts("extern void* alloca (int size);");
- %% #endif
- %% #endif
- %% #elif defined(_AIX)
- %% puts("#pragma alloca");
- %% #elif !defined(NO_ALLOCA)
- %% puts("extern void* alloca (int size);");
- %% #endif
- #define MALLOC(size,type) (type*)malloc((size)*sizeof(type))
- /* Literal constants of 64-bit integer types
- LL(nnnn) = nnnn parsed as a sint64
- ULL(nnnn) = nnnn parsed as a uint64 */
- #if defined(HAVE_LONG_LONG_INT)
- #define LL(nnnn) nnnn##LL
- #define ULL(nnnn) nnnn##ULL
- #elif defined(MICROSOFT)
- #define LL(nnnn) nnnn##i64
- #define ULL(nnnn) nnnn##ui64
- #endif
- %% #if defined(HAVE_LONG_LONG_INT)
- %% puts("#define LL(nnnn) nnnn##LL");
- %% puts("#define ULL(nnnn) nnnn##ULL");
- %% #elif defined(MICROSOFT)
- %% puts("#define LL(nnnn) nnnn##i64");
- %% puts("#define ULL(nnnn) nnnn##ui64");
- %% #endif
- /* Synonyms for Byte, Word, Longword:
- SBYTE = signed 8 bit integer
- UBYTE = unsigned 8 bit int
- SWORD = signed 16 bit int
- UWORD = unsigned 16 bit int
- SLONG = signed 32 bit int
- ULONG = unsigned 32 bit int
- On the other hand, "char" is only used as an element of a string
- You never really compute with a "char"; it might depend on
- __CHAR_UNSIGNED___! */
- #if (char_bitsize==8)
- #ifdef __CHAR_UNSIGNED__
- typedef signed char SBYTE;
- #else
- typedef char SBYTE;
- #endif
- typedef unsigned char UBYTE;
- #else
- #error "No 8 bit integer type? -- Which Interger-type has 8 Bit?"
- #endif
- #if (short_bitsize==16)
- typedef short SWORD;
- typedef unsigned short UWORD;
- #else
- #error "No 16 bit integer type? -- Which Integer-type has 16 Bit?"
- #endif
- #if (long_bitsize==32)
- typedef long SLONG;
- typedef unsigned long ULONG;
- #elif (int_bitsize==32)
- typedef int SLONG;
- typedef unsigned int ULONG;
- #else
- #error "No 32 bit integer type? -- Which Integer-type has 32 Bit?"
- #endif
- #if (long_bitsize==64)
- typedef long SLONGLONG;
- typedef unsigned long ULONGLONG;
- #ifndef HAVE_LONG_LONG_INT
- #define HAVE_LONG_LONG_INT
- #endif
- #elif defined(MICROSOFT)
- typedef __int64 SLONGLONG;
- typedef unsigned __int64 ULONGLONG;
- #define HAVE_LONG_LONG_INT
- #elif defined(HAVE_LONG_LONG_INT)
- #if defined(long_long_bitsize) && (long_long_bitsize==64)
- typedef long long SLONGLONG;
- typedef unsigned long long ULONGLONG;
- #else /* useless type */
- #undef HAVE_LONG_LONG_INT
- #endif
- #endif
- #if defined(WIDE) && !defined(HAVE_LONG_LONG_INT)
- #error "No 64 bit integer type? -- Which Integer-type has 64 Bit?"
- #endif
- %% #ifdef __CHAR_UNSIGNED__
- %% emit_typedef("signed char","SBYTE");
- %% #else
- %% emit_typedef("char","SBYTE");
- %% #endif
- %% emit_typedef("unsigned char","UBYTE");
- %% emit_typedef("short","SWORD");
- %% emit_typedef("unsigned short","UWORD");
- %% #if (long_bitsize==32)
- %% emit_typedef("long","SLONG");
- %% emit_typedef("unsigned long","ULONG");
- %% #elif (int_bitsize==32)
- %% emit_typedef("int","SLONG");
- %% emit_typedef("unsigned int","ULONG");
- %% #endif
- %% #if (long_bitsize==64)
- %% emit_typedef("long","SLONGLONG");
- %% emit_typedef("unsigned long","ULONGLONG");
- %% #elif defined(MICROSOFT)
- %% emit_typedef("__int64","SLONGLONG");
- %% emit_typedef("unsigned __int64","ULONGLONG");
- %% #elif defined(HAVE_LONG_LONG_INT)
- %% emit_typedef("long long","SLONGLONG");
- %% emit_typedef("unsigned long long","ULONGLONG");
- %% #endif
- #include <stdbool.h> /* boolean values */
- %% #ifdef HAVE_STDBOOL_H
- %% puts("#include <stdbool.h>");
- %% #else
- %% print_file("stdbool.h");
- %% #endif
- /* Type for signed values, results of comparisons, tertiary enums
- with values +1, 0, -1 */
- typedef signed int signean;
- #define signean_plus 1 /* +1 */
- #define signean_null 0 /* 0 */
- #define signean_minus -1 /* -1 */
- /* Null pointers */
- #ifdef __cplusplus
- #undef NULL
- #define NULL 0
- #elif !(defined(INTEL) || defined(_AIX))
- #undef NULL
- #define NULL ((void*) 0L)
- #endif
- %% puts("#undef NULL");
- %% export_def(NULL);
- #include <stdio.h> /* libc i/o */
- /* A more precise classification of the operating system:
- (This test works only after at least one system header has been included.) */
- #if (__GLIBC__ >= 2)
- #define UNIX_GNU /* glibc2 (may be UNIX_LINUX, UNIX_HURD or UNIX_FREEBSD) */
- #endif
- /* Determine the offset of a component 'ident' in a struct of the type 'type':
- See 0 as pointer to 'type', put a struct 'type' there and determine the
- address of its component 'ident' and return it as number: */
- #if defined(HAVE_OFFSETOF) || defined(__MINGW32__) || (defined(BORLAND) && defined(WIN32)) || defined(MICROSOFT)
- #include <stddef.h>
- #else
- #undef offsetof
- #define o…
Large files files are truncated, but you can click here to view the full file