[BACK]Return to gcconfig.h CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / gc / include / private

Annotation of OpenXM_contrib2/asir2000/gc/include/private/gcconfig.h, Revision 1.9

1.1       noro        1: /*
                      2:  * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
                      3:  * Copyright (c) 1991-1994 by Xerox Corporation.  All rights reserved.
                      4:  * Copyright (c) 1996 by Silicon Graphics.  All rights reserved.
1.3       noro        5:  * Copyright (c) 2000 by Hewlett-Packard Company.  All rights reserved.
1.1       noro        6:  *
                      7:  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
                      8:  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
                      9:  *
                     10:  * Permission is hereby granted to use or copy this program
                     11:  * for any purpose,  provided the above notices are retained on all copies.
                     12:  * Permission to modify the code and to distribute modified code is granted,
                     13:  * provided the above notices are retained, and a notice that the code was
                     14:  * modified is included with the above copyright notice.
                     15:  */
1.9     ! noro       16:
        !            17: /*
        !            18:  * This header is private to the gc.  It is almost always included from
        !            19:  * gc_priv.h.  However it is possible to include it by itself if just the
        !            20:  * configuration macros are needed.  In that
        !            21:  * case, a few declarations relying on types declared in gc_priv.h will be
        !            22:  * omitted.
        !            23:  */
1.1       noro       24:
1.3       noro       25: #ifndef GCCONFIG_H
1.1       noro       26:
1.3       noro       27: # define GCCONFIG_H
1.1       noro       28:
1.9     ! noro       29: # ifndef GC_PRIVATE_H
        !            30:     /* Fake ptr_t declaration, just to avoid compilation errors.       */
        !            31:     /* This avoids many instances if "ifndef GC_PRIVATE_H" below.      */
        !            32:     typedef struct GC_undefined_struct * ptr_t;
        !            33: # endif
        !            34:
1.1       noro       35: /* Machine dependent parameters.  Some tuning parameters can be found  */
                     36: /* near the top of gc_private.h.                                       */
                     37:
                     38: /* Machine specific parts contributed by various people.  See README file. */
                     39:
                     40: /* First a unified test for Linux: */
                     41: # if defined(linux) || defined(__linux__)
1.9     ! noro       42: #  ifndef LINUX
1.1       noro       43: #    define LINUX
1.9     ! noro       44: #  endif
1.1       noro       45: # endif
                     46:
1.3       noro       47: /* And one for NetBSD: */
                     48: # if defined(__NetBSD__)
                     49: #    define NETBSD
                     50: # endif
                     51:
1.6       noro       52: /* And one for OpenBSD: */
                     53: # if defined(__OpenBSD__)
                     54: #    define OPENBSD
                     55: # endif
                     56:
                     57: /* And one for FreeBSD: */
                     58: # if defined(__FreeBSD__)
                     59: #    define FREEBSD
                     60: # endif
                     61:
1.1       noro       62: /* Determine the machine type: */
1.6       noro       63: # if defined(__XSCALE__)
                     64: #    define ARM32
                     65: #    if !defined(LINUX)
                     66: #      define NOSYS
                     67: #      define mach_type_known
                     68: #    endif
                     69: # endif
1.1       noro       70: # if defined(sun) && defined(mc68000)
                     71: #    define M68K
                     72: #    define SUNOS4
                     73: #    define mach_type_known
                     74: # endif
                     75: # if defined(hp9000s300)
                     76: #    define M68K
                     77: #    define HP
                     78: #    define mach_type_known
                     79: # endif
1.6       noro       80: # if defined(OPENBSD) && defined(m68k)
1.1       noro       81: #    define M68K
                     82: #    define mach_type_known
                     83: # endif
1.6       noro       84: # if defined(OPENBSD) && defined(__sparc__)
1.1       noro       85: #    define SPARC
                     86: #    define mach_type_known
                     87: # endif
1.6       noro       88: # if defined(NETBSD) && defined(m68k)
1.1       noro       89: #    define M68K
1.3       noro       90: #    define mach_type_known
                     91: # endif
1.6       noro       92: # if defined(NETBSD) && defined(__powerpc__)
1.3       noro       93: #    define POWERPC
                     94: #    define mach_type_known
                     95: # endif
1.6       noro       96: # if defined(NETBSD) && defined(__arm32__)
1.3       noro       97: #    define ARM32
1.1       noro       98: #    define mach_type_known
                     99: # endif
                    100: # if defined(vax)
                    101: #    define VAX
                    102: #    ifdef ultrix
                    103: #      define ULTRIX
                    104: #    else
                    105: #      define BSD
                    106: #    endif
                    107: #    define mach_type_known
                    108: # endif
1.6       noro      109: # if defined(mips) || defined(__mips) || defined(_mips)
1.1       noro      110: #    define MIPS
1.6       noro      111: #    if defined(nec_ews) || defined(_nec_ews)
                    112: #      define EWS4800
                    113: #    endif
                    114: #    if !defined(LINUX) && !defined(EWS4800)
1.3       noro      115: #      if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
                    116: #       define ULTRIX
                    117: #      else
                    118: #       if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
                    119:            || defined(__SYSTYPE_SVR4__)
                    120: #         define IRIX5   /* or IRIX 6.X */
                    121: #       else
                    122: #         define RISCOS  /* or IRIX 4.X */
                    123: #       endif
                    124: #      endif
                    125: #    endif /* !LINUX */
                    126: #    if defined(__NetBSD__) && defined(__MIPSEL__)
                    127: #      undef ULTRIX
1.1       noro      128: #    endif
                    129: #    define mach_type_known
                    130: # endif
1.6       noro      131: # if defined(DGUX) && (defined(i386) || defined(__i386__))
                    132: #    define I386
                    133: #    ifndef _USING_DGUX
                    134: #    define _USING_DGUX
                    135: #    endif
                    136: #    define mach_type_known
                    137: # endif
1.3       noro      138: # if defined(sequent) && (defined(i386) || defined(__i386__))
1.1       noro      139: #    define I386
                    140: #    define SEQUENT
                    141: #    define mach_type_known
                    142: # endif
1.3       noro      143: # if defined(sun) && (defined(i386) || defined(__i386__))
1.1       noro      144: #    define I386
                    145: #    define SUNOS5
                    146: #    define mach_type_known
                    147: # endif
                    148: # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
                    149: #    define I386
                    150: #    define OS2
                    151: #    define mach_type_known
                    152: # endif
                    153: # if defined(ibm032)
                    154: #   define RT
                    155: #   define mach_type_known
                    156: # endif
                    157: # if defined(sun) && (defined(sparc) || defined(__sparc))
                    158: #   define SPARC
                    159:     /* Test for SunOS 5.x */
                    160: #     include <errno.h>
                    161: #     ifdef ECHRNG
                    162: #       define SUNOS5
                    163: #     else
                    164: #      define SUNOS4
                    165: #     endif
                    166: #   define mach_type_known
                    167: # endif
                    168: # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
1.3       noro      169:      && !defined(__OpenBSD__) && !(__NetBSD__)
1.1       noro      170: #   define SPARC
                    171: #   define DRSNX
                    172: #   define mach_type_known
                    173: # endif
                    174: # if defined(_IBMR2)
                    175: #   define RS6000
                    176: #   define mach_type_known
                    177: # endif
1.3       noro      178: # if defined(__NetBSD__) && defined(__sparc__)
                    179: #   define SPARC
                    180: #   define mach_type_known
                    181: # endif
1.1       noro      182: # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
                    183:        /* The above test may need refinement   */
                    184: #   define I386
                    185: #   if defined(_SCO_ELF)
                    186: #     define SCO_ELF
                    187: #   else
                    188: #     define SCO
                    189: #   endif
                    190: #   define mach_type_known
                    191: # endif
                    192: # if defined(_AUX_SOURCE)
                    193: #   define M68K
                    194: #   define SYSV
                    195: #   define mach_type_known
                    196: # endif
1.3       noro      197: # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
1.1       noro      198:      || defined(hppa) || defined(__hppa__)
                    199: #   define HP_PA
1.3       noro      200: #   ifndef LINUX
                    201: #     define HPUX
                    202: #   endif
1.1       noro      203: #   define mach_type_known
                    204: # endif
1.6       noro      205: # if defined(__ia64) && defined(_HPUX_SOURCE)
                    206: #   define IA64
                    207: #   define HPUX
                    208: #   define mach_type_known
                    209: # endif
1.3       noro      210: # if defined(__BEOS__) && defined(_X86_)
                    211: #    define I386
                    212: #    define BEOS
                    213: #    define mach_type_known
                    214: # endif
1.1       noro      215: # if defined(LINUX) && (defined(i386) || defined(__i386__))
                    216: #    define I386
                    217: #    define mach_type_known
                    218: # endif
1.9     ! noro      219: # if defined(LINUX) && defined(__x86_64__)
        !           220: #    define X86_64
        !           221: #    define mach_type_known
        !           222: # endif
1.3       noro      223: # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
                    224: #    define IA64
                    225: #    define mach_type_known
                    226: # endif
1.6       noro      227: # if defined(LINUX) && defined(__arm__)
                    228: #    define ARM32
                    229: #    define mach_type_known
                    230: # endif
1.9     ! noro      231: # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || defined(powerpc64) || defined(__powerpc64__))
1.1       noro      232: #    define POWERPC
                    233: #    define mach_type_known
                    234: # endif
                    235: # if defined(LINUX) && defined(__mc68000__)
                    236: #    define M68K
                    237: #    define mach_type_known
                    238: # endif
1.3       noro      239: # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
1.1       noro      240: #    define SPARC
                    241: #    define mach_type_known
                    242: # endif
1.3       noro      243: # if defined(LINUX) && defined(__arm__)
                    244: #    define ARM32
                    245: #    define mach_type_known
                    246: # endif
                    247: # if defined(LINUX) && defined(__sh__)
                    248: #    define SH
                    249: #    define mach_type_known
                    250: # endif
1.1       noro      251: # if defined(__alpha) || defined(__alpha__)
                    252: #   define ALPHA
1.6       noro      253: #   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
1.1       noro      254: #     define OSF1      /* a.k.a Digital Unix */
                    255: #   endif
                    256: #   define mach_type_known
                    257: # endif
                    258: # if defined(_AMIGA) && !defined(AMIGA)
                    259: #   define AMIGA
                    260: # endif
                    261: # ifdef AMIGA
                    262: #   define M68K
                    263: #   define mach_type_known
                    264: # endif
                    265: # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
                    266: #   define M68K
                    267: #   define MACOS
                    268: #   define mach_type_known
                    269: # endif
1.6       noro      270: # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
1.1       noro      271: #   define POWERPC
                    272: #   define MACOS
                    273: #   define mach_type_known
                    274: # endif
1.3       noro      275: # if defined(macosx) || \
                    276:      defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
1.9     ! noro      277: #    define DARWIN
1.1       noro      278: #    define POWERPC
                    279: #    define mach_type_known
                    280: # endif
1.3       noro      281: # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
1.9     ! noro      282: #    define DARWIN
1.3       noro      283: #    define I386
                    284:      --> Not really supported, but at least we recognize it.
                    285: # endif
1.1       noro      286: # if defined(NeXT) && defined(mc68000)
                    287: #   define M68K
                    288: #   define NEXT
                    289: #   define mach_type_known
                    290: # endif
1.3       noro      291: # if defined(NeXT) && (defined(i386) || defined(__i386__))
1.1       noro      292: #   define I386
                    293: #   define NEXT
                    294: #   define mach_type_known
                    295: # endif
1.3       noro      296: # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
1.1       noro      297: #   define I386
                    298: #   define OPENBSD
                    299: #   define mach_type_known
                    300: # endif
1.6       noro      301: # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
1.1       noro      302: #   define I386
                    303: #   define mach_type_known
                    304: # endif
1.3       noro      305: # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
1.1       noro      306: #   define I386
                    307: #   define mach_type_known
                    308: # endif
1.3       noro      309: # if defined(bsdi) && (defined(i386) || defined(__i386__))
1.1       noro      310: #    define I386
                    311: #    define BSDI
                    312: #    define mach_type_known
                    313: # endif
                    314: # if !defined(mach_type_known) && defined(__386BSD__)
                    315: #   define I386
                    316: #   define THREE86BSD
                    317: #   define mach_type_known
                    318: # endif
                    319: # if defined(_CX_UX) && defined(_M88K)
                    320: #   define M88K
                    321: #   define CX_UX
                    322: #   define mach_type_known
                    323: # endif
1.6       noro      324: # if defined(DGUX) && defined(m88k)
1.1       noro      325: #   define M88K
                    326:     /* DGUX defined */
                    327: #   define mach_type_known
                    328: # endif
1.3       noro      329: # if defined(_WIN32_WCE)
                    330:     /* SH3, SH4, MIPS already defined for corresponding architectures */
                    331: #   if defined(SH3) || defined(SH4)
                    332: #     define SH
                    333: #   endif
                    334: #   if defined(x86)
                    335: #     define I386
                    336: #   endif
                    337: #   if defined(ARM)
                    338: #     define ARM32
                    339: #   endif
                    340: #   define MSWINCE
                    341: #   define mach_type_known
                    342: # else
                    343: #   if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
                    344:         || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
                    345: #     define I386
                    346: #     define MSWIN32   /* or Win32s */
                    347: #     define mach_type_known
                    348: #   endif
1.1       noro      349: # endif
                    350: # if defined(__DJGPP__)
                    351: #   define I386
                    352: #   ifndef DJGPP
                    353: #     define DJGPP  /* MSDOS running the DJGPP port of GCC */
                    354: #   endif
                    355: #   define mach_type_known
                    356: # endif
                    357: # if defined(__CYGWIN32__) || defined(__CYGWIN__)
                    358: #   define I386
                    359: #   define CYGWIN32
                    360: #   define mach_type_known
                    361: # endif
1.3       noro      362: # if defined(__MINGW32__)
                    363: #   define I386
                    364: #   define MSWIN32
                    365: #   define mach_type_known
                    366: # endif
1.1       noro      367: # if defined(__BORLANDC__)
                    368: #   define I386
                    369: #   define MSWIN32
                    370: #   define mach_type_known
                    371: # endif
                    372: # if defined(_UTS) && !defined(mach_type_known)
                    373: #   define S370
                    374: #   define UTS4
                    375: #   define mach_type_known
                    376: # endif
1.3       noro      377: # if defined(__pj__)
                    378: #   define PJ
                    379: #   define mach_type_known
                    380: # endif
                    381: # if defined(__embedded__) && defined(PPC)
                    382: #   define POWERPC
                    383: #   define NOSYS
                    384: #   define mach_type_known
                    385: # endif
1.1       noro      386: /* Ivan Demakov */
                    387: # if defined(__WATCOMC__) && defined(__386__)
                    388: #   define I386
                    389: #   if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
                    390: #     if defined(__OS2__)
                    391: #       define OS2
                    392: #     else
                    393: #       if defined(__WINDOWS_386__) || defined(__NT__)
                    394: #         define MSWIN32
                    395: #       else
                    396: #         define DOS4GW
                    397: #       endif
                    398: #     endif
                    399: #   endif
                    400: #   define mach_type_known
                    401: # endif
1.3       noro      402: # if defined(__s390__) && defined(LINUX)
1.9     ! noro      403: #    define S390
1.3       noro      404: #    define mach_type_known
                    405: # endif
1.6       noro      406: # if defined(__GNU__)
                    407: #   if defined(__i386__)
                    408: /* The Debian Hurd running on generic PC */
                    409: #     define  HURD
                    410: #     define  I386
                    411: #     define  mach_type_known
                    412: #    endif
                    413: # endif
1.1       noro      414:
                    415: /* Feel free to add more clauses here */
                    416:
                    417: /* Or manually define the machine type here.  A machine type is        */
                    418: /* characterized by the architecture.  Some                            */
                    419: /* machine types are further subdivided by OS.                         */
                    420: /* the macros ULTRIX, RISCOS, and BSD to distinguish.                  */
                    421: /* Note that SGI IRIX is treated identically to RISCOS.                        */
                    422: /* SYSV on an M68K actually means A/UX.                                        */
                    423: /* The distinction in these cases is usually the stack starting address */
                    424: # ifndef mach_type_known
                    425:        --> unknown machine type
                    426: # endif
                    427:                    /* Mapping is: M68K       ==> Motorola 680X0        */
                    428:                    /*             (SUNOS4,HP,NEXT, and SYSV (A/UX),    */
                    429:                    /*             MACOS and AMIGA variants)            */
                    430:                    /*             I386       ==> Intel 386             */
                    431:                    /*              (SEQUENT, OS2, SCO, LINUX, NETBSD,  */
                    432:                    /*               FREEBSD, THREE86BSD, MSWIN32,      */
                    433:                    /*               BSDI,SUNOS5, NEXT, other variants) */
                    434:                     /*             NS32K      ==> Encore Multimax      */
                    435:                     /*             MIPS       ==> R2000 or R3000       */
                    436:                     /*                 (RISCOS, ULTRIX variants)       */
                    437:                     /*            VAX        ==> DEC VAX               */
                    438:                     /*                 (BSD, ULTRIX variants)          */
                    439:                     /*            RS6000     ==> IBM RS/6000 AIX3.X    */
                    440:                     /*            RT         ==> IBM PC/RT             */
                    441:                     /*            HP_PA      ==> HP9000/700 & /800     */
1.6       noro      442:                     /*                           HP/UX, LINUX          */
1.3       noro      443:                    /*             SPARC      ==> SPARC v7/v8/v9        */
                    444:                    /*                  (SUNOS4, SUNOS5, LINUX,         */
1.1       noro      445:                    /*                   DRSNX variants)                */
                    446:                    /*             ALPHA      ==> DEC Alpha             */
                    447:                    /*                  (OSF1 and LINUX variants)       */
                    448:                    /*             M88K       ==> Motorola 88XX0        */
                    449:                    /*                  (CX_UX and DGUX)                */
                    450:                    /*             S370       ==> 370-like machine      */
                    451:                    /*                  running Amdahl UTS4             */
1.9     ! noro      452:                     /*             S390       ==> 390-like machine      */
        !           453:                    /*                  running LINUX                   */
1.3       noro      454:                    /*             ARM32      ==> Intel StrongARM       */
1.6       noro      455:                    /*             IA64       ==> Intel IPF             */
1.3       noro      456:                    /*                            (e.g. Itanium)        */
1.6       noro      457:                    /*                  (LINUX and HPUX)                */
1.3       noro      458:                    /*             SH         ==> Hitachi SuperH        */
                    459:                    /*                  (LINUX & MSWINCE)               */
1.9     ! noro      460:                    /*             X86_64     ==> AMD x86-64            */
        !           461:                    /*             POWERPC    ==> IBM/Apple PowerPC     */
        !           462:                    /*                  (MACOS(<=9),DARWIN(incl.MACOSX),*/
        !           463:                    /*                   LINUX, NETBSD, NOSYS variants) */
1.1       noro      464:
                    465:
                    466: /*
                    467:  * For each architecture and OS, the following need to be defined:
                    468:  *
                    469:  * CPP_WORD_SZ is a simple integer constant representing the word size.
                    470:  * in bits.  We assume byte addressibility, where a byte has 8 bits.
                    471:  * We also assume CPP_WORD_SZ is either 32 or 64.
                    472:  * (We care about the length of pointers, not hardware
                    473:  * bus widths.  Thus a 64 bit processor with a C compiler that uses
                    474:  * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
                    475:  *
                    476:  * MACH_TYPE is a string representation of the machine type.
                    477:  * OS_TYPE is analogous for the OS.
                    478:  *
                    479:  * ALIGNMENT is the largest N, such that
                    480:  * all pointer are guaranteed to be aligned on N byte boundaries.
                    481:  * defining it to be 1 will always work, but perform poorly.
                    482:  *
                    483:  * DATASTART is the beginning of the data segment.
1.6       noro      484:  * On some platforms SEARCH_FOR_DATA_START is defined.
                    485:  * SEARCH_FOR_DATASTART will cause GC_data_start to
                    486:  * be set to an address determined by accessing data backwards from _end
                    487:  * until an unmapped page is found.  DATASTART will be defined to be
                    488:  * GC_data_start.
                    489:  * On UNIX-like systems, the collector will scan the area between DATASTART
1.1       noro      490:  * and DATAEND for root pointers.
                    491:  *
1.6       noro      492:  * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
                    493:  * RTH suggests gaining access to linker script synth'd values with
                    494:  * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
1.1       noro      495:  *
                    496:  * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
                    497:  * the pointer size.
                    498:  *
                    499:  * STACKBOTTOM is the cool end of the stack, which is usually the
                    500:  * highest address in the stack.
                    501:  * Under PCR or OS/2, we have other ways of finding thread stacks.
                    502:  * For each machine, the following should:
                    503:  * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
                    504:  * 2) define exactly one of
                    505:  *     STACKBOTTOM (should be defined to be an expression)
1.6       noro      506:  *     LINUX_STACKBOTTOM
1.1       noro      507:  *     HEURISTIC1
                    508:  *     HEURISTIC2
1.6       noro      509:  * If STACKBOTTOM is defined, then it's value will be used directly as the
                    510:  * stack base.  If LINUX_STACKBOTTOM is defined, then it will be determined
                    511:  * with a method appropriate for most Linux systems.  Currently we look
                    512:  * first for __libc_stack_end, and if that fails read it from /proc.
1.1       noro      513:  * If either of the last two macros are defined, then STACKBOTTOM is computed
                    514:  * during collector startup using one of the following two heuristics:
                    515:  * HEURISTIC1:  Take an address inside GC_init's frame, and round it up to
                    516:  *             the next multiple of STACK_GRAN.
                    517:  * HEURISTIC2:  Take an address inside GC_init's frame, increment it repeatedly
                    518:  *             in small steps (decrement if STACK_GROWS_UP), and read the value
                    519:  *             at each location.  Remember the value when the first
                    520:  *             Segmentation violation or Bus error is signalled.  Round that
                    521:  *             to the nearest plausible page boundary, and use that instead
                    522:  *             of STACKBOTTOM.
                    523:  *
1.3       noro      524:  * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
                    525:  * the value of environ is a pointer that can serve as STACKBOTTOM.
                    526:  * I expect that HEURISTIC2 can be replaced by this approach, which
                    527:  * interferes far less with debugging.  However it has the disadvantage
                    528:  * that it's confused by a putenv call before the collector is initialized.
                    529:  * This could be dealt with by intercepting putenv ...
                    530:  *
1.1       noro      531:  * If no expression for STACKBOTTOM can be found, and neither of the above
                    532:  * heuristics are usable, the collector can still be used with all of the above
                    533:  * undefined, provided one of the following is done:
                    534:  * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
                    535:  *    without reference to STACKBOTTOM.  This is appropriate for use in
                    536:  *    conjunction with thread packages, since there will be multiple stacks.
                    537:  *    (Allocating thread stacks in the heap, and treating them as ordinary
                    538:  *    heap data objects is also possible as a last resort.  However, this is
                    539:  *    likely to introduce significant amounts of excess storage retention
                    540:  *    unless the dead parts of the thread stacks are periodically cleared.)
                    541:  * 2) Client code may set GC_stackbottom before calling any GC_ routines.
                    542:  *    If the author of the client code controls the main program, this is
                    543:  *    easily accomplished by introducing a new main program, setting
                    544:  *    GC_stackbottom to the address of a local variable, and then calling
                    545:  *    the original main program.  The new main program would read something
                    546:  *    like:
                    547:  *
                    548:  *             # include "gc_private.h"
                    549:  *
                    550:  *             main(argc, argv, envp)
                    551:  *             int argc;
                    552:  *             char **argv, **envp;
                    553:  *             {
                    554:  *                 int dummy;
                    555:  *
                    556:  *                 GC_stackbottom = (ptr_t)(&dummy);
                    557:  *                 return(real_main(argc, argv, envp));
                    558:  *             }
                    559:  *
                    560:  *
                    561:  * Each architecture may also define the style of virtual dirty bit
                    562:  * implementation to be used:
                    563:  *   MPROTECT_VDB: Write protect the heap and catch faults.
                    564:  *   PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
                    565:  *
                    566:  * An architecture may define DYNAMIC_LOADING if dynamic_load.c
                    567:  * defined GC_register_dynamic_libraries() for the architecture.
1.3       noro      568:  *
                    569:  * An architecture may define PREFETCH(x) to preload the cache with *x.
                    570:  * This defaults to a no-op.
                    571:  *
                    572:  * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
                    573:  *
                    574:  * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
                    575:  * clear the two words at GC_malloc-aligned address x.  By default,
                    576:  * word stores of 0 are used instead.
1.6       noro      577:  *
                    578:  * HEAP_START may be defined as the initial address hint for mmap-based
                    579:  * allocation.
1.1       noro      580:  */
                    581:
1.6       noro      582: /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
                    583:  * to push the relevant registers onto the stack.  This generally makes
                    584:  * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
                    585:  */
                    586: # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
                    587:                           (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
                    588: #   define HAVE_BUILTIN_UNWIND_INIT
                    589: # endif
1.1       noro      590:
                    591: # define STACK_GRAN 0x1000000
                    592: # ifdef M68K
                    593: #   define MACH_TYPE "M68K"
                    594: #   define ALIGNMENT 2
                    595: #   ifdef OPENBSD
                    596: #      define OS_TYPE "OPENBSD"
                    597: #      define HEURISTIC2
1.6       noro      598:        extern char etext[];
                    599: #      define DATASTART ((ptr_t)(etext))
1.1       noro      600: #   endif
                    601: #   ifdef NETBSD
                    602: #      define OS_TYPE "NETBSD"
                    603: #      define HEURISTIC2
1.6       noro      604:        extern char etext[];
                    605: #      define DATASTART ((ptr_t)(etext))
1.1       noro      606: #   endif
                    607: #   ifdef LINUX
                    608: #       define OS_TYPE "LINUX"
                    609: #       define STACKBOTTOM ((ptr_t)0xf0000000)
1.6       noro      610: /* #       define MPROTECT_VDB - Reported to not work  9/17/01 */
1.1       noro      611: #       ifdef __ELF__
                    612: #            define DYNAMIC_LOADING
1.3       noro      613: #           include <features.h>
                    614: #           if defined(__GLIBC__)&& __GLIBC__>=2
1.9     ! noro      615: #              define SEARCH_FOR_DATA_START
1.3       noro      616: #           else /* !GLIBC2 */
                    617:                extern char **__environ;
                    618: #              define DATASTART ((ptr_t)(&__environ))
1.1       noro      619:                              /* hideous kludge: __environ is the first */
                    620:                              /* word in crt0.o, and delimits the start */
                    621:                              /* of the data segment, no matter which   */
                    622:                              /* ld options were passed through.        */
                    623:                              /* We could use _etext instead, but that  */
                    624:                              /* would include .rodata, which may       */
                    625:                              /* contain large read-only data tables    */
                    626:                              /* that we'd rather not scan.             */
1.3       noro      627: #           endif /* !GLIBC2 */
1.6       noro      628:              extern int _end[];
                    629: #            define DATAEND (_end)
1.1       noro      630: #       else
1.6       noro      631:              extern int etext[];
                    632: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.1       noro      633: #       endif
                    634: #   endif
                    635: #   ifdef SUNOS4
                    636: #      define OS_TYPE "SUNOS4"
1.6       noro      637:        extern char etext[];
                    638: #      define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
1.1       noro      639: #      define HEURISTIC1       /* differs      */
                    640: #      define DYNAMIC_LOADING
                    641: #   endif
                    642: #   ifdef HP
                    643: #      define OS_TYPE "HP"
1.6       noro      644:        extern char etext[];
                    645: #       define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.1       noro      646: #       define STACKBOTTOM ((ptr_t) 0xffeffffc)
                    647:                              /* empirically determined.  seems to work. */
                    648: #      include <unistd.h>
                    649: #      define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
                    650: #   endif
                    651: #   ifdef SYSV
                    652: #      define OS_TYPE "SYSV"
1.6       noro      653:        extern etext[];
                    654: #      define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1.1       noro      655:                                   & ~0x3fffff) \
1.6       noro      656:                                  +((word)etext & 0x1fff))
1.1       noro      657:        /* This only works for shared-text binaries with magic number 0413.
                    658:           The other sorts of SysV binaries put the data at the end of the text,
1.6       noro      659:           in which case the default of etext would work.  Unfortunately,
1.1       noro      660:           handling both would require having the magic-number available.
                    661:                                -- Parag
                    662:           */
                    663: #      define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
                    664:                        /* The stack starts at the top of memory, but   */
                    665:                        /* 0x0 cannot be used as setjump_test complains */
                    666:                        /* that the stack direction is incorrect.  Two  */
                    667:                        /* bytes down from 0x0 should be safe enough.   */
                    668:                        /*              --Parag                         */
                    669: #      include <sys/mmu.h>
                    670: #      define GETPAGESIZE() PAGESIZE   /* Is this still right? */
                    671: #   endif
                    672: #   ifdef AMIGA
                    673: #      define OS_TYPE "AMIGA"
                    674:                /* STACKBOTTOM and DATASTART handled specially  */
                    675:                /* in os_dep.c                                  */
                    676: #      define DATAEND  /* not needed */
                    677: #      define GETPAGESIZE() 4096
                    678: #   endif
                    679: #   ifdef MACOS
                    680: #     ifndef __LOWMEM__
                    681: #     include <LowMem.h>
                    682: #     endif
                    683: #     define OS_TYPE "MACOS"
                    684:                        /* see os_dep.c for details of global data segments. */
                    685: #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
                    686: #     define DATAEND   /* not needed */
                    687: #     define GETPAGESIZE() 4096
                    688: #   endif
                    689: #   ifdef NEXT
                    690: #      define OS_TYPE "NEXT"
                    691: #      define DATASTART ((ptr_t) get_etext())
                    692: #      define STACKBOTTOM ((ptr_t) 0x4000000)
                    693: #      define DATAEND  /* not needed */
                    694: #   endif
                    695: # endif
                    696:
                    697: # ifdef POWERPC
                    698: #   define MACH_TYPE "POWERPC"
                    699: #   ifdef MACOS
                    700: #     define ALIGNMENT 2  /* Still necessary?  Could it be 4?  */
                    701: #     ifndef __LOWMEM__
                    702: #     include <LowMem.h>
                    703: #     endif
                    704: #     define OS_TYPE "MACOS"
                    705:                        /* see os_dep.c for details of global data segments. */
                    706: #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
                    707: #     define DATAEND  /* not needed */
                    708: #   endif
                    709: #   ifdef LINUX
1.9     ! noro      710: #     if (defined (powerpc64) || defined(__powerpc64__))
        !           711: #       define ALIGNMENT 8
        !           712: #       define CPP_WORDSZ 64
        !           713: #     else
        !           714: #       define ALIGNMENT 4     /* Guess.  Can someone verify?  */
1.1       noro      715:                                /* This was 2, but that didn't sound right. */
1.9     ! noro      716: #     endif
1.1       noro      717: #     define OS_TYPE "LINUX"
1.9     ! noro      718:       /* HEURISTIC1 has been reliably reported to fail for a 32-bit    */
        !           719:       /* executable on a 64 bit kernel.                                        */
        !           720: #     define LINUX_STACKBOTTOM
1.3       noro      721: #     define DYNAMIC_LOADING
1.9     ! noro      722: #     define SEARCH_FOR_DATA_START
1.6       noro      723:       extern int _end[];
                    724: #     define DATAEND (_end)
1.1       noro      725: #   endif
1.9     ! noro      726: #   ifdef DARWIN
1.1       noro      727: #     define ALIGNMENT 4
1.9     ! noro      728: #     define OS_TYPE "DARWIN"
        !           729: #     define DYNAMIC_LOADING
        !           730:       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
        !           731:          These aren't used when dyld support is enabled (it is by default) */
1.1       noro      732: #     define DATASTART ((ptr_t) get_etext())
1.9     ! noro      733: #     define DATAEND   ((ptr_t) get_end())
1.1       noro      734: #     define STACKBOTTOM ((ptr_t) 0xc0000000)
1.9     ! noro      735: #     define USE_MMAP
        !           736: #     define USE_MMAP_ANON
        !           737: #     define USE_ASM_PUSH_REGS
        !           738:       /* This is potentially buggy. It needs more testing. See the comments in
        !           739:          os_dep.c */
1.3       noro      740: #     define MPROTECT_VDB
                    741: #     include <unistd.h>
                    742: #     define GETPAGESIZE() getpagesize()
1.9     ! noro      743: #     if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
        !           744:        /* The performance impact of prefetches is untested */
        !           745: #      define PREFETCH(x) \
        !           746:          __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
        !           747: #      define PREFETCH_FOR_WRITE(x) \
        !           748:          __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
        !           749: #     endif
        !           750:       /* There seems to be some issues with trylock hanging on darwin. This
        !           751:          should be looked into some more */
        !           752: #     define NO_PTHREAD_TRYLOCK
1.3       noro      753: #   endif
                    754: #   ifdef NETBSD
                    755: #     define ALIGNMENT 4
                    756: #     define OS_TYPE "NETBSD"
                    757: #     define HEURISTIC2
1.6       noro      758:       extern char etext[];
1.3       noro      759: #     define DATASTART GC_data_start
                    760: #     define DYNAMIC_LOADING
                    761: #   endif
                    762: #   ifdef NOSYS
                    763: #     define ALIGNMENT 4
                    764: #     define OS_TYPE "NOSYS"
1.6       noro      765:       extern void __end[], __dso_handle[];
                    766: #     define DATASTART (__dso_handle)  /* OK, that's ugly.  */
                    767: #     define DATAEND (__end)
1.3       noro      768:        /* Stack starts at 0xE0000000 for the simulator.  */
                    769: #     undef STACK_GRAN
                    770: #     define STACK_GRAN 0x10000000
                    771: #     define HEURISTIC1
1.1       noro      772: #   endif
                    773: # endif
                    774:
                    775: # ifdef VAX
                    776: #   define MACH_TYPE "VAX"
                    777: #   define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
1.6       noro      778:     extern char etext[];
                    779: #   define DATASTART ((ptr_t)(etext))
1.1       noro      780: #   ifdef BSD
                    781: #      define OS_TYPE "BSD"
                    782: #      define HEURISTIC1
                    783:                        /* HEURISTIC2 may be OK, but it's hard to test. */
                    784: #   endif
                    785: #   ifdef ULTRIX
                    786: #      define OS_TYPE "ULTRIX"
                    787: #      define STACKBOTTOM ((ptr_t) 0x7fffc800)
                    788: #   endif
                    789: # endif
                    790:
                    791: # ifdef RT
                    792: #   define MACH_TYPE "RT"
                    793: #   define ALIGNMENT 4
                    794: #   define DATASTART ((ptr_t) 0x10000000)
                    795: #   define STACKBOTTOM ((ptr_t) 0x1fffd800)
                    796: # endif
                    797:
                    798: # ifdef SPARC
                    799: #   define MACH_TYPE "SPARC"
1.3       noro      800: #   if defined(__arch64__) || defined(__sparcv9)
                    801: #     define ALIGNMENT 8
1.6       noro      802: #     define CPP_WORDSZ 64
                    803: #     define ELF_CLASS ELFCLASS64
1.3       noro      804: #   else
                    805: #     define ALIGNMENT 4       /* Required by hardware */
1.6       noro      806: #     define CPP_WORDSZ 32
1.3       noro      807: #   endif
1.1       noro      808: #   define ALIGN_DOUBLE
                    809: #   ifdef SUNOS5
                    810: #      define OS_TYPE "SUNOS5"
1.6       noro      811:        extern int _etext[];
                    812:        extern int _end[];
1.9     ! noro      813:        extern ptr_t GC_SysVGetDataStart();
        !           814: #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1.6       noro      815: #      define DATAEND (_end)
                    816: #      if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1.1       noro      817: #          define USE_MMAP
1.6       noro      818:            /* Otherwise we now use calloc.  Mmap may result in the     */
                    819:            /* heap interleaved with thread stacks, which can result in */
                    820:            /* excessive blacklisting.  Sbrk is unusable since it       */
                    821:            /* doesn't interact correctly with the system malloc.       */
1.1       noro      822: #      endif
                    823: #       ifdef USE_MMAP
                    824: #         define HEAP_START (ptr_t)0x40000000
                    825: #       else
                    826: #        define HEAP_START DATAEND
                    827: #       endif
                    828: #      define PROC_VDB
1.3       noro      829: /*     HEURISTIC1 reportedly no longer works under 2.7.                */
                    830: /*     HEURISTIC2 probably works, but this appears to be preferable.   */
                    831: /*     Apparently USRSTACK is defined to be USERLIMIT, but in some     */
                    832: /*     installations that's undefined.  We work around this with a     */
                    833: /*     gross hack:                                                     */
                    834: #       include <sys/vmparam.h>
                    835: #      ifdef USERLIMIT
                    836:          /* This should work everywhere, but doesn't.  */
                    837: #        define STACKBOTTOM USRSTACK
                    838: #       else
                    839: #        define HEURISTIC2
                    840: #       endif
1.1       noro      841: #      include <unistd.h>
                    842: #       define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
                    843:                /* getpagesize() appeared to be missing from at least one */
                    844:                /* Solaris 5.4 installation.  Weird.                      */
                    845: #      define DYNAMIC_LOADING
                    846: #   endif
                    847: #   ifdef SUNOS4
                    848: #      define OS_TYPE "SUNOS4"
                    849:        /* [If you have a weak stomach, don't read this.]               */
                    850:        /* We would like to use:                                        */
1.6       noro      851: /* #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
1.1       noro      852:        /* This fails occasionally, due to an ancient, but very         */
1.6       noro      853:        /* persistent ld bug.  etext is set 32 bytes too high.          */
1.1       noro      854:        /* We instead read the text segment size from the a.out         */
                    855:        /* header, which happens to be mapped into our address space    */
                    856:        /* at the start of the text segment.  The detective work here   */
                    857:        /* was done by Robert Ehrlich, Manuel Serrano, and Bernard      */
                    858:        /* Serpette of INRIA.                                           */
                    859:        /* This assumes ZMAGIC, i.e. demand-loadable executables.       */
                    860: #      define TEXTSTART 0x2000
                    861: #       define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
                    862: #      define MPROTECT_VDB
                    863: #      define HEURISTIC1
                    864: #      define DYNAMIC_LOADING
                    865: #   endif
                    866: #   ifdef DRSNX
                    867: #      define OS_TYPE "DRSNX"
1.9     ! noro      868:        extern ptr_t GC_SysVGetDataStart();
1.6       noro      869:        extern int etext[];
1.9     ! noro      870: #       define DATASTART GC_SysVGetDataStart(0x10000, etext)
1.1       noro      871: #      define MPROTECT_VDB
                    872: #       define STACKBOTTOM ((ptr_t) 0xdfff0000)
                    873: #      define DYNAMIC_LOADING
                    874: #   endif
                    875: #   ifdef LINUX
                    876: #     define OS_TYPE "LINUX"
                    877: #     ifdef __ELF__
1.3       noro      878: #       define DYNAMIC_LOADING
1.1       noro      879: #     else
1.3       noro      880:           Linux Sparc/a.out not supported
1.1       noro      881: #     endif
1.6       noro      882:       extern int _end[];
                    883:       extern int _etext[];
                    884: #     define DATAEND (_end)
1.1       noro      885: #     define SVR4
1.9     ! noro      886:       extern ptr_t GC_SysVGetDataStart();
1.3       noro      887: #     ifdef __arch64__
1.9     ! noro      888: #      define DATASTART GC_SysVGetDataStart(0x100000, _etext)
1.6       noro      889:        /* libc_stack_end is not set reliably for sparc64 */
1.3       noro      890: #       define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
                    891: #     else
1.9     ! noro      892: #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1.6       noro      893: #      define LINUX_STACKBOTTOM
1.3       noro      894: #     endif
1.1       noro      895: #   endif
                    896: #   ifdef OPENBSD
                    897: #     define OS_TYPE "OPENBSD"
                    898: #     define STACKBOTTOM ((ptr_t) 0xf8000000)
1.6       noro      899:       extern int etext[];
                    900: #     define DATASTART ((ptr_t)(etext))
1.1       noro      901: #   endif
1.3       noro      902: #   ifdef NETBSD
                    903: #     define OS_TYPE "NETBSD"
                    904: #     define HEURISTIC2
                    905: #     ifdef __ELF__
                    906: #      define DATASTART GC_data_start
                    907: #      define DYNAMIC_LOADING
                    908: #     else
1.6       noro      909:        extern char etext[];
                    910: #      define DATASTART ((ptr_t)(etext))
1.3       noro      911: #     endif
                    912: #   endif
1.1       noro      913: # endif
                    914:
                    915: # ifdef I386
                    916: #   define MACH_TYPE "I386"
                    917: #   define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers   */
                    918:                        /* except Borland.  The -a4 option fixes        */
                    919:                        /* Borland.                                     */
                    920:                         /* Ivan Demakov: For Watcom the option is -zp4. */
                    921: #   ifndef SMALL_CONFIG
                    922: #     define ALIGN_DOUBLE /* Not strictly necessary, but may give speed   */
                    923:                          /* improvement on Pentiums.                     */
                    924: #   endif
1.6       noro      925: #   ifdef HAVE_BUILTIN_UNWIND_INIT
                    926: #      define USE_GENERIC_PUSH_REGS
                    927: #   endif
1.1       noro      928: #   ifdef SEQUENT
                    929: #      define OS_TYPE "SEQUENT"
1.6       noro      930:        extern int etext[];
                    931: #       define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.1       noro      932: #       define STACKBOTTOM ((ptr_t) 0x3ffff000)
                    933: #   endif
1.3       noro      934: #   ifdef BEOS
                    935: #     define OS_TYPE "BEOS"
                    936: #     include <OS.h>
                    937: #     define GETPAGESIZE() B_PAGE_SIZE
1.6       noro      938:       extern int etext[];
                    939: #     define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.3       noro      940: #   endif
1.1       noro      941: #   ifdef SUNOS5
                    942: #      define OS_TYPE "SUNOS5"
1.6       noro      943:         extern int _etext[], _end[];
1.9     ! noro      944:        extern ptr_t GC_SysVGetDataStart();
1.6       noro      945: #       define DATASTART GC_SysVGetDataStart(0x1000, _etext)
                    946: #      define DATAEND (_end)
                    947: /*     # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,      */
1.3       noro      948: /*      but reportedly breaks under 2.8.  It appears that the stack    */
                    949: /*     base is a property of the executable, so this should not break  */
                    950: /*     old executables.                                                */
                    951: /*     HEURISTIC2 probably works, but this appears to be preferable.   */
1.6       noro      952: #       include <sys/vm.h>
1.3       noro      953: #      define STACKBOTTOM USRSTACK
1.6       noro      954: /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
                    955: /* It appears to be fixed in 2.8 and 2.9.                              */
                    956: #      ifdef SOLARIS25_PROC_VDB_BUG_FIXED
                    957: #        define PROC_VDB
                    958: #      endif
1.1       noro      959: #      define DYNAMIC_LOADING
1.6       noro      960: #      if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1.1       noro      961: #          define USE_MMAP
1.6       noro      962:            /* Otherwise we now use calloc.  Mmap may result in the     */
                    963:            /* heap interleaved with thread stacks, which can result in */
                    964:            /* excessive blacklisting.  Sbrk is unusable since it       */
                    965:            /* doesn't interact correctly with the system malloc.       */
1.1       noro      966: #      endif
                    967: #       ifdef USE_MMAP
                    968: #         define HEAP_START (ptr_t)0x40000000
                    969: #       else
                    970: #        define HEAP_START DATAEND
                    971: #       endif
                    972: #   endif
                    973: #   ifdef SCO
                    974: #      define OS_TYPE "SCO"
1.6       noro      975:        extern int etext[];
                    976: #      define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1.1       noro      977:                                  & ~0x3fffff) \
1.6       noro      978:                                 +((word)etext & 0xfff))
1.1       noro      979: #      define STACKBOTTOM ((ptr_t) 0x7ffffffc)
                    980: #   endif
                    981: #   ifdef SCO_ELF
                    982: #       define OS_TYPE "SCO_ELF"
1.6       noro      983:         extern int etext[];
                    984: #       define DATASTART ((ptr_t)(etext))
1.1       noro      985: #       define STACKBOTTOM ((ptr_t) 0x08048000)
                    986: #       define DYNAMIC_LOADING
                    987: #      define ELF_CLASS ELFCLASS32
                    988: #   endif
1.6       noro      989: #   ifdef DGUX
                    990: #      define OS_TYPE "DGUX"
                    991:        extern int _etext, _end;
1.9     ! noro      992:        extern ptr_t GC_SysVGetDataStart();
1.6       noro      993: #      define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
                    994: #      define DATAEND (&_end)
                    995: #      define STACK_GROWS_DOWN
                    996: #      define HEURISTIC2
                    997: #      include <unistd.h>
                    998: #      define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
                    999: #      define DYNAMIC_LOADING
                   1000: #      ifndef USE_MMAP
                   1001: #        define USE_MMAP
                   1002: #      endif /* USE_MMAP */
                   1003: #      define MAP_FAILED (void *) -1
                   1004: #      ifdef USE_MMAP
                   1005: #        define HEAP_START (ptr_t)0x40000000
                   1006: #      else /* USE_MMAP */
                   1007: #        define HEAP_START DATAEND
                   1008: #      endif /* USE_MMAP */
                   1009: #   endif /* DGUX */
                   1010:
1.1       noro     1011: #   ifdef LINUX
1.6       noro     1012: #      ifndef __GNUC__
                   1013:          /* The Intel compiler doesn't like inline assembly */
                   1014: #        define USE_GENERIC_PUSH_REGS
                   1015: #      endif
1.1       noro     1016: #      define OS_TYPE "LINUX"
1.3       noro     1017: #       define LINUX_STACKBOTTOM
1.8       noro     1018: /* #       define USE_MMAP */
1.3       noro     1019: #      if 0
                   1020: #        define HEURISTIC1
                   1021: #         undef STACK_GRAN
                   1022: #         define STACK_GRAN 0x10000000
                   1023:          /* STACKBOTTOM is usually 0xc0000000, but this changes with   */
                   1024:          /* different kernel configurations.  In particular, systems   */
                   1025:          /* with 2GB physical memory will usually move the user        */
                   1026:          /* address space limit, and hence initial SP to 0x80000000.   */
                   1027: #       endif
1.6       noro     1028: #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1.1       noro     1029: #          define MPROTECT_VDB
                   1030: #      else
                   1031:            /* We seem to get random errors in incremental mode,        */
                   1032:            /* possibly because Linux threads is itself a malloc client */
                   1033:            /* and can't deal with the signals.                         */
                   1034: #      endif
1.6       noro     1035: #      define HEAP_START 0x1000
                   1036:                /* This encourages mmap to give us low addresses,       */
                   1037:                /* thus allowing the heap to grow to ~3GB               */
1.1       noro     1038: #       ifdef __ELF__
                   1039: #            define DYNAMIC_LOADING
                   1040: #           ifdef UNDEFINED    /* includes ro data */
1.6       noro     1041:               extern int _etext[];
                   1042: #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1.1       noro     1043: #           endif
                   1044: #           include <features.h>
                   1045: #           if defined(__GLIBC__) && __GLIBC__ >= 2
1.9     ! noro     1046: #               define SEARCH_FOR_DATA_START
1.1       noro     1047: #           else
                   1048:                 extern char **__environ;
                   1049: #                define DATASTART ((ptr_t)(&__environ))
                   1050:                              /* hideous kludge: __environ is the first */
                   1051:                              /* word in crt0.o, and delimits the start */
                   1052:                              /* of the data segment, no matter which   */
                   1053:                              /* ld options were passed through.        */
                   1054:                              /* We could use _etext instead, but that  */
                   1055:                              /* would include .rodata, which may       */
                   1056:                              /* contain large read-only data tables    */
                   1057:                              /* that we'd rather not scan.             */
                   1058: #           endif
1.6       noro     1059:             extern int _end[];
                   1060: #           define DATAEND (_end)
1.1       noro     1061: #      else
1.6       noro     1062:             extern int etext[];
                   1063: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.1       noro     1064: #       endif
1.3       noro     1065: #      ifdef USE_I686_PREFETCH
                   1066: #        define PREFETCH(x) \
                   1067:            __asm__ __volatile__ ("     prefetchnta     %0": : "m"(*(char *)(x)))
                   1068:            /* Empirically prefetcht0 is much more effective at reducing        */
                   1069:            /* cache miss stalls for the targetted load instructions.  But it   */
                   1070:            /* seems to interfere enough with other cache traffic that the net  */
                   1071:            /* result is worse than prefetchnta.                                */
                   1072: #         if 0
                   1073:            /* Using prefetches for write seems to have a slight negative       */
                   1074:            /* impact on performance, at least for a PIII/500.                  */
                   1075: #          define PREFETCH_FOR_WRITE(x) \
                   1076:              __asm__ __volatile__ ("   prefetcht0      %0": : "m"(*(char *)(x)))
                   1077: #        endif
                   1078: #      endif
                   1079: #      ifdef USE_3DNOW_PREFETCH
                   1080: #        define PREFETCH(x) \
                   1081:            __asm__ __volatile__ ("     prefetch        %0": : "m"(*(char *)(x)))
                   1082: #        define PREFETCH_FOR_WRITE(x) \
                   1083:            __asm__ __volatile__ ("     prefetchw       %0": : "m"(*(char *)(x)))
                   1084: #      endif
1.1       noro     1085: #   endif
                   1086: #   ifdef CYGWIN32
                   1087: #       define OS_TYPE "CYGWIN32"
1.6       noro     1088:           extern int _data_start__[];
                   1089:           extern int _data_end__[];
                   1090:           extern int _bss_start__[];
                   1091:           extern int _bss_end__[];
1.1       noro     1092:        /* For binutils 2.9.1, we have                  */
                   1093:        /*      DATASTART   = _data_start__             */
                   1094:        /*      DATAEND     = _bss_end__                */
                   1095:        /* whereas for some earlier versions it was     */
                   1096:        /*      DATASTART   = _bss_start__              */
                   1097:        /*      DATAEND     = _data_end__               */
                   1098:        /* To get it right for both, we take the        */
                   1099:        /* minumum/maximum of the two.                  */
1.9     ! noro     1100: #     ifndef MAX
1.1       noro     1101: #      define MAX(x,y) ((x) > (y) ? (x) : (y))
1.9     ! noro     1102: #     endif
        !          1103: #     ifndef MIN
1.1       noro     1104: #      define MIN(x,y) ((x) < (y) ? (x) : (y))
1.9     ! noro     1105: #     endif
1.6       noro     1106: #       define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
                   1107: #       define DATAEND  ((ptr_t) MAX(_data_end__, _bss_end__))
1.1       noro     1108: #      undef STACK_GRAN
                   1109: #       define STACK_GRAN 0x10000
                   1110: #       define HEURISTIC1
                   1111: #   endif
                   1112: #   ifdef OS2
                   1113: #      define OS_TYPE "OS2"
                   1114:                /* STACKBOTTOM and DATASTART are handled specially in   */
                   1115:                /* os_dep.c. OS2 actually has the right                 */
                   1116:                /* system call!                                         */
                   1117: #      define DATAEND  /* not needed */
1.3       noro     1118: #      define USE_GENERIC_PUSH_REGS
1.1       noro     1119: #   endif
                   1120: #   ifdef MSWIN32
                   1121: #      define OS_TYPE "MSWIN32"
                   1122:                /* STACKBOTTOM and DATASTART are handled specially in   */
                   1123:                /* os_dep.c.                                            */
                   1124: #       ifndef __WATCOMC__
                   1125: #        define MPROTECT_VDB
                   1126: #      endif
                   1127: #       define DATAEND  /* not needed */
                   1128: #   endif
1.3       noro     1129: #   ifdef MSWINCE
                   1130: #      define OS_TYPE "MSWINCE"
                   1131: #       define DATAEND  /* not needed */
                   1132: #   endif
1.1       noro     1133: #   ifdef DJGPP
                   1134: #       define OS_TYPE "DJGPP"
                   1135: #       include "stubinfo.h"
1.6       noro     1136:         extern int etext[];
1.1       noro     1137:         extern int _stklen;
                   1138:         extern int __djgpp_stack_limit;
1.6       noro     1139: #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1.1       noro     1140: /* #       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
                   1141:                                                      + _stklen)) */
                   1142: #       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
                   1143:                /* This may not be right.  */
                   1144: #   endif
                   1145: #   ifdef OPENBSD
                   1146: #      define OS_TYPE "OPENBSD"
                   1147: #   endif
                   1148: #   ifdef FREEBSD
                   1149: #      define OS_TYPE "FREEBSD"
1.6       noro     1150: #      ifndef GC_FREEBSD_THREADS
                   1151: #          define MPROTECT_VDB
                   1152: #      endif
                   1153: #      define SIG_SUSPEND SIGUSR1
                   1154: #      define SIG_THR_RESTART SIGUSR2
1.3       noro     1155: #      define FREEBSD_STACKBOTTOM
1.6       noro     1156: #      ifdef __ELF__
                   1157: #          define DYNAMIC_LOADING
                   1158: #      endif
                   1159:        extern char etext[];
1.9     ! noro     1160:        extern char * GC_FreeBSDGetDataStart();
        !          1161: #      define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1.1       noro     1162: #   endif
                   1163: #   ifdef NETBSD
                   1164: #      define OS_TYPE "NETBSD"
1.6       noro     1165: #      ifdef __ELF__
                   1166: #          define DYNAMIC_LOADING
                   1167: #      endif
1.1       noro     1168: #   endif
                   1169: #   ifdef THREE86BSD
                   1170: #      define OS_TYPE "THREE86BSD"
                   1171: #   endif
                   1172: #   ifdef BSDI
                   1173: #      define OS_TYPE "BSDI"
                   1174: #   endif
1.6       noro     1175: #   if defined(OPENBSD) || defined(NETBSD) \
1.1       noro     1176:         || defined(THREE86BSD) || defined(BSDI)
                   1177: #      define HEURISTIC2
1.6       noro     1178:        extern char etext[];
                   1179: #      define DATASTART ((ptr_t)(etext))
1.1       noro     1180: #   endif
                   1181: #   ifdef NEXT
                   1182: #      define OS_TYPE "NEXT"
                   1183: #      define DATASTART ((ptr_t) get_etext())
                   1184: #      define STACKBOTTOM ((ptr_t)0xc0000000)
                   1185: #      define DATAEND  /* not needed */
                   1186: #   endif
                   1187: #   ifdef DOS4GW
                   1188: #     define OS_TYPE "DOS4GW"
                   1189:       extern long __nullarea;
                   1190:       extern char _end;
                   1191:       extern char *_STACKTOP;
                   1192:       /* Depending on calling conventions Watcom C either precedes
                   1193:          or does not precedes with undescore names of C-variables.
                   1194:          Make sure startup code variables always have the same names.  */
                   1195:       #pragma aux __nullarea "*";
                   1196:       #pragma aux _end "*";
                   1197: #     define STACKBOTTOM ((ptr_t) _STACKTOP)
                   1198:                          /* confused? me too. */
                   1199: #     define DATASTART ((ptr_t) &__nullarea)
                   1200: #     define DATAEND ((ptr_t) &_end)
                   1201: #   endif
1.6       noro     1202: #   ifdef HURD
                   1203: #     define OS_TYPE "HURD"
                   1204: #     define STACK_GROWS_DOWN
                   1205: #     define HEURISTIC2
                   1206:       extern int  __data_start[];
                   1207: #     define DATASTART ( (ptr_t) (__data_start))
                   1208:       extern int   _end[];
                   1209: #     define DATAEND ( (ptr_t) (_end))
                   1210: /* #     define MPROTECT_VDB  Not quite working yet? */
                   1211: #     define DYNAMIC_LOADING
                   1212: #   endif
1.1       noro     1213: # endif
                   1214:
                   1215: # ifdef NS32K
                   1216: #   define MACH_TYPE "NS32K"
                   1217: #   define ALIGNMENT 4
                   1218:     extern char **environ;
                   1219: #   define DATASTART ((ptr_t)(&environ))
                   1220:                              /* hideous kludge: environ is the first   */
                   1221:                              /* word in crt0.o, and delimits the start */
                   1222:                              /* of the data segment, no matter which   */
                   1223:                              /* ld options were passed through.        */
                   1224: #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
                   1225: # endif
                   1226:
                   1227: # ifdef MIPS
                   1228: #   define MACH_TYPE "MIPS"
1.3       noro     1229: #   ifdef LINUX
                   1230:       /* This was developed for a linuxce style platform.  Probably    */
                   1231:       /* needs to be tweaked for workstation class machines.           */
                   1232: #     define OS_TYPE "LINUX"
1.6       noro     1233: #     define DYNAMIC_LOADING
                   1234:       extern int _end[];
                   1235: #     define DATAEND (_end)
                   1236:       extern int __data_start[];
                   1237: #     define DATASTART ((ptr_t)(__data_start))
1.3       noro     1238: #     define ALIGNMENT 4
1.6       noro     1239: #     define USE_GENERIC_PUSH_REGS
1.9     ! noro     1240: #     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
        !          1241: #        define LINUX_STACKBOTTOM
        !          1242: #     else
        !          1243: #        define STACKBOTTOM 0x80000000
        !          1244: #     endif
1.3       noro     1245: #   endif /* Linux */
1.6       noro     1246: #   ifdef EWS4800
                   1247: #      define HEURISTIC2
                   1248: #      if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
                   1249:          extern int _fdata[], _end[];
                   1250: #        define DATASTART ((ptr_t)_fdata)
                   1251: #        define DATAEND ((ptr_t)_end)
                   1252: #        define CPP_WORDSZ _MIPS_SZPTR
                   1253: #        define ALIGNMENT (_MIPS_SZPTR/8)
                   1254: #      else
                   1255:          extern int etext[], edata[], end[];
                   1256:          extern int _DYNAMIC_LINKING[], _gp[];
                   1257: #        define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
                   1258:                + ((word)etext & 0xffff)))
                   1259: #        define DATAEND (edata)
                   1260: #        define DATASTART2 (_DYNAMIC_LINKING \
                   1261:                ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
                   1262:                : (ptr_t)edata)
                   1263: #        define DATAEND2 (end)
                   1264: #        define ALIGNMENT 4
                   1265: #      endif
                   1266: #      define OS_TYPE "EWS4800"
                   1267: #      define USE_GENERIC_PUSH_REGS 1
                   1268: #   endif
1.3       noro     1269: #   ifdef ULTRIX
                   1270: #      define HEURISTIC2
                   1271: #       define DATASTART (ptr_t)0x10000000
1.1       noro     1272:                              /* Could probably be slightly higher since */
                   1273:                              /* startup code allocates lots of stuff.   */
                   1274: #      define OS_TYPE "ULTRIX"
                   1275: #       define ALIGNMENT 4
                   1276: #   endif
                   1277: #   ifdef RISCOS
1.3       noro     1278: #      define HEURISTIC2
                   1279: #       define DATASTART (ptr_t)0x10000000
1.1       noro     1280: #      define OS_TYPE "RISCOS"
                   1281: #      define ALIGNMENT 4  /* Required by hardware */
                   1282: #   endif
                   1283: #   ifdef IRIX5
1.3       noro     1284: #      define HEURISTIC2
1.6       noro     1285:         extern int _fdata[];
                   1286: #       define DATASTART ((ptr_t)(_fdata))
1.3       noro     1287: #       ifdef USE_MMAP
                   1288: #         define HEAP_START (ptr_t)0x30000000
                   1289: #       else
                   1290: #        define HEAP_START DATASTART
                   1291: #       endif
                   1292:                              /* Lowest plausible heap address.         */
                   1293:                              /* In the MMAP case, we map there.        */
                   1294:                              /* In either case it is used to identify  */
                   1295:                              /* heap sections so they're not           */
                   1296:                              /* considered as roots.                   */
1.1       noro     1297: #      define OS_TYPE "IRIX5"
1.9     ! noro     1298: /*#       define MPROTECT_VDB DOB: this should work, but there is evidence */
        !          1299: /*             of recent breakage.                                        */
1.1       noro     1300: #       ifdef _MIPS_SZPTR
                   1301: #        define CPP_WORDSZ _MIPS_SZPTR
                   1302: #        define ALIGNMENT (_MIPS_SZPTR/8)
                   1303: #        if CPP_WORDSZ != 64
                   1304: #          define ALIGN_DOUBLE
                   1305: #        endif
                   1306: #      else
                   1307: #         define ALIGNMENT 4
                   1308: #        define ALIGN_DOUBLE
                   1309: #      endif
                   1310: #      define DYNAMIC_LOADING
                   1311: #   endif
1.3       noro     1312: #   ifdef MSWINCE
                   1313: #       define OS_TYPE "MSWINCE"
                   1314: #       define ALIGNMENT 4
                   1315: #       define DATAEND /* not needed */
                   1316: #   endif
                   1317: #   if defined(NETBSD)
                   1318:       /* This also checked for __MIPSEL__ .  Why?  NETBSD recognition  */
                   1319:       /* should be handled at the top of the file.                     */
                   1320: #     define ALIGNMENT 4
                   1321: #     define OS_TYPE "NETBSD"
                   1322: #     define HEURISTIC2
1.6       noro     1323: #     define USE_GENERIC_PUSH_REGS
1.3       noro     1324: #     ifdef __ELF__
1.6       noro     1325:         extern int etext[];
1.3       noro     1326: #       define DATASTART GC_data_start
                   1327: #       define NEED_FIND_LIMIT
                   1328: #       define DYNAMIC_LOADING
                   1329: #     else
                   1330: #       define DATASTART ((ptr_t) 0x10000000)
                   1331: #       define STACKBOTTOM ((ptr_t) 0x7ffff000)
                   1332: #     endif /* _ELF_ */
                   1333: #  endif
1.1       noro     1334: # endif
                   1335:
                   1336: # ifdef RS6000
                   1337: #   define MACH_TYPE "RS6000"
1.9     ! noro     1338: #   ifdef ALIGNMENT
        !          1339: #     undef ALIGNMENT
        !          1340: #   endif
        !          1341: #   ifdef IA64
        !          1342: #     undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
        !          1343: #   endif
1.6       noro     1344: #   ifdef __64BIT__
                   1345: #     define ALIGNMENT 8
                   1346: #     define CPP_WORDSZ 64
1.9     ! noro     1347: #     define STACKBOTTOM ((ptr_t)0x1000000000000000)
1.6       noro     1348: #   else
                   1349: #     define ALIGNMENT 4
                   1350: #     define CPP_WORDSZ 32
                   1351: #     define STACKBOTTOM ((ptr_t)((ulong)&errno))
                   1352: #   endif
1.9     ! noro     1353:  /* From AIX linker man page:
        !          1354:  _text Specifies the first location of the program.
        !          1355:  _etext Specifies the first location after the program.
        !          1356:  _data Specifies the first location of the data.
        !          1357:  _edata Specifies the first location after the initialized data
        !          1358:  _end or end Specifies the first location after all data.
        !          1359:  */
1.6       noro     1360:     extern int _data[], _end[];
                   1361: #   define DATASTART ((ptr_t)((ulong)_data))
                   1362: #   define DATAEND ((ptr_t)((ulong)_end))
1.1       noro     1363:     extern int errno;
1.6       noro     1364: #   define USE_GENERIC_PUSH_REGS
1.1       noro     1365: #   define DYNAMIC_LOADING
                   1366:        /* For really old versions of AIX, this may have to be removed. */
                   1367: # endif
                   1368:
                   1369: # ifdef HP_PA
                   1370: #   define MACH_TYPE "HP_PA"
1.3       noro     1371: #   ifdef __LP64__
                   1372: #     define CPP_WORDSZ 64
                   1373: #     define ALIGNMENT 8
                   1374: #   else
                   1375: #     define CPP_WORDSZ 32
                   1376: #     define ALIGNMENT 4
                   1377: #     define ALIGN_DOUBLE
                   1378: #   endif
1.6       noro     1379: #   if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1.3       noro     1380: #     ifndef LINUX /* For now. */
                   1381: #       define MPROTECT_VDB
                   1382: #     endif
                   1383: #   else
                   1384: #     define GENERIC_COMPARE_AND_SWAP
                   1385:        /* No compare-and-swap instruction.  Use pthread mutexes        */
                   1386:        /* when we absolutely have to.                                  */
                   1387: #     ifdef PARALLEL_MARK
                   1388: #      define USE_MARK_BYTES
                   1389:                /* Minimize compare-and-swap usage.             */
                   1390: #     endif
                   1391: #   endif
                   1392: #   define STACK_GROWS_UP
                   1393: #   ifdef HPUX
1.6       noro     1394: #     define OS_TYPE "HPUX"
                   1395:       extern int __data_start[];
                   1396: #     define DATASTART ((ptr_t)(__data_start))
1.3       noro     1397: #     if 0
1.1       noro     1398:        /* The following appears to work for 7xx systems running HP/UX  */
                   1399:        /* 9.xx Furthermore, it might result in much faster             */
                   1400:        /* collections than HEURISTIC2, which may involve scanning      */
                   1401:        /* segments that directly precede the stack.  It is not the     */
                   1402:        /* default, since it may not work on older machine/OS           */
                   1403:        /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
                   1404:        /* this.)                                                       */
                   1405: #       define STACKBOTTOM ((ptr_t) 0x7b033000)  /* from /etc/conf/h/param.h */
1.3       noro     1406: #     else
                   1407:        /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
                   1408:        /* to this.  Note that the GC must be initialized before the    */
                   1409:        /* first putenv call.                                           */
                   1410:        extern char ** environ;
                   1411: #       define STACKBOTTOM ((ptr_t)environ)
                   1412: #     endif
                   1413: #     define DYNAMIC_LOADING
                   1414: #     include <unistd.h>
                   1415: #     define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
                   1416: #     ifndef __GNUC__
                   1417: #       define PREFETCH(x)  { \
                   1418:                               register long addr = (long)(x); \
                   1419:                               (void) _asm ("LDW", 0, 0, addr, 0); \
                   1420:                             }
                   1421: #     endif
                   1422: #   endif /* HPUX */
                   1423: #   ifdef LINUX
                   1424: #     define OS_TYPE "LINUX"
                   1425: #     define LINUX_STACKBOTTOM
                   1426: #     define DYNAMIC_LOADING
1.6       noro     1427: #     define SEARCH_FOR_DATA_START
                   1428:       extern int _end[];
1.3       noro     1429: #     define DATAEND (&_end)
                   1430: #   endif /* LINUX */
                   1431: # endif /* HP_PA */
1.1       noro     1432:
                   1433: # ifdef ALPHA
                   1434: #   define MACH_TYPE "ALPHA"
                   1435: #   define ALIGNMENT 8
1.9     ! noro     1436: #   define CPP_WORDSZ 64
1.6       noro     1437: #   ifndef LINUX
                   1438: #     define USE_GENERIC_PUSH_REGS
                   1439:       /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
                   1440:       /* fp registers in some cases when the target is a 21264.  The assembly */
                   1441:       /* code doesn't handle that yet, and version dependencies make that a   */
                   1442:       /* bit tricky.  Do the easy thing for now.                                   */
                   1443: #   endif
1.3       noro     1444: #   ifdef NETBSD
                   1445: #      define OS_TYPE "NETBSD"
                   1446: #      define HEURISTIC2
                   1447: #      define DATASTART GC_data_start
                   1448: #      define ELFCLASS32 32
                   1449: #      define ELFCLASS64 64
                   1450: #      define ELF_CLASS ELFCLASS64
                   1451: #       define DYNAMIC_LOADING
                   1452: #   endif
1.6       noro     1453: #   ifdef OPENBSD
                   1454: #      define OS_TYPE "OPENBSD"
                   1455: #      define HEURISTIC2
                   1456: #      ifdef __ELF__   /* since OpenBSD/Alpha 2.9 */
                   1457: #         define DATASTART GC_data_start
                   1458: #         define ELFCLASS32 32
                   1459: #         define ELFCLASS64 64
                   1460: #         define ELF_CLASS ELFCLASS64
                   1461: #       else           /* ECOFF, until OpenBSD/Alpha 2.7 */
                   1462: #         define DATASTART ((ptr_t) 0x140000000)
                   1463: #      endif
                   1464: #   endif
                   1465: #   ifdef FREEBSD
                   1466: #      define OS_TYPE "FREEBSD"
                   1467: /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
                   1468: #      define SIG_SUSPEND SIGUSR1
                   1469: #      define SIG_THR_RESTART SIGUSR2
                   1470: #      define FREEBSD_STACKBOTTOM
                   1471: #      ifdef __ELF__
                   1472: #          define DYNAMIC_LOADING
                   1473: #      endif
                   1474: /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
                   1475:        extern char etext[];
                   1476:        extern char edata[];
                   1477:        extern char end[];
                   1478: #      define NEED_FIND_LIMIT
                   1479: #      define DATASTART ((ptr_t)(&etext))
                   1480: #      define DATAEND (GC_find_limit (DATASTART, TRUE))
                   1481: #      define DATASTART2 ((ptr_t)(&edata))
                   1482: #      define DATAEND2 ((ptr_t)(&end))
                   1483: #   endif
1.1       noro     1484: #   ifdef OSF1
                   1485: #      define OS_TYPE "OSF1"
                   1486: #      define DATASTART ((ptr_t) 0x140000000)
1.6       noro     1487:        extern int _end[];
1.1       noro     1488: #      define DATAEND ((ptr_t) &_end)
1.3       noro     1489:        extern char ** environ;
                   1490:        /* round up from the value of environ to the nearest page boundary */
                   1491:        /* Probably breaks if putenv is called before collector            */
                   1492:        /* initialization.                                                 */
                   1493: #      define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
                   1494: /* #           define HEURISTIC2 */
1.1       noro     1495:        /* Normally HEURISTIC2 is too conervative, since                */
                   1496:        /* the text segment immediately follows the stack.              */
                   1497:        /* Hence we give an upper pound.                                */
1.3       noro     1498:        /* This is currently unused, since we disabled HEURISTIC2       */
1.6       noro     1499:        extern int __start[];
                   1500: #      define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1.9     ! noro     1501: #      ifndef GC_OSF1_THREADS
        !          1502:          /* Unresolved signal issues with threads.     */
        !          1503: #        define MPROTECT_VDB
        !          1504: #       endif
1.1       noro     1505: #      define DYNAMIC_LOADING
                   1506: #   endif
                   1507: #   ifdef LINUX
                   1508: #       define OS_TYPE "LINUX"
                   1509: #       define STACKBOTTOM ((ptr_t) 0x120000000)
                   1510: #       ifdef __ELF__
1.3       noro     1511: #        define SEARCH_FOR_DATA_START
1.1       noro     1512: #         define DYNAMIC_LOADING
                   1513: #       else
                   1514: #           define DATASTART ((ptr_t) 0x140000000)
                   1515: #       endif
1.6       noro     1516:        extern int _end[];
                   1517: #      define DATAEND (_end)
1.1       noro     1518: #      define MPROTECT_VDB
                   1519:                /* Has only been superficially tested.  May not */
                   1520:                /* work on all versions.                        */
                   1521: #   endif
                   1522: # endif
                   1523:
1.3       noro     1524: # ifdef IA64
                   1525: #   define MACH_TYPE "IA64"
                   1526: #   define USE_GENERIC_PUSH_REGS
                   1527:        /* We need to get preserved registers in addition to register   */
                   1528:        /* windows.   That's easiest to do with setjmp.                 */
                   1529: #   ifdef PARALLEL_MARK
                   1530: #      define USE_MARK_BYTES
                   1531:            /* Compare-and-exchange is too expensive to use for         */
                   1532:            /* setting mark bits.                                       */
                   1533: #   endif
                   1534: #   ifdef HPUX
1.6       noro     1535: #      ifdef _ILP32
                   1536: #        define CPP_WORDSZ 32
                   1537: #         define ALIGN_DOUBLE
                   1538:            /* Requires 8 byte alignment for malloc */
                   1539: #        define ALIGNMENT 4
                   1540: #       else
                   1541: #        ifndef _LP64
                   1542:                ---> unknown ABI
                   1543: #         endif
                   1544: #        define CPP_WORDSZ 64
                   1545: #        define ALIGN_DOUBLE
                   1546:            /* Requires 16 byte alignment for malloc */
                   1547: #         define ALIGNMENT 8
                   1548: #       endif
                   1549: #       define OS_TYPE "HPUX"
                   1550:         extern int __data_start[];
                   1551: #       define DATASTART ((ptr_t)(__data_start))
                   1552:         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2      */
                   1553:         /* to this.  Note that the GC must be initialized before the   */
                   1554:        /* first putenv call.                                           */
                   1555:        extern char ** environ;
                   1556: #       define STACKBOTTOM ((ptr_t)environ)
                   1557: #       define DYNAMIC_LOADING
                   1558: #       include <unistd.h>
                   1559: #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
                   1560:        /* The following was empirically determined, and is probably    */
                   1561:        /* not very robust.                                             */
                   1562:        /* Note that the backing store base seems to be at a nice       */
                   1563:        /* address minus one page.                                      */
                   1564: #      define BACKING_STORE_DISPLACEMENT 0x1000000
                   1565: #      define BACKING_STORE_ALIGNMENT 0x1000
                   1566: #       define BACKING_STORE_BASE \
                   1567:          (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
                   1568:                        & ~(BACKING_STORE_ALIGNMENT - 1))
1.3       noro     1569: #   endif
                   1570: #   ifdef LINUX
1.6       noro     1571: #      define CPP_WORDSZ 64
                   1572: #      define ALIGN_DOUBLE
                   1573:          /* Requires 16 byte alignment for malloc */
                   1574: #      define ALIGNMENT 8
1.3       noro     1575: #       define OS_TYPE "LINUX"
                   1576:        /* The following works on NUE and older kernels:        */
                   1577: /* #       define STACKBOTTOM ((ptr_t) 0xa000000000000000l)    */
                   1578:        /* This does not work on NUE:                           */
                   1579: #       define LINUX_STACKBOTTOM
                   1580:        /* We also need the base address of the register stack  */
                   1581:        /* backing store.  This is computed in                  */
                   1582:        /* GC_linux_register_stack_base based on the following  */
                   1583:        /* constants:                                           */
                   1584: #       define BACKING_STORE_ALIGNMENT 0x100000
                   1585: #       define BACKING_STORE_DISPLACEMENT 0x80000000
                   1586:        extern char * GC_register_stackbottom;
                   1587: #      define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
                   1588: #      define SEARCH_FOR_DATA_START
1.6       noro     1589: #      ifdef __GNUC__
                   1590: #         define DYNAMIC_LOADING
                   1591: #      else
                   1592:          /* In the Intel compiler environment, we seem to end up with  */
                   1593:          /* statically linked executables and an undefined reference   */
                   1594:          /* to _DYNAMIC                                                */
                   1595: #      endif
1.3       noro     1596: #      define MPROTECT_VDB
                   1597:                /* Requires Linux 2.3.47 or later.      */
1.6       noro     1598:        extern int _end[];
                   1599: #      define DATAEND (_end)
1.3       noro     1600: #       ifdef __GNUC__
                   1601: #        define PREFETCH(x) \
                   1602:            __asm__ ("  lfetch  [%0]": : "r"((void *)(x)))
                   1603: #        define PREFETCH_FOR_WRITE(x) \
                   1604:            __asm__ ("  lfetch.excl     [%0]": : "r"((void *)(x)))
                   1605: #        define CLEAR_DOUBLE(x) \
                   1606:            __asm__ ("  stf.spill       [%0]=f0": : "r"((void *)(x)))
                   1607: #       endif
                   1608: #   endif
                   1609: # endif
                   1610:
1.1       noro     1611: # ifdef M88K
                   1612: #   define MACH_TYPE "M88K"
                   1613: #   define ALIGNMENT 4
                   1614: #   define ALIGN_DOUBLE
1.6       noro     1615:     extern int etext[];
1.1       noro     1616: #   ifdef CX_UX
                   1617: #      define OS_TYPE "CX_UX"
1.6       noro     1618: #       define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1.1       noro     1619: #   endif
                   1620: #   ifdef  DGUX
                   1621: #      define OS_TYPE "DGUX"
1.9     ! noro     1622:        extern ptr_t GC_SysVGetDataStart();
        !          1623: #       define DATASTART GC_SysVGetDataStart(0x10000, etext)
1.1       noro     1624: #   endif
                   1625: #   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
                   1626: # endif
                   1627:
                   1628: # ifdef S370
1.9     ! noro     1629:     /* If this still works, and if anyone cares, this should probably  */
        !          1630:     /* be moved to the S390 category.                                  */
1.1       noro     1631: #   define MACH_TYPE "S370"
                   1632: #   define ALIGNMENT 4 /* Required by hardware */
1.3       noro     1633: #   define USE_GENERIC_PUSH_REGS
                   1634: #   ifdef UTS4
                   1635: #       define OS_TYPE "UTS4"
1.6       noro     1636:         extern int etext[];
                   1637:        extern int _etext[];
                   1638:        extern int _end[];
1.9     ! noro     1639:        extern ptr_t GC_SysVGetDataStart();
        !          1640: #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1.6       noro     1641: #      define DATAEND (_end)
1.1       noro     1642: #      define HEURISTIC2
1.3       noro     1643: #   endif
1.9     ! noro     1644: # endif
        !          1645:
        !          1646: # ifdef S390
        !          1647: #   define MACH_TYPE "S390"
        !          1648: #   define USE_GENERIC_PUSH_REGS
        !          1649: #   ifndef __s390x__
        !          1650: #   define ALIGNMENT 4
        !          1651: #   define CPP_WORDSZ 32
        !          1652: #   else
        !          1653: #   define ALIGNMENT 8
        !          1654: #   define CPP_WORDSZ 64
        !          1655: #   define HBLKSIZE 4096
        !          1656: #   endif
1.3       noro     1657: #   ifdef LINUX
                   1658: #       define OS_TYPE "LINUX"
1.9     ! noro     1659: #       define LINUX_STACKBOTTOM
1.3       noro     1660: #       define DYNAMIC_LOADING
1.6       noro     1661:         extern int __data_start[];
                   1662: #       define DATASTART ((ptr_t)(__data_start))
1.9     ! noro     1663:     extern int _end[];
        !          1664: #   define DATAEND (_end)
        !          1665: #   define CACHE_LINE_SIZE 256
        !          1666: #   define GETPAGESIZE() 4096
1.3       noro     1667: #   endif
                   1668: # endif
                   1669:
                   1670: # if defined(PJ)
                   1671: #   define ALIGNMENT 4
1.6       noro     1672:     extern int _etext[];
                   1673: #   define DATASTART ((ptr_t)(_etext))
1.3       noro     1674: #   define HEURISTIC1
1.1       noro     1675: # endif
                   1676:
1.3       noro     1677: # ifdef ARM32
                   1678: #   define CPP_WORDSZ 32
                   1679: #   define MACH_TYPE "ARM32"
                   1680: #   define ALIGNMENT 4
                   1681: #   ifdef NETBSD
                   1682: #       define OS_TYPE "NETBSD"
                   1683: #       define HEURISTIC2
1.6       noro     1684:         extern char etext[];
                   1685: #       define DATASTART ((ptr_t)(etext))
1.3       noro     1686: #       define USE_GENERIC_PUSH_REGS
                   1687: #   endif
                   1688: #   ifdef LINUX
                   1689: #       define OS_TYPE "LINUX"
                   1690: #       define HEURISTIC1
                   1691: #       undef STACK_GRAN
                   1692: #       define STACK_GRAN 0x10000000
                   1693: #       define USE_GENERIC_PUSH_REGS
                   1694: #       ifdef __ELF__
                   1695: #            define DYNAMIC_LOADING
                   1696: #           include <features.h>
                   1697: #           if defined(__GLIBC__) && __GLIBC__ >= 2
1.9     ! noro     1698: #               define SEARCH_FOR_DATA_START
1.3       noro     1699: #           else
                   1700:                 extern char **__environ;
                   1701: #                define DATASTART ((ptr_t)(&__environ))
                   1702:                              /* hideous kludge: __environ is the first */
                   1703:                              /* word in crt0.o, and delimits the start */
                   1704:                              /* of the data segment, no matter which   */
                   1705:                              /* ld options were passed through.        */
                   1706:                              /* We could use _etext instead, but that  */
                   1707:                              /* would include .rodata, which may       */
                   1708:                              /* contain large read-only data tables    */
                   1709:                              /* that we'd rather not scan.             */
                   1710: #           endif
1.6       noro     1711:             extern int _end[];
                   1712: #           define DATAEND (_end)
1.3       noro     1713: #      else
1.6       noro     1714:             extern int etext[];
                   1715: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.3       noro     1716: #       endif
                   1717: #   endif
                   1718: #   ifdef MSWINCE
                   1719: #     define OS_TYPE "MSWINCE"
                   1720: #     define DATAEND /* not needed */
                   1721: #   endif
1.6       noro     1722: #   ifdef NOSYS
                   1723:       /* __data_start is usually defined in the target linker script.  */
                   1724:       extern int __data_start[];
                   1725: #     define DATASTART (ptr_t)(__data_start)
                   1726: #     define USE_GENERIC_PUSH_REGS
                   1727:       /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S  */
                   1728:       extern void *__stack_base__;
                   1729: #     define STACKBOTTOM ((ptr_t) (__stack_base__))
                   1730: #   endif
1.3       noro     1731: #endif
                   1732:
                   1733: # ifdef SH
                   1734: #   define MACH_TYPE "SH"
                   1735: #   define ALIGNMENT 4
                   1736: #   ifdef MSWINCE
                   1737: #     define OS_TYPE "MSWINCE"
                   1738: #     define DATAEND /* not needed */
                   1739: #   endif
                   1740: #   ifdef LINUX
                   1741: #     define OS_TYPE "LINUX"
                   1742: #     define STACKBOTTOM ((ptr_t) 0x7c000000)
                   1743: #     define USE_GENERIC_PUSH_REGS
                   1744: #     define DYNAMIC_LOADING
1.9     ! noro     1745: #     define SEARCH_FOR_DATA_START
1.6       noro     1746:       extern int _end[];
                   1747: #     define DATAEND (_end)
1.3       noro     1748: #   endif
                   1749: # endif
                   1750:
                   1751: # ifdef SH4
                   1752: #   define MACH_TYPE "SH4"
                   1753: #   define OS_TYPE "MSWINCE"
                   1754: #   define ALIGNMENT 4
                   1755: #   define DATAEND /* not needed */
                   1756: # endif
                   1757:
1.9     ! noro     1758: # ifdef X86_64
        !          1759: #   define MACH_TYPE "X86_64"
        !          1760: #   define ALIGNMENT 8
        !          1761: #   define CPP_WORDSZ 64
        !          1762: #   ifndef HBLKSIZE
        !          1763: #     define HBLKSIZE 4096
        !          1764: #   endif
        !          1765: #   define CACHE_LINE_SIZE 64
        !          1766: #   define USE_GENERIC_PUSH_REGS
        !          1767: #   ifdef LINUX
        !          1768: #      define OS_TYPE "LINUX"
        !          1769: #       define LINUX_STACKBOTTOM
        !          1770: #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
        !          1771: #          define MPROTECT_VDB
        !          1772: #      else
        !          1773:            /* We seem to get random errors in incremental mode,        */
        !          1774:            /* possibly because Linux threads is itself a malloc client */
        !          1775:            /* and can't deal with the signals.                         */
        !          1776: #      endif
        !          1777: #       ifdef __ELF__
        !          1778: #            define DYNAMIC_LOADING
        !          1779: #           ifdef UNDEFINED    /* includes ro data */
        !          1780:               extern int _etext[];
        !          1781: #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
        !          1782: #           endif
        !          1783: #           include <features.h>
        !          1784: #           define SEARCH_FOR_DATA_START
        !          1785:             extern int _end[];
        !          1786: #           define DATAEND (_end)
        !          1787: #      else
        !          1788:             extern int etext[];
        !          1789: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
        !          1790: #       endif
        !          1791: #      define PREFETCH(x) \
        !          1792:          __asm__ __volatile__ ("       prefetch        %0": : "m"(*(char *)(x)))
        !          1793: #      define PREFETCH_FOR_WRITE(x) \
        !          1794:          __asm__ __volatile__ ("       prefetchw       %0": : "m"(*(char *)(x)))
        !          1795: #   endif
        !          1796: # endif
1.3       noro     1797:
                   1798: #if defined(LINUX) && defined(REDIRECT_MALLOC)
                   1799:     /* Rld appears to allocate some memory with its own allocator, and */
                   1800:     /* some through malloc, which might be redirected.  To make this   */
                   1801:     /* work with collectable memory, we have to scan memory allocated  */
                   1802:     /* by rld's internal malloc.                                       */
                   1803: #   define USE_PROC_FOR_LIBRARIES
                   1804: #endif
                   1805:
1.1       noro     1806: # ifndef STACK_GROWS_UP
                   1807: #   define STACK_GROWS_DOWN
                   1808: # endif
                   1809:
                   1810: # ifndef CPP_WORDSZ
                   1811: #   define CPP_WORDSZ 32
                   1812: # endif
                   1813:
                   1814: # ifndef OS_TYPE
                   1815: #   define OS_TYPE ""
                   1816: # endif
                   1817:
                   1818: # ifndef DATAEND
1.6       noro     1819:     extern int end[];
                   1820: #   define DATAEND (end)
1.1       noro     1821: # endif
                   1822:
                   1823: # if defined(SVR4) && !defined(GETPAGESIZE)
                   1824: #    include <unistd.h>
                   1825: #    define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
                   1826: # endif
                   1827:
                   1828: # ifndef GETPAGESIZE
                   1829: #   if defined(SUNOS5) || defined(IRIX5)
                   1830: #      include <unistd.h>
                   1831: #   endif
                   1832: #   define GETPAGESIZE() getpagesize()
                   1833: # endif
                   1834:
                   1835: # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1.6       noro     1836:            /* OS has SVR4 generic features.  Probably others also qualify.     */
1.1       noro     1837: #   define SVR4
                   1838: # endif
                   1839:
                   1840: # if defined(SUNOS5) || defined(DRSNX)
1.6       noro     1841:            /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
                   1842:            /* loader.                                                          */
1.1       noro     1843: #   define SUNOS5DL
1.6       noro     1844:            /* OS has SUNOS5 style signal handlers.                             */
1.1       noro     1845: #   define SUNOS5SIGS
                   1846: # endif
                   1847:
1.3       noro     1848: # if defined(HPUX)
                   1849: #   define SUNOS5SIGS
                   1850: # endif
                   1851:
                   1852: # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1.9     ! noro     1853:            || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
        !          1854:            || defined(DGUX) || defined(BSD) \
        !          1855:            || defined(_AIX) || defined(DARWIN) || defined(OSF1)
1.3       noro     1856: #   define UNIX_LIKE   /* Basic Unix-like system calls work.   */
                   1857: # endif
                   1858:
1.1       noro     1859: # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1.6       noro     1860:           -> bad word size
1.1       noro     1861: # endif
                   1862:
                   1863: # ifdef PCR
                   1864: #   undef DYNAMIC_LOADING
                   1865: #   undef STACKBOTTOM
                   1866: #   undef HEURISTIC1
                   1867: #   undef HEURISTIC2
                   1868: #   undef PROC_VDB
                   1869: #   undef MPROTECT_VDB
                   1870: #   define PCR_VDB
                   1871: # endif
                   1872:
                   1873: # ifdef SRC_M3
1.6       noro     1874:        /* Postponed for now. */
1.1       noro     1875: #   undef PROC_VDB
                   1876: #   undef MPROTECT_VDB
                   1877: # endif
                   1878:
                   1879: # ifdef SMALL_CONFIG
1.6       noro     1880:        /* Presumably not worth the space it takes. */
1.1       noro     1881: #   undef PROC_VDB
                   1882: #   undef MPROTECT_VDB
                   1883: # endif
                   1884:
                   1885: # ifdef USE_MUNMAP
                   1886: #   undef MPROTECT_VDB  /* Can't deal with address space holes. */
                   1887: # endif
                   1888:
1.3       noro     1889: # ifdef PARALLEL_MARK
                   1890: #   undef MPROTECT_VDB  /* For now.    */
                   1891: # endif
                   1892:
1.1       noro     1893: # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
                   1894: #   define DEFAULT_VDB
                   1895: # endif
                   1896:
1.3       noro     1897: # ifndef PREFETCH
                   1898: #   define PREFETCH(x)
                   1899: #   define NO_PREFETCH
                   1900: # endif
                   1901:
                   1902: # ifndef PREFETCH_FOR_WRITE
                   1903: #   define PREFETCH_FOR_WRITE(x)
                   1904: #   define NO_PREFETCH_FOR_WRITE
                   1905: # endif
                   1906:
                   1907: # ifndef CACHE_LINE_SIZE
                   1908: #   define CACHE_LINE_SIZE 32  /* Wild guess   */
                   1909: # endif
                   1910:
1.9     ! noro     1911: # ifdef LINUX
        !          1912: #   define REGISTER_LIBRARIES_EARLY
        !          1913:     /* We sometimes use dl_iterate_phdr, which may acquire an internal */
        !          1914:     /* lock.  This isn't safe after the world has stopped.  So we must */
        !          1915:     /* call GC_register_dynamic_libraries before stopping the world.   */
        !          1916:     /* For performance reasons, this may be beneficial on other                */
        !          1917:     /* platforms as well, though it should be avoided in win32.                */
        !          1918: # endif /* LINUX */
        !          1919:
1.6       noro     1920: # if defined(SEARCH_FOR_DATA_START)
                   1921:     extern ptr_t GC_data_start;
                   1922: #   define DATASTART GC_data_start
                   1923: # endif
                   1924:
1.3       noro     1925: # ifndef CLEAR_DOUBLE
                   1926: #   define CLEAR_DOUBLE(x) \
1.6       noro     1927:                ((word*)x)[0] = 0; \
                   1928:                ((word*)x)[1] = 0;
1.3       noro     1929: # endif /* CLEAR_DOUBLE */
                   1930:
1.6       noro     1931:        /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
                   1932: # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
                   1933: #   define GC_SOLARIS_THREADS
                   1934: # endif
1.3       noro     1935:
1.6       noro     1936: # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
                   1937:        --> inconsistent configuration
1.1       noro     1938: # endif
1.6       noro     1939: # if defined(GC_LINUX_THREADS) && !defined(LINUX)
                   1940:        --> inconsistent configuration
1.1       noro     1941: # endif
1.6       noro     1942: # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
                   1943:        --> inconsistent configuration
1.1       noro     1944: # endif
1.6       noro     1945: # if defined(GC_HPUX_THREADS) && !defined(HPUX)
                   1946:        --> inconsistent configuration
1.1       noro     1947: # endif
1.9     ! noro     1948: # if defined(GC_AIX_THREADS) && !defined(_AIX)
        !          1949:        --> inconsistent configuration
        !          1950: # endif
        !          1951: # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
1.6       noro     1952:        --> inconsistent configuration
1.1       noro     1953: # endif
1.6       noro     1954:
1.1       noro     1955: # if defined(PCR) || defined(SRC_M3) || \
1.6       noro     1956:                defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
                   1957:                defined(GC_PTHREADS)
1.1       noro     1958: #   define THREADS
                   1959: # endif
                   1960:
1.9     ! noro     1961: # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(DARWIN) \
1.6       noro     1962:             || defined(LINT) || defined(MSWINCE) || defined(ARM32) \
                   1963:             || (defined(I386) && defined(__LCC__))
1.9     ! noro     1964:        /* Use setjmp based hack to mark from callee-save registers.    */
        !          1965:        /* The define should move to the individual platform            */
        !          1966:        /* descriptions.                                                */
1.1       noro     1967: #      define USE_GENERIC_PUSH_REGS
                   1968: # endif
1.6       noro     1969:
                   1970: # if defined(SPARC)
                   1971: #   define ASM_CLEAR_CODE      /* Stack clearing is crucial, and we    */
1.9     ! noro     1972:                                /* include assembly code to do it well. */
1.6       noro     1973: # endif
                   1974:
1.9     ! noro     1975:   /* Can we save call chain in objects for debugging?                  */
        !          1976:   /* SET NFRAMES (# of saved frames) and NARGS (#of args for each      */
        !          1977:   /* frame) to reasonable values for the platform.                     */
        !          1978:   /* Set SAVE_CALL_CHAIN if we can.  SAVE_CALL_COUNT can be specified  */
        !          1979:   /* at build time, though we feel free to adjust it slightly.         */
        !          1980:   /* Define NEED_CALLINFO if we either save the call stack or          */
        !          1981:   /* GC_ADD_CALLER is defined.                                         */
        !          1982:   /* GC_CAN_SAVE_CALL_STACKS is set in gc.h.                           */
1.6       noro     1983:
                   1984: #if defined(SPARC)
                   1985: # define CAN_SAVE_CALL_ARGS
                   1986: #endif
1.9     ! noro     1987: #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1.6       noro     1988:            /* SAVE_CALL_CHAIN is supported if the code is compiled to save     */
                   1989:            /* frame pointers by default, i.e. no -fomit-frame-pointer flag.    */
                   1990: # define CAN_SAVE_CALL_ARGS
                   1991: #endif
                   1992:
                   1993: # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1.9     ! noro     1994:             && defined(GC_CAN_SAVE_CALL_STACKS)
1.3       noro     1995: #   define SAVE_CALL_CHAIN
                   1996: # endif
1.6       noro     1997: # ifdef SAVE_CALL_CHAIN
                   1998: #   if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
                   1999: #     define NARGS SAVE_CALL_NARGS
                   2000: #   else
                   2001: #     define NARGS 0   /* Number of arguments to save for each call.   */
                   2002: #   endif
1.3       noro     2003: # endif
1.6       noro     2004: # ifdef SAVE_CALL_CHAIN
                   2005: #   ifndef SAVE_CALL_COUNT
                   2006: #     define NFRAMES 6 /* Number of frames to save. Even for           */
                   2007:                                /* alignment reasons.                           */
                   2008: #   else
                   2009: #     define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
                   2010: #   endif
                   2011: #   define NEED_CALLINFO
                   2012: # endif /* SAVE_CALL_CHAIN */
                   2013: # ifdef GC_ADD_CALLER
                   2014: #   define NFRAMES 1
                   2015: #   define NARGS 0
                   2016: #   define NEED_CALLINFO
                   2017: # endif
                   2018:
                   2019: # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
                   2020: #   define DBG_HDRS_ALL
                   2021: # endif
                   2022:
1.9     ! noro     2023: # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
        !          2024: #   define POINTER_SHIFT 0
        !          2025: # endif
        !          2026:
        !          2027: # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
        !          2028: #   define POINTER_MASK ((GC_word)(-1))
        !          2029: # endif
        !          2030:
        !          2031: # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
        !          2032: #   define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
        !          2033: # endif
        !          2034:
        !          2035: # if defined(FIXUP_POINTER)
        !          2036: #   define NEED_FIXUP_POINTER 1
        !          2037: # else
        !          2038: #   define NEED_FIXUP_POINTER 0
        !          2039: #   define FIXUP_POINTER(p)
        !          2040: # endif
        !          2041:
1.6       noro     2042: #ifdef GC_PRIVATE_H
                   2043:        /* This relies on some type definitions from gc_priv.h, from    */
                   2044:         /* where it's normally included.                               */
                   2045:        /*                                                              */
                   2046:        /* How to get heap memory from the OS:                          */
                   2047:        /* Note that sbrk()-like allocation is preferred, since it      */
                   2048:        /* usually makes it possible to merge consecutively allocated   */
                   2049:        /* chunks.  It also avoids unintented recursion with            */
                   2050:        /* -DREDIRECT_MALLOC.                                           */
                   2051:        /* GET_MEM() returns a HLKSIZE aligned chunk.                   */
                   2052:        /* 0 is taken to mean failure.                                  */
                   2053:        /* In the case os USE_MMAP, the argument must also be a         */
                   2054:        /* physical page size.                                          */
                   2055:        /* GET_MEM is currently not assumed to retrieve 0 filled space, */
                   2056:        /* though we should perhaps take advantage of the case in which */
                   2057:        /* does.                                                        */
                   2058:        struct hblk;    /* See gc_priv.h.       */
                   2059: # ifdef PCR
                   2060:            char * real_malloc();
                   2061: #   define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
                   2062:                                          + GC_page_size-1)
                   2063: # else
                   2064: #   ifdef OS2
                   2065:              void * os2_alloc(size_t bytes);
                   2066: #     define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
                   2067:                                            + GC_page_size) \
                   2068:                                            + GC_page_size-1)
                   2069: #   else
1.9     ! noro     2070: #     if defined(NEXT) || defined(DOS4GW) || \
1.6       noro     2071:                 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
                   2072:                 (defined(SUNOS5) && !defined(USE_MMAP))
                   2073: #       define GET_MEM(bytes) HBLKPTR((size_t) \
                   2074:                                              calloc(1, (size_t)bytes + GC_page_size) \
                   2075:                                              + GC_page_size-1)
                   2076: #     else
                   2077: #      ifdef MSWIN32
1.9     ! noro     2078:          extern ptr_t GC_win32_get_mem();
1.6       noro     2079: #         define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
                   2080: #      else
                   2081: #        ifdef MACOS
                   2082: #          if defined(USE_TEMPORARY_MEMORY)
                   2083:                        extern Ptr GC_MacTemporaryNewPtr(size_t size,
                   2084:                                                         Boolean clearMemory);
                   2085: #               define GET_MEM(bytes) HBLKPTR( \
                   2086:                            GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
                   2087:                            + GC_page_size-1)
                   2088: #          else
                   2089: #                  define GET_MEM(bytes) HBLKPTR( \
                   2090:                                NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
                   2091: #          endif
                   2092: #        else
                   2093: #          ifdef MSWINCE
1.9     ! noro     2094:              extern ptr_t GC_wince_get_mem();
1.6       noro     2095: #            define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
                   2096: #          else
                   2097: #            if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
                   2098:                        extern void *GC_amiga_get_mem(size_t size);
                   2099:                        define GET_MEM(bytes) HBLKPTR((size_t) \
                   2100:                          GC_amiga_get_mem((size_t)bytes + GC_page_size) \
                   2101:                          + GC_page_size-1)
                   2102: #            else
1.9     ! noro     2103:                extern ptr_t GC_unix_get_mem();
1.6       noro     2104: #               define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
                   2105: #            endif
                   2106: #          endif
                   2107: #        endif
                   2108: #      endif
                   2109: #     endif
                   2110: #   endif
1.1       noro     2111: # endif
1.6       noro     2112:
                   2113: #endif /* GC_PRIVATE_H */
1.1       noro     2114:
1.3       noro     2115: # endif /* GCCONFIG_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>