[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.10

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.10    ! noro      960: #
        !           961: #   added by noro
        !           962: #   define USE_MMAP
        !           963: #
1.6       noro      964: #      if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1.1       noro      965: #          define USE_MMAP
1.6       noro      966:            /* Otherwise we now use calloc.  Mmap may result in the     */
                    967:            /* heap interleaved with thread stacks, which can result in */
                    968:            /* excessive blacklisting.  Sbrk is unusable since it       */
                    969:            /* doesn't interact correctly with the system malloc.       */
1.1       noro      970: #      endif
                    971: #       ifdef USE_MMAP
                    972: #         define HEAP_START (ptr_t)0x40000000
                    973: #       else
                    974: #        define HEAP_START DATAEND
                    975: #       endif
                    976: #   endif
                    977: #   ifdef SCO
                    978: #      define OS_TYPE "SCO"
1.6       noro      979:        extern int etext[];
                    980: #      define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1.1       noro      981:                                  & ~0x3fffff) \
1.6       noro      982:                                 +((word)etext & 0xfff))
1.1       noro      983: #      define STACKBOTTOM ((ptr_t) 0x7ffffffc)
                    984: #   endif
                    985: #   ifdef SCO_ELF
                    986: #       define OS_TYPE "SCO_ELF"
1.6       noro      987:         extern int etext[];
                    988: #       define DATASTART ((ptr_t)(etext))
1.1       noro      989: #       define STACKBOTTOM ((ptr_t) 0x08048000)
                    990: #       define DYNAMIC_LOADING
                    991: #      define ELF_CLASS ELFCLASS32
                    992: #   endif
1.6       noro      993: #   ifdef DGUX
                    994: #      define OS_TYPE "DGUX"
                    995:        extern int _etext, _end;
1.9       noro      996:        extern ptr_t GC_SysVGetDataStart();
1.6       noro      997: #      define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
                    998: #      define DATAEND (&_end)
                    999: #      define STACK_GROWS_DOWN
                   1000: #      define HEURISTIC2
                   1001: #      include <unistd.h>
                   1002: #      define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
                   1003: #      define DYNAMIC_LOADING
                   1004: #      ifndef USE_MMAP
                   1005: #        define USE_MMAP
                   1006: #      endif /* USE_MMAP */
                   1007: #      define MAP_FAILED (void *) -1
                   1008: #      ifdef USE_MMAP
                   1009: #        define HEAP_START (ptr_t)0x40000000
                   1010: #      else /* USE_MMAP */
                   1011: #        define HEAP_START DATAEND
                   1012: #      endif /* USE_MMAP */
                   1013: #   endif /* DGUX */
                   1014:
1.1       noro     1015: #   ifdef LINUX
1.6       noro     1016: #      ifndef __GNUC__
                   1017:          /* The Intel compiler doesn't like inline assembly */
                   1018: #        define USE_GENERIC_PUSH_REGS
                   1019: #      endif
1.1       noro     1020: #      define OS_TYPE "LINUX"
1.3       noro     1021: #       define LINUX_STACKBOTTOM
1.8       noro     1022: /* #       define USE_MMAP */
1.3       noro     1023: #      if 0
                   1024: #        define HEURISTIC1
                   1025: #         undef STACK_GRAN
                   1026: #         define STACK_GRAN 0x10000000
                   1027:          /* STACKBOTTOM is usually 0xc0000000, but this changes with   */
                   1028:          /* different kernel configurations.  In particular, systems   */
                   1029:          /* with 2GB physical memory will usually move the user        */
                   1030:          /* address space limit, and hence initial SP to 0x80000000.   */
                   1031: #       endif
1.6       noro     1032: #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1.1       noro     1033: #          define MPROTECT_VDB
                   1034: #      else
                   1035:            /* We seem to get random errors in incremental mode,        */
                   1036:            /* possibly because Linux threads is itself a malloc client */
                   1037:            /* and can't deal with the signals.                         */
                   1038: #      endif
1.6       noro     1039: #      define HEAP_START 0x1000
                   1040:                /* This encourages mmap to give us low addresses,       */
                   1041:                /* thus allowing the heap to grow to ~3GB               */
1.1       noro     1042: #       ifdef __ELF__
                   1043: #            define DYNAMIC_LOADING
                   1044: #           ifdef UNDEFINED    /* includes ro data */
1.6       noro     1045:               extern int _etext[];
                   1046: #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1.1       noro     1047: #           endif
                   1048: #           include <features.h>
                   1049: #           if defined(__GLIBC__) && __GLIBC__ >= 2
1.9       noro     1050: #               define SEARCH_FOR_DATA_START
1.1       noro     1051: #           else
                   1052:                 extern char **__environ;
                   1053: #                define DATASTART ((ptr_t)(&__environ))
                   1054:                              /* hideous kludge: __environ is the first */
                   1055:                              /* word in crt0.o, and delimits the start */
                   1056:                              /* of the data segment, no matter which   */
                   1057:                              /* ld options were passed through.        */
                   1058:                              /* We could use _etext instead, but that  */
                   1059:                              /* would include .rodata, which may       */
                   1060:                              /* contain large read-only data tables    */
                   1061:                              /* that we'd rather not scan.             */
                   1062: #           endif
1.6       noro     1063:             extern int _end[];
                   1064: #           define DATAEND (_end)
1.1       noro     1065: #      else
1.6       noro     1066:             extern int etext[];
                   1067: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.1       noro     1068: #       endif
1.3       noro     1069: #      ifdef USE_I686_PREFETCH
                   1070: #        define PREFETCH(x) \
                   1071:            __asm__ __volatile__ ("     prefetchnta     %0": : "m"(*(char *)(x)))
                   1072:            /* Empirically prefetcht0 is much more effective at reducing        */
                   1073:            /* cache miss stalls for the targetted load instructions.  But it   */
                   1074:            /* seems to interfere enough with other cache traffic that the net  */
                   1075:            /* result is worse than prefetchnta.                                */
                   1076: #         if 0
                   1077:            /* Using prefetches for write seems to have a slight negative       */
                   1078:            /* impact on performance, at least for a PIII/500.                  */
                   1079: #          define PREFETCH_FOR_WRITE(x) \
                   1080:              __asm__ __volatile__ ("   prefetcht0      %0": : "m"(*(char *)(x)))
                   1081: #        endif
                   1082: #      endif
                   1083: #      ifdef USE_3DNOW_PREFETCH
                   1084: #        define PREFETCH(x) \
                   1085:            __asm__ __volatile__ ("     prefetch        %0": : "m"(*(char *)(x)))
                   1086: #        define PREFETCH_FOR_WRITE(x) \
                   1087:            __asm__ __volatile__ ("     prefetchw       %0": : "m"(*(char *)(x)))
                   1088: #      endif
1.1       noro     1089: #   endif
                   1090: #   ifdef CYGWIN32
                   1091: #       define OS_TYPE "CYGWIN32"
1.6       noro     1092:           extern int _data_start__[];
                   1093:           extern int _data_end__[];
                   1094:           extern int _bss_start__[];
                   1095:           extern int _bss_end__[];
1.1       noro     1096:        /* For binutils 2.9.1, we have                  */
                   1097:        /*      DATASTART   = _data_start__             */
                   1098:        /*      DATAEND     = _bss_end__                */
                   1099:        /* whereas for some earlier versions it was     */
                   1100:        /*      DATASTART   = _bss_start__              */
                   1101:        /*      DATAEND     = _data_end__               */
                   1102:        /* To get it right for both, we take the        */
                   1103:        /* minumum/maximum of the two.                  */
1.9       noro     1104: #     ifndef MAX
1.1       noro     1105: #      define MAX(x,y) ((x) > (y) ? (x) : (y))
1.9       noro     1106: #     endif
                   1107: #     ifndef MIN
1.1       noro     1108: #      define MIN(x,y) ((x) < (y) ? (x) : (y))
1.9       noro     1109: #     endif
1.6       noro     1110: #       define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
                   1111: #       define DATAEND  ((ptr_t) MAX(_data_end__, _bss_end__))
1.1       noro     1112: #      undef STACK_GRAN
                   1113: #       define STACK_GRAN 0x10000
                   1114: #       define HEURISTIC1
                   1115: #   endif
                   1116: #   ifdef OS2
                   1117: #      define OS_TYPE "OS2"
                   1118:                /* STACKBOTTOM and DATASTART are handled specially in   */
                   1119:                /* os_dep.c. OS2 actually has the right                 */
                   1120:                /* system call!                                         */
                   1121: #      define DATAEND  /* not needed */
1.3       noro     1122: #      define USE_GENERIC_PUSH_REGS
1.1       noro     1123: #   endif
                   1124: #   ifdef MSWIN32
                   1125: #      define OS_TYPE "MSWIN32"
                   1126:                /* STACKBOTTOM and DATASTART are handled specially in   */
                   1127:                /* os_dep.c.                                            */
                   1128: #       ifndef __WATCOMC__
                   1129: #        define MPROTECT_VDB
                   1130: #      endif
                   1131: #       define DATAEND  /* not needed */
                   1132: #   endif
1.3       noro     1133: #   ifdef MSWINCE
                   1134: #      define OS_TYPE "MSWINCE"
                   1135: #       define DATAEND  /* not needed */
                   1136: #   endif
1.1       noro     1137: #   ifdef DJGPP
                   1138: #       define OS_TYPE "DJGPP"
                   1139: #       include "stubinfo.h"
1.6       noro     1140:         extern int etext[];
1.1       noro     1141:         extern int _stklen;
                   1142:         extern int __djgpp_stack_limit;
1.6       noro     1143: #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1.1       noro     1144: /* #       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
                   1145:                                                      + _stklen)) */
                   1146: #       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
                   1147:                /* This may not be right.  */
                   1148: #   endif
                   1149: #   ifdef OPENBSD
                   1150: #      define OS_TYPE "OPENBSD"
                   1151: #   endif
                   1152: #   ifdef FREEBSD
                   1153: #      define OS_TYPE "FREEBSD"
1.6       noro     1154: #      ifndef GC_FREEBSD_THREADS
                   1155: #          define MPROTECT_VDB
                   1156: #      endif
                   1157: #      define SIG_SUSPEND SIGUSR1
                   1158: #      define SIG_THR_RESTART SIGUSR2
1.3       noro     1159: #      define FREEBSD_STACKBOTTOM
1.6       noro     1160: #      ifdef __ELF__
                   1161: #          define DYNAMIC_LOADING
                   1162: #      endif
                   1163:        extern char etext[];
1.9       noro     1164:        extern char * GC_FreeBSDGetDataStart();
                   1165: #      define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1.1       noro     1166: #   endif
                   1167: #   ifdef NETBSD
                   1168: #      define OS_TYPE "NETBSD"
1.6       noro     1169: #      ifdef __ELF__
                   1170: #          define DYNAMIC_LOADING
                   1171: #      endif
1.1       noro     1172: #   endif
                   1173: #   ifdef THREE86BSD
                   1174: #      define OS_TYPE "THREE86BSD"
                   1175: #   endif
                   1176: #   ifdef BSDI
                   1177: #      define OS_TYPE "BSDI"
                   1178: #   endif
1.6       noro     1179: #   if defined(OPENBSD) || defined(NETBSD) \
1.1       noro     1180:         || defined(THREE86BSD) || defined(BSDI)
                   1181: #      define HEURISTIC2
1.6       noro     1182:        extern char etext[];
                   1183: #      define DATASTART ((ptr_t)(etext))
1.1       noro     1184: #   endif
                   1185: #   ifdef NEXT
                   1186: #      define OS_TYPE "NEXT"
                   1187: #      define DATASTART ((ptr_t) get_etext())
                   1188: #      define STACKBOTTOM ((ptr_t)0xc0000000)
                   1189: #      define DATAEND  /* not needed */
                   1190: #   endif
                   1191: #   ifdef DOS4GW
                   1192: #     define OS_TYPE "DOS4GW"
                   1193:       extern long __nullarea;
                   1194:       extern char _end;
                   1195:       extern char *_STACKTOP;
                   1196:       /* Depending on calling conventions Watcom C either precedes
                   1197:          or does not precedes with undescore names of C-variables.
                   1198:          Make sure startup code variables always have the same names.  */
                   1199:       #pragma aux __nullarea "*";
                   1200:       #pragma aux _end "*";
                   1201: #     define STACKBOTTOM ((ptr_t) _STACKTOP)
                   1202:                          /* confused? me too. */
                   1203: #     define DATASTART ((ptr_t) &__nullarea)
                   1204: #     define DATAEND ((ptr_t) &_end)
                   1205: #   endif
1.6       noro     1206: #   ifdef HURD
                   1207: #     define OS_TYPE "HURD"
                   1208: #     define STACK_GROWS_DOWN
                   1209: #     define HEURISTIC2
                   1210:       extern int  __data_start[];
                   1211: #     define DATASTART ( (ptr_t) (__data_start))
                   1212:       extern int   _end[];
                   1213: #     define DATAEND ( (ptr_t) (_end))
                   1214: /* #     define MPROTECT_VDB  Not quite working yet? */
                   1215: #     define DYNAMIC_LOADING
                   1216: #   endif
1.1       noro     1217: # endif
                   1218:
                   1219: # ifdef NS32K
                   1220: #   define MACH_TYPE "NS32K"
                   1221: #   define ALIGNMENT 4
                   1222:     extern char **environ;
                   1223: #   define DATASTART ((ptr_t)(&environ))
                   1224:                              /* hideous kludge: environ is the first   */
                   1225:                              /* word in crt0.o, and delimits the start */
                   1226:                              /* of the data segment, no matter which   */
                   1227:                              /* ld options were passed through.        */
                   1228: #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
                   1229: # endif
                   1230:
                   1231: # ifdef MIPS
                   1232: #   define MACH_TYPE "MIPS"
1.3       noro     1233: #   ifdef LINUX
                   1234:       /* This was developed for a linuxce style platform.  Probably    */
                   1235:       /* needs to be tweaked for workstation class machines.           */
                   1236: #     define OS_TYPE "LINUX"
1.6       noro     1237: #     define DYNAMIC_LOADING
                   1238:       extern int _end[];
                   1239: #     define DATAEND (_end)
                   1240:       extern int __data_start[];
                   1241: #     define DATASTART ((ptr_t)(__data_start))
1.3       noro     1242: #     define ALIGNMENT 4
1.6       noro     1243: #     define USE_GENERIC_PUSH_REGS
1.9       noro     1244: #     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
                   1245: #        define LINUX_STACKBOTTOM
                   1246: #     else
                   1247: #        define STACKBOTTOM 0x80000000
                   1248: #     endif
1.3       noro     1249: #   endif /* Linux */
1.6       noro     1250: #   ifdef EWS4800
                   1251: #      define HEURISTIC2
                   1252: #      if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
                   1253:          extern int _fdata[], _end[];
                   1254: #        define DATASTART ((ptr_t)_fdata)
                   1255: #        define DATAEND ((ptr_t)_end)
                   1256: #        define CPP_WORDSZ _MIPS_SZPTR
                   1257: #        define ALIGNMENT (_MIPS_SZPTR/8)
                   1258: #      else
                   1259:          extern int etext[], edata[], end[];
                   1260:          extern int _DYNAMIC_LINKING[], _gp[];
                   1261: #        define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
                   1262:                + ((word)etext & 0xffff)))
                   1263: #        define DATAEND (edata)
                   1264: #        define DATASTART2 (_DYNAMIC_LINKING \
                   1265:                ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
                   1266:                : (ptr_t)edata)
                   1267: #        define DATAEND2 (end)
                   1268: #        define ALIGNMENT 4
                   1269: #      endif
                   1270: #      define OS_TYPE "EWS4800"
                   1271: #      define USE_GENERIC_PUSH_REGS 1
                   1272: #   endif
1.3       noro     1273: #   ifdef ULTRIX
                   1274: #      define HEURISTIC2
                   1275: #       define DATASTART (ptr_t)0x10000000
1.1       noro     1276:                              /* Could probably be slightly higher since */
                   1277:                              /* startup code allocates lots of stuff.   */
                   1278: #      define OS_TYPE "ULTRIX"
                   1279: #       define ALIGNMENT 4
                   1280: #   endif
                   1281: #   ifdef RISCOS
1.3       noro     1282: #      define HEURISTIC2
                   1283: #       define DATASTART (ptr_t)0x10000000
1.1       noro     1284: #      define OS_TYPE "RISCOS"
                   1285: #      define ALIGNMENT 4  /* Required by hardware */
                   1286: #   endif
                   1287: #   ifdef IRIX5
1.3       noro     1288: #      define HEURISTIC2
1.6       noro     1289:         extern int _fdata[];
                   1290: #       define DATASTART ((ptr_t)(_fdata))
1.3       noro     1291: #       ifdef USE_MMAP
                   1292: #         define HEAP_START (ptr_t)0x30000000
                   1293: #       else
                   1294: #        define HEAP_START DATASTART
                   1295: #       endif
                   1296:                              /* Lowest plausible heap address.         */
                   1297:                              /* In the MMAP case, we map there.        */
                   1298:                              /* In either case it is used to identify  */
                   1299:                              /* heap sections so they're not           */
                   1300:                              /* considered as roots.                   */
1.1       noro     1301: #      define OS_TYPE "IRIX5"
1.9       noro     1302: /*#       define MPROTECT_VDB DOB: this should work, but there is evidence */
                   1303: /*             of recent breakage.                                        */
1.1       noro     1304: #       ifdef _MIPS_SZPTR
                   1305: #        define CPP_WORDSZ _MIPS_SZPTR
                   1306: #        define ALIGNMENT (_MIPS_SZPTR/8)
                   1307: #        if CPP_WORDSZ != 64
                   1308: #          define ALIGN_DOUBLE
                   1309: #        endif
                   1310: #      else
                   1311: #         define ALIGNMENT 4
                   1312: #        define ALIGN_DOUBLE
                   1313: #      endif
                   1314: #      define DYNAMIC_LOADING
                   1315: #   endif
1.3       noro     1316: #   ifdef MSWINCE
                   1317: #       define OS_TYPE "MSWINCE"
                   1318: #       define ALIGNMENT 4
                   1319: #       define DATAEND /* not needed */
                   1320: #   endif
                   1321: #   if defined(NETBSD)
                   1322:       /* This also checked for __MIPSEL__ .  Why?  NETBSD recognition  */
                   1323:       /* should be handled at the top of the file.                     */
                   1324: #     define ALIGNMENT 4
                   1325: #     define OS_TYPE "NETBSD"
                   1326: #     define HEURISTIC2
1.6       noro     1327: #     define USE_GENERIC_PUSH_REGS
1.3       noro     1328: #     ifdef __ELF__
1.6       noro     1329:         extern int etext[];
1.3       noro     1330: #       define DATASTART GC_data_start
                   1331: #       define NEED_FIND_LIMIT
                   1332: #       define DYNAMIC_LOADING
                   1333: #     else
                   1334: #       define DATASTART ((ptr_t) 0x10000000)
                   1335: #       define STACKBOTTOM ((ptr_t) 0x7ffff000)
                   1336: #     endif /* _ELF_ */
                   1337: #  endif
1.1       noro     1338: # endif
                   1339:
                   1340: # ifdef RS6000
                   1341: #   define MACH_TYPE "RS6000"
1.9       noro     1342: #   ifdef ALIGNMENT
                   1343: #     undef ALIGNMENT
                   1344: #   endif
                   1345: #   ifdef IA64
                   1346: #     undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
                   1347: #   endif
1.6       noro     1348: #   ifdef __64BIT__
                   1349: #     define ALIGNMENT 8
                   1350: #     define CPP_WORDSZ 64
1.9       noro     1351: #     define STACKBOTTOM ((ptr_t)0x1000000000000000)
1.6       noro     1352: #   else
                   1353: #     define ALIGNMENT 4
                   1354: #     define CPP_WORDSZ 32
                   1355: #     define STACKBOTTOM ((ptr_t)((ulong)&errno))
                   1356: #   endif
1.9       noro     1357:  /* From AIX linker man page:
                   1358:  _text Specifies the first location of the program.
                   1359:  _etext Specifies the first location after the program.
                   1360:  _data Specifies the first location of the data.
                   1361:  _edata Specifies the first location after the initialized data
                   1362:  _end or end Specifies the first location after all data.
                   1363:  */
1.6       noro     1364:     extern int _data[], _end[];
                   1365: #   define DATASTART ((ptr_t)((ulong)_data))
                   1366: #   define DATAEND ((ptr_t)((ulong)_end))
1.1       noro     1367:     extern int errno;
1.6       noro     1368: #   define USE_GENERIC_PUSH_REGS
1.1       noro     1369: #   define DYNAMIC_LOADING
                   1370:        /* For really old versions of AIX, this may have to be removed. */
                   1371: # endif
                   1372:
                   1373: # ifdef HP_PA
                   1374: #   define MACH_TYPE "HP_PA"
1.3       noro     1375: #   ifdef __LP64__
                   1376: #     define CPP_WORDSZ 64
                   1377: #     define ALIGNMENT 8
                   1378: #   else
                   1379: #     define CPP_WORDSZ 32
                   1380: #     define ALIGNMENT 4
                   1381: #     define ALIGN_DOUBLE
                   1382: #   endif
1.6       noro     1383: #   if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1.3       noro     1384: #     ifndef LINUX /* For now. */
                   1385: #       define MPROTECT_VDB
                   1386: #     endif
                   1387: #   else
                   1388: #     define GENERIC_COMPARE_AND_SWAP
                   1389:        /* No compare-and-swap instruction.  Use pthread mutexes        */
                   1390:        /* when we absolutely have to.                                  */
                   1391: #     ifdef PARALLEL_MARK
                   1392: #      define USE_MARK_BYTES
                   1393:                /* Minimize compare-and-swap usage.             */
                   1394: #     endif
                   1395: #   endif
                   1396: #   define STACK_GROWS_UP
                   1397: #   ifdef HPUX
1.6       noro     1398: #     define OS_TYPE "HPUX"
                   1399:       extern int __data_start[];
                   1400: #     define DATASTART ((ptr_t)(__data_start))
1.3       noro     1401: #     if 0
1.1       noro     1402:        /* The following appears to work for 7xx systems running HP/UX  */
                   1403:        /* 9.xx Furthermore, it might result in much faster             */
                   1404:        /* collections than HEURISTIC2, which may involve scanning      */
                   1405:        /* segments that directly precede the stack.  It is not the     */
                   1406:        /* default, since it may not work on older machine/OS           */
                   1407:        /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
                   1408:        /* this.)                                                       */
                   1409: #       define STACKBOTTOM ((ptr_t) 0x7b033000)  /* from /etc/conf/h/param.h */
1.3       noro     1410: #     else
                   1411:        /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
                   1412:        /* to this.  Note that the GC must be initialized before the    */
                   1413:        /* first putenv call.                                           */
                   1414:        extern char ** environ;
                   1415: #       define STACKBOTTOM ((ptr_t)environ)
                   1416: #     endif
                   1417: #     define DYNAMIC_LOADING
                   1418: #     include <unistd.h>
                   1419: #     define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
                   1420: #     ifndef __GNUC__
                   1421: #       define PREFETCH(x)  { \
                   1422:                               register long addr = (long)(x); \
                   1423:                               (void) _asm ("LDW", 0, 0, addr, 0); \
                   1424:                             }
                   1425: #     endif
                   1426: #   endif /* HPUX */
                   1427: #   ifdef LINUX
                   1428: #     define OS_TYPE "LINUX"
                   1429: #     define LINUX_STACKBOTTOM
                   1430: #     define DYNAMIC_LOADING
1.6       noro     1431: #     define SEARCH_FOR_DATA_START
                   1432:       extern int _end[];
1.3       noro     1433: #     define DATAEND (&_end)
                   1434: #   endif /* LINUX */
                   1435: # endif /* HP_PA */
1.1       noro     1436:
                   1437: # ifdef ALPHA
                   1438: #   define MACH_TYPE "ALPHA"
                   1439: #   define ALIGNMENT 8
1.9       noro     1440: #   define CPP_WORDSZ 64
1.6       noro     1441: #   ifndef LINUX
                   1442: #     define USE_GENERIC_PUSH_REGS
                   1443:       /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
                   1444:       /* fp registers in some cases when the target is a 21264.  The assembly */
                   1445:       /* code doesn't handle that yet, and version dependencies make that a   */
                   1446:       /* bit tricky.  Do the easy thing for now.                                   */
                   1447: #   endif
1.3       noro     1448: #   ifdef NETBSD
                   1449: #      define OS_TYPE "NETBSD"
                   1450: #      define HEURISTIC2
                   1451: #      define DATASTART GC_data_start
                   1452: #      define ELFCLASS32 32
                   1453: #      define ELFCLASS64 64
                   1454: #      define ELF_CLASS ELFCLASS64
                   1455: #       define DYNAMIC_LOADING
                   1456: #   endif
1.6       noro     1457: #   ifdef OPENBSD
                   1458: #      define OS_TYPE "OPENBSD"
                   1459: #      define HEURISTIC2
                   1460: #      ifdef __ELF__   /* since OpenBSD/Alpha 2.9 */
                   1461: #         define DATASTART GC_data_start
                   1462: #         define ELFCLASS32 32
                   1463: #         define ELFCLASS64 64
                   1464: #         define ELF_CLASS ELFCLASS64
                   1465: #       else           /* ECOFF, until OpenBSD/Alpha 2.7 */
                   1466: #         define DATASTART ((ptr_t) 0x140000000)
                   1467: #      endif
                   1468: #   endif
                   1469: #   ifdef FREEBSD
                   1470: #      define OS_TYPE "FREEBSD"
                   1471: /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
                   1472: #      define SIG_SUSPEND SIGUSR1
                   1473: #      define SIG_THR_RESTART SIGUSR2
                   1474: #      define FREEBSD_STACKBOTTOM
                   1475: #      ifdef __ELF__
                   1476: #          define DYNAMIC_LOADING
                   1477: #      endif
                   1478: /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
                   1479:        extern char etext[];
                   1480:        extern char edata[];
                   1481:        extern char end[];
                   1482: #      define NEED_FIND_LIMIT
                   1483: #      define DATASTART ((ptr_t)(&etext))
                   1484: #      define DATAEND (GC_find_limit (DATASTART, TRUE))
                   1485: #      define DATASTART2 ((ptr_t)(&edata))
                   1486: #      define DATAEND2 ((ptr_t)(&end))
                   1487: #   endif
1.1       noro     1488: #   ifdef OSF1
                   1489: #      define OS_TYPE "OSF1"
                   1490: #      define DATASTART ((ptr_t) 0x140000000)
1.6       noro     1491:        extern int _end[];
1.1       noro     1492: #      define DATAEND ((ptr_t) &_end)
1.3       noro     1493:        extern char ** environ;
                   1494:        /* round up from the value of environ to the nearest page boundary */
                   1495:        /* Probably breaks if putenv is called before collector            */
                   1496:        /* initialization.                                                 */
                   1497: #      define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
                   1498: /* #           define HEURISTIC2 */
1.1       noro     1499:        /* Normally HEURISTIC2 is too conervative, since                */
                   1500:        /* the text segment immediately follows the stack.              */
                   1501:        /* Hence we give an upper pound.                                */
1.3       noro     1502:        /* This is currently unused, since we disabled HEURISTIC2       */
1.6       noro     1503:        extern int __start[];
                   1504: #      define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1.9       noro     1505: #      ifndef GC_OSF1_THREADS
                   1506:          /* Unresolved signal issues with threads.     */
                   1507: #        define MPROTECT_VDB
                   1508: #       endif
1.1       noro     1509: #      define DYNAMIC_LOADING
                   1510: #   endif
                   1511: #   ifdef LINUX
                   1512: #       define OS_TYPE "LINUX"
                   1513: #       define STACKBOTTOM ((ptr_t) 0x120000000)
                   1514: #       ifdef __ELF__
1.3       noro     1515: #        define SEARCH_FOR_DATA_START
1.1       noro     1516: #         define DYNAMIC_LOADING
                   1517: #       else
                   1518: #           define DATASTART ((ptr_t) 0x140000000)
                   1519: #       endif
1.6       noro     1520:        extern int _end[];
                   1521: #      define DATAEND (_end)
1.1       noro     1522: #      define MPROTECT_VDB
                   1523:                /* Has only been superficially tested.  May not */
                   1524:                /* work on all versions.                        */
                   1525: #   endif
                   1526: # endif
                   1527:
1.3       noro     1528: # ifdef IA64
                   1529: #   define MACH_TYPE "IA64"
                   1530: #   define USE_GENERIC_PUSH_REGS
                   1531:        /* We need to get preserved registers in addition to register   */
                   1532:        /* windows.   That's easiest to do with setjmp.                 */
                   1533: #   ifdef PARALLEL_MARK
                   1534: #      define USE_MARK_BYTES
                   1535:            /* Compare-and-exchange is too expensive to use for         */
                   1536:            /* setting mark bits.                                       */
                   1537: #   endif
                   1538: #   ifdef HPUX
1.6       noro     1539: #      ifdef _ILP32
                   1540: #        define CPP_WORDSZ 32
                   1541: #         define ALIGN_DOUBLE
                   1542:            /* Requires 8 byte alignment for malloc */
                   1543: #        define ALIGNMENT 4
                   1544: #       else
                   1545: #        ifndef _LP64
                   1546:                ---> unknown ABI
                   1547: #         endif
                   1548: #        define CPP_WORDSZ 64
                   1549: #        define ALIGN_DOUBLE
                   1550:            /* Requires 16 byte alignment for malloc */
                   1551: #         define ALIGNMENT 8
                   1552: #       endif
                   1553: #       define OS_TYPE "HPUX"
                   1554:         extern int __data_start[];
                   1555: #       define DATASTART ((ptr_t)(__data_start))
                   1556:         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2      */
                   1557:         /* to this.  Note that the GC must be initialized before the   */
                   1558:        /* first putenv call.                                           */
                   1559:        extern char ** environ;
                   1560: #       define STACKBOTTOM ((ptr_t)environ)
                   1561: #       define DYNAMIC_LOADING
                   1562: #       include <unistd.h>
                   1563: #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
                   1564:        /* The following was empirically determined, and is probably    */
                   1565:        /* not very robust.                                             */
                   1566:        /* Note that the backing store base seems to be at a nice       */
                   1567:        /* address minus one page.                                      */
                   1568: #      define BACKING_STORE_DISPLACEMENT 0x1000000
                   1569: #      define BACKING_STORE_ALIGNMENT 0x1000
                   1570: #       define BACKING_STORE_BASE \
                   1571:          (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
                   1572:                        & ~(BACKING_STORE_ALIGNMENT - 1))
1.3       noro     1573: #   endif
                   1574: #   ifdef LINUX
1.6       noro     1575: #      define CPP_WORDSZ 64
                   1576: #      define ALIGN_DOUBLE
                   1577:          /* Requires 16 byte alignment for malloc */
                   1578: #      define ALIGNMENT 8
1.3       noro     1579: #       define OS_TYPE "LINUX"
                   1580:        /* The following works on NUE and older kernels:        */
                   1581: /* #       define STACKBOTTOM ((ptr_t) 0xa000000000000000l)    */
                   1582:        /* This does not work on NUE:                           */
                   1583: #       define LINUX_STACKBOTTOM
                   1584:        /* We also need the base address of the register stack  */
                   1585:        /* backing store.  This is computed in                  */
                   1586:        /* GC_linux_register_stack_base based on the following  */
                   1587:        /* constants:                                           */
                   1588: #       define BACKING_STORE_ALIGNMENT 0x100000
                   1589: #       define BACKING_STORE_DISPLACEMENT 0x80000000
                   1590:        extern char * GC_register_stackbottom;
                   1591: #      define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
                   1592: #      define SEARCH_FOR_DATA_START
1.6       noro     1593: #      ifdef __GNUC__
                   1594: #         define DYNAMIC_LOADING
                   1595: #      else
                   1596:          /* In the Intel compiler environment, we seem to end up with  */
                   1597:          /* statically linked executables and an undefined reference   */
                   1598:          /* to _DYNAMIC                                                */
                   1599: #      endif
1.3       noro     1600: #      define MPROTECT_VDB
                   1601:                /* Requires Linux 2.3.47 or later.      */
1.6       noro     1602:        extern int _end[];
                   1603: #      define DATAEND (_end)
1.3       noro     1604: #       ifdef __GNUC__
                   1605: #        define PREFETCH(x) \
                   1606:            __asm__ ("  lfetch  [%0]": : "r"((void *)(x)))
                   1607: #        define PREFETCH_FOR_WRITE(x) \
                   1608:            __asm__ ("  lfetch.excl     [%0]": : "r"((void *)(x)))
                   1609: #        define CLEAR_DOUBLE(x) \
                   1610:            __asm__ ("  stf.spill       [%0]=f0": : "r"((void *)(x)))
                   1611: #       endif
                   1612: #   endif
                   1613: # endif
                   1614:
1.1       noro     1615: # ifdef M88K
                   1616: #   define MACH_TYPE "M88K"
                   1617: #   define ALIGNMENT 4
                   1618: #   define ALIGN_DOUBLE
1.6       noro     1619:     extern int etext[];
1.1       noro     1620: #   ifdef CX_UX
                   1621: #      define OS_TYPE "CX_UX"
1.6       noro     1622: #       define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1.1       noro     1623: #   endif
                   1624: #   ifdef  DGUX
                   1625: #      define OS_TYPE "DGUX"
1.9       noro     1626:        extern ptr_t GC_SysVGetDataStart();
                   1627: #       define DATASTART GC_SysVGetDataStart(0x10000, etext)
1.1       noro     1628: #   endif
                   1629: #   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
                   1630: # endif
                   1631:
                   1632: # ifdef S370
1.9       noro     1633:     /* If this still works, and if anyone cares, this should probably  */
                   1634:     /* be moved to the S390 category.                                  */
1.1       noro     1635: #   define MACH_TYPE "S370"
                   1636: #   define ALIGNMENT 4 /* Required by hardware */
1.3       noro     1637: #   define USE_GENERIC_PUSH_REGS
                   1638: #   ifdef UTS4
                   1639: #       define OS_TYPE "UTS4"
1.6       noro     1640:         extern int etext[];
                   1641:        extern int _etext[];
                   1642:        extern int _end[];
1.9       noro     1643:        extern ptr_t GC_SysVGetDataStart();
                   1644: #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1.6       noro     1645: #      define DATAEND (_end)
1.1       noro     1646: #      define HEURISTIC2
1.3       noro     1647: #   endif
1.9       noro     1648: # endif
                   1649:
                   1650: # ifdef S390
                   1651: #   define MACH_TYPE "S390"
                   1652: #   define USE_GENERIC_PUSH_REGS
                   1653: #   ifndef __s390x__
                   1654: #   define ALIGNMENT 4
                   1655: #   define CPP_WORDSZ 32
                   1656: #   else
                   1657: #   define ALIGNMENT 8
                   1658: #   define CPP_WORDSZ 64
                   1659: #   define HBLKSIZE 4096
                   1660: #   endif
1.3       noro     1661: #   ifdef LINUX
                   1662: #       define OS_TYPE "LINUX"
1.9       noro     1663: #       define LINUX_STACKBOTTOM
1.3       noro     1664: #       define DYNAMIC_LOADING
1.6       noro     1665:         extern int __data_start[];
                   1666: #       define DATASTART ((ptr_t)(__data_start))
1.9       noro     1667:     extern int _end[];
                   1668: #   define DATAEND (_end)
                   1669: #   define CACHE_LINE_SIZE 256
                   1670: #   define GETPAGESIZE() 4096
1.3       noro     1671: #   endif
                   1672: # endif
                   1673:
                   1674: # if defined(PJ)
                   1675: #   define ALIGNMENT 4
1.6       noro     1676:     extern int _etext[];
                   1677: #   define DATASTART ((ptr_t)(_etext))
1.3       noro     1678: #   define HEURISTIC1
1.1       noro     1679: # endif
                   1680:
1.3       noro     1681: # ifdef ARM32
                   1682: #   define CPP_WORDSZ 32
                   1683: #   define MACH_TYPE "ARM32"
                   1684: #   define ALIGNMENT 4
                   1685: #   ifdef NETBSD
                   1686: #       define OS_TYPE "NETBSD"
                   1687: #       define HEURISTIC2
1.6       noro     1688:         extern char etext[];
                   1689: #       define DATASTART ((ptr_t)(etext))
1.3       noro     1690: #       define USE_GENERIC_PUSH_REGS
                   1691: #   endif
                   1692: #   ifdef LINUX
                   1693: #       define OS_TYPE "LINUX"
                   1694: #       define HEURISTIC1
                   1695: #       undef STACK_GRAN
                   1696: #       define STACK_GRAN 0x10000000
                   1697: #       define USE_GENERIC_PUSH_REGS
                   1698: #       ifdef __ELF__
                   1699: #            define DYNAMIC_LOADING
                   1700: #           include <features.h>
                   1701: #           if defined(__GLIBC__) && __GLIBC__ >= 2
1.9       noro     1702: #               define SEARCH_FOR_DATA_START
1.3       noro     1703: #           else
                   1704:                 extern char **__environ;
                   1705: #                define DATASTART ((ptr_t)(&__environ))
                   1706:                              /* hideous kludge: __environ is the first */
                   1707:                              /* word in crt0.o, and delimits the start */
                   1708:                              /* of the data segment, no matter which   */
                   1709:                              /* ld options were passed through.        */
                   1710:                              /* We could use _etext instead, but that  */
                   1711:                              /* would include .rodata, which may       */
                   1712:                              /* contain large read-only data tables    */
                   1713:                              /* that we'd rather not scan.             */
                   1714: #           endif
1.6       noro     1715:             extern int _end[];
                   1716: #           define DATAEND (_end)
1.3       noro     1717: #      else
1.6       noro     1718:             extern int etext[];
                   1719: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1.3       noro     1720: #       endif
                   1721: #   endif
                   1722: #   ifdef MSWINCE
                   1723: #     define OS_TYPE "MSWINCE"
                   1724: #     define DATAEND /* not needed */
                   1725: #   endif
1.6       noro     1726: #   ifdef NOSYS
                   1727:       /* __data_start is usually defined in the target linker script.  */
                   1728:       extern int __data_start[];
                   1729: #     define DATASTART (ptr_t)(__data_start)
                   1730: #     define USE_GENERIC_PUSH_REGS
                   1731:       /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S  */
                   1732:       extern void *__stack_base__;
                   1733: #     define STACKBOTTOM ((ptr_t) (__stack_base__))
                   1734: #   endif
1.3       noro     1735: #endif
                   1736:
                   1737: # ifdef SH
                   1738: #   define MACH_TYPE "SH"
                   1739: #   define ALIGNMENT 4
                   1740: #   ifdef MSWINCE
                   1741: #     define OS_TYPE "MSWINCE"
                   1742: #     define DATAEND /* not needed */
                   1743: #   endif
                   1744: #   ifdef LINUX
                   1745: #     define OS_TYPE "LINUX"
                   1746: #     define STACKBOTTOM ((ptr_t) 0x7c000000)
                   1747: #     define USE_GENERIC_PUSH_REGS
                   1748: #     define DYNAMIC_LOADING
1.9       noro     1749: #     define SEARCH_FOR_DATA_START
1.6       noro     1750:       extern int _end[];
                   1751: #     define DATAEND (_end)
1.3       noro     1752: #   endif
                   1753: # endif
                   1754:
                   1755: # ifdef SH4
                   1756: #   define MACH_TYPE "SH4"
                   1757: #   define OS_TYPE "MSWINCE"
                   1758: #   define ALIGNMENT 4
                   1759: #   define DATAEND /* not needed */
                   1760: # endif
                   1761:
1.9       noro     1762: # ifdef X86_64
                   1763: #   define MACH_TYPE "X86_64"
                   1764: #   define ALIGNMENT 8
                   1765: #   define CPP_WORDSZ 64
                   1766: #   ifndef HBLKSIZE
                   1767: #     define HBLKSIZE 4096
                   1768: #   endif
                   1769: #   define CACHE_LINE_SIZE 64
                   1770: #   define USE_GENERIC_PUSH_REGS
                   1771: #   ifdef LINUX
                   1772: #      define OS_TYPE "LINUX"
                   1773: #       define LINUX_STACKBOTTOM
                   1774: #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
                   1775: #          define MPROTECT_VDB
                   1776: #      else
                   1777:            /* We seem to get random errors in incremental mode,        */
                   1778:            /* possibly because Linux threads is itself a malloc client */
                   1779:            /* and can't deal with the signals.                         */
                   1780: #      endif
                   1781: #       ifdef __ELF__
                   1782: #            define DYNAMIC_LOADING
                   1783: #           ifdef UNDEFINED    /* includes ro data */
                   1784:               extern int _etext[];
                   1785: #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
                   1786: #           endif
                   1787: #           include <features.h>
                   1788: #           define SEARCH_FOR_DATA_START
                   1789:             extern int _end[];
                   1790: #           define DATAEND (_end)
                   1791: #      else
                   1792:             extern int etext[];
                   1793: #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
                   1794: #       endif
                   1795: #      define PREFETCH(x) \
                   1796:          __asm__ __volatile__ ("       prefetch        %0": : "m"(*(char *)(x)))
                   1797: #      define PREFETCH_FOR_WRITE(x) \
                   1798:          __asm__ __volatile__ ("       prefetchw       %0": : "m"(*(char *)(x)))
                   1799: #   endif
                   1800: # endif
1.3       noro     1801:
                   1802: #if defined(LINUX) && defined(REDIRECT_MALLOC)
                   1803:     /* Rld appears to allocate some memory with its own allocator, and */
                   1804:     /* some through malloc, which might be redirected.  To make this   */
                   1805:     /* work with collectable memory, we have to scan memory allocated  */
                   1806:     /* by rld's internal malloc.                                       */
                   1807: #   define USE_PROC_FOR_LIBRARIES
                   1808: #endif
                   1809:
1.1       noro     1810: # ifndef STACK_GROWS_UP
                   1811: #   define STACK_GROWS_DOWN
                   1812: # endif
                   1813:
                   1814: # ifndef CPP_WORDSZ
                   1815: #   define CPP_WORDSZ 32
                   1816: # endif
                   1817:
                   1818: # ifndef OS_TYPE
                   1819: #   define OS_TYPE ""
                   1820: # endif
                   1821:
                   1822: # ifndef DATAEND
1.6       noro     1823:     extern int end[];
                   1824: #   define DATAEND (end)
1.1       noro     1825: # endif
                   1826:
                   1827: # if defined(SVR4) && !defined(GETPAGESIZE)
                   1828: #    include <unistd.h>
                   1829: #    define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
                   1830: # endif
                   1831:
                   1832: # ifndef GETPAGESIZE
                   1833: #   if defined(SUNOS5) || defined(IRIX5)
                   1834: #      include <unistd.h>
                   1835: #   endif
                   1836: #   define GETPAGESIZE() getpagesize()
                   1837: # endif
                   1838:
                   1839: # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1.6       noro     1840:            /* OS has SVR4 generic features.  Probably others also qualify.     */
1.1       noro     1841: #   define SVR4
                   1842: # endif
                   1843:
                   1844: # if defined(SUNOS5) || defined(DRSNX)
1.6       noro     1845:            /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
                   1846:            /* loader.                                                          */
1.1       noro     1847: #   define SUNOS5DL
1.6       noro     1848:            /* OS has SUNOS5 style signal handlers.                             */
1.1       noro     1849: #   define SUNOS5SIGS
                   1850: # endif
                   1851:
1.3       noro     1852: # if defined(HPUX)
                   1853: #   define SUNOS5SIGS
                   1854: # endif
                   1855:
                   1856: # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1.9       noro     1857:            || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
                   1858:            || defined(DGUX) || defined(BSD) \
                   1859:            || defined(_AIX) || defined(DARWIN) || defined(OSF1)
1.3       noro     1860: #   define UNIX_LIKE   /* Basic Unix-like system calls work.   */
                   1861: # endif
                   1862:
1.1       noro     1863: # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1.6       noro     1864:           -> bad word size
1.1       noro     1865: # endif
                   1866:
                   1867: # ifdef PCR
                   1868: #   undef DYNAMIC_LOADING
                   1869: #   undef STACKBOTTOM
                   1870: #   undef HEURISTIC1
                   1871: #   undef HEURISTIC2
                   1872: #   undef PROC_VDB
                   1873: #   undef MPROTECT_VDB
                   1874: #   define PCR_VDB
                   1875: # endif
                   1876:
                   1877: # ifdef SRC_M3
1.6       noro     1878:        /* Postponed for now. */
1.1       noro     1879: #   undef PROC_VDB
                   1880: #   undef MPROTECT_VDB
                   1881: # endif
                   1882:
                   1883: # ifdef SMALL_CONFIG
1.6       noro     1884:        /* Presumably not worth the space it takes. */
1.1       noro     1885: #   undef PROC_VDB
                   1886: #   undef MPROTECT_VDB
                   1887: # endif
                   1888:
                   1889: # ifdef USE_MUNMAP
                   1890: #   undef MPROTECT_VDB  /* Can't deal with address space holes. */
                   1891: # endif
                   1892:
1.3       noro     1893: # ifdef PARALLEL_MARK
                   1894: #   undef MPROTECT_VDB  /* For now.    */
                   1895: # endif
                   1896:
1.1       noro     1897: # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
                   1898: #   define DEFAULT_VDB
                   1899: # endif
                   1900:
1.3       noro     1901: # ifndef PREFETCH
                   1902: #   define PREFETCH(x)
                   1903: #   define NO_PREFETCH
                   1904: # endif
                   1905:
                   1906: # ifndef PREFETCH_FOR_WRITE
                   1907: #   define PREFETCH_FOR_WRITE(x)
                   1908: #   define NO_PREFETCH_FOR_WRITE
                   1909: # endif
                   1910:
                   1911: # ifndef CACHE_LINE_SIZE
                   1912: #   define CACHE_LINE_SIZE 32  /* Wild guess   */
                   1913: # endif
                   1914:
1.9       noro     1915: # ifdef LINUX
                   1916: #   define REGISTER_LIBRARIES_EARLY
                   1917:     /* We sometimes use dl_iterate_phdr, which may acquire an internal */
                   1918:     /* lock.  This isn't safe after the world has stopped.  So we must */
                   1919:     /* call GC_register_dynamic_libraries before stopping the world.   */
                   1920:     /* For performance reasons, this may be beneficial on other                */
                   1921:     /* platforms as well, though it should be avoided in win32.                */
                   1922: # endif /* LINUX */
                   1923:
1.6       noro     1924: # if defined(SEARCH_FOR_DATA_START)
                   1925:     extern ptr_t GC_data_start;
                   1926: #   define DATASTART GC_data_start
                   1927: # endif
                   1928:
1.3       noro     1929: # ifndef CLEAR_DOUBLE
                   1930: #   define CLEAR_DOUBLE(x) \
1.6       noro     1931:                ((word*)x)[0] = 0; \
                   1932:                ((word*)x)[1] = 0;
1.3       noro     1933: # endif /* CLEAR_DOUBLE */
                   1934:
1.6       noro     1935:        /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
                   1936: # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
                   1937: #   define GC_SOLARIS_THREADS
                   1938: # endif
1.3       noro     1939:
1.6       noro     1940: # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
                   1941:        --> inconsistent configuration
1.1       noro     1942: # endif
1.6       noro     1943: # if defined(GC_LINUX_THREADS) && !defined(LINUX)
                   1944:        --> inconsistent configuration
1.1       noro     1945: # endif
1.6       noro     1946: # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
                   1947:        --> inconsistent configuration
1.1       noro     1948: # endif
1.6       noro     1949: # if defined(GC_HPUX_THREADS) && !defined(HPUX)
                   1950:        --> inconsistent configuration
1.1       noro     1951: # endif
1.9       noro     1952: # if defined(GC_AIX_THREADS) && !defined(_AIX)
                   1953:        --> inconsistent configuration
                   1954: # endif
                   1955: # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
1.6       noro     1956:        --> inconsistent configuration
1.1       noro     1957: # endif
1.6       noro     1958:
1.1       noro     1959: # if defined(PCR) || defined(SRC_M3) || \
1.6       noro     1960:                defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
                   1961:                defined(GC_PTHREADS)
1.1       noro     1962: #   define THREADS
                   1963: # endif
                   1964:
1.9       noro     1965: # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(DARWIN) \
1.6       noro     1966:             || defined(LINT) || defined(MSWINCE) || defined(ARM32) \
                   1967:             || (defined(I386) && defined(__LCC__))
1.9       noro     1968:        /* Use setjmp based hack to mark from callee-save registers.    */
                   1969:        /* The define should move to the individual platform            */
                   1970:        /* descriptions.                                                */
1.1       noro     1971: #      define USE_GENERIC_PUSH_REGS
                   1972: # endif
1.6       noro     1973:
                   1974: # if defined(SPARC)
                   1975: #   define ASM_CLEAR_CODE      /* Stack clearing is crucial, and we    */
1.9       noro     1976:                                /* include assembly code to do it well. */
1.6       noro     1977: # endif
                   1978:
1.9       noro     1979:   /* Can we save call chain in objects for debugging?                  */
                   1980:   /* SET NFRAMES (# of saved frames) and NARGS (#of args for each      */
                   1981:   /* frame) to reasonable values for the platform.                     */
                   1982:   /* Set SAVE_CALL_CHAIN if we can.  SAVE_CALL_COUNT can be specified  */
                   1983:   /* at build time, though we feel free to adjust it slightly.         */
                   1984:   /* Define NEED_CALLINFO if we either save the call stack or          */
                   1985:   /* GC_ADD_CALLER is defined.                                         */
                   1986:   /* GC_CAN_SAVE_CALL_STACKS is set in gc.h.                           */
1.6       noro     1987:
                   1988: #if defined(SPARC)
                   1989: # define CAN_SAVE_CALL_ARGS
                   1990: #endif
1.9       noro     1991: #if (defined(I386) || defined(X86_64)) && defined(LINUX)
1.6       noro     1992:            /* SAVE_CALL_CHAIN is supported if the code is compiled to save     */
                   1993:            /* frame pointers by default, i.e. no -fomit-frame-pointer flag.    */
                   1994: # define CAN_SAVE_CALL_ARGS
                   1995: #endif
                   1996:
                   1997: # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
1.9       noro     1998:             && defined(GC_CAN_SAVE_CALL_STACKS)
1.3       noro     1999: #   define SAVE_CALL_CHAIN
                   2000: # endif
1.6       noro     2001: # ifdef SAVE_CALL_CHAIN
                   2002: #   if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
                   2003: #     define NARGS SAVE_CALL_NARGS
                   2004: #   else
                   2005: #     define NARGS 0   /* Number of arguments to save for each call.   */
                   2006: #   endif
1.3       noro     2007: # endif
1.6       noro     2008: # ifdef SAVE_CALL_CHAIN
                   2009: #   ifndef SAVE_CALL_COUNT
                   2010: #     define NFRAMES 6 /* Number of frames to save. Even for           */
                   2011:                                /* alignment reasons.                           */
                   2012: #   else
                   2013: #     define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
                   2014: #   endif
                   2015: #   define NEED_CALLINFO
                   2016: # endif /* SAVE_CALL_CHAIN */
                   2017: # ifdef GC_ADD_CALLER
                   2018: #   define NFRAMES 1
                   2019: #   define NARGS 0
                   2020: #   define NEED_CALLINFO
                   2021: # endif
                   2022:
                   2023: # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
                   2024: #   define DBG_HDRS_ALL
                   2025: # endif
                   2026:
1.9       noro     2027: # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
                   2028: #   define POINTER_SHIFT 0
                   2029: # endif
                   2030:
                   2031: # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
                   2032: #   define POINTER_MASK ((GC_word)(-1))
                   2033: # endif
                   2034:
                   2035: # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
                   2036: #   define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
                   2037: # endif
                   2038:
                   2039: # if defined(FIXUP_POINTER)
                   2040: #   define NEED_FIXUP_POINTER 1
                   2041: # else
                   2042: #   define NEED_FIXUP_POINTER 0
                   2043: #   define FIXUP_POINTER(p)
                   2044: # endif
                   2045:
1.6       noro     2046: #ifdef GC_PRIVATE_H
                   2047:        /* This relies on some type definitions from gc_priv.h, from    */
                   2048:         /* where it's normally included.                               */
                   2049:        /*                                                              */
                   2050:        /* How to get heap memory from the OS:                          */
                   2051:        /* Note that sbrk()-like allocation is preferred, since it      */
                   2052:        /* usually makes it possible to merge consecutively allocated   */
                   2053:        /* chunks.  It also avoids unintented recursion with            */
                   2054:        /* -DREDIRECT_MALLOC.                                           */
                   2055:        /* GET_MEM() returns a HLKSIZE aligned chunk.                   */
                   2056:        /* 0 is taken to mean failure.                                  */
                   2057:        /* In the case os USE_MMAP, the argument must also be a         */
                   2058:        /* physical page size.                                          */
                   2059:        /* GET_MEM is currently not assumed to retrieve 0 filled space, */
                   2060:        /* though we should perhaps take advantage of the case in which */
                   2061:        /* does.                                                        */
                   2062:        struct hblk;    /* See gc_priv.h.       */
                   2063: # ifdef PCR
                   2064:            char * real_malloc();
                   2065: #   define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
                   2066:                                          + GC_page_size-1)
                   2067: # else
                   2068: #   ifdef OS2
                   2069:              void * os2_alloc(size_t bytes);
                   2070: #     define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
                   2071:                                            + GC_page_size) \
                   2072:                                            + GC_page_size-1)
                   2073: #   else
1.9       noro     2074: #     if defined(NEXT) || defined(DOS4GW) || \
1.6       noro     2075:                 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
                   2076:                 (defined(SUNOS5) && !defined(USE_MMAP))
                   2077: #       define GET_MEM(bytes) HBLKPTR((size_t) \
                   2078:                                              calloc(1, (size_t)bytes + GC_page_size) \
                   2079:                                              + GC_page_size-1)
                   2080: #     else
                   2081: #      ifdef MSWIN32
1.9       noro     2082:          extern ptr_t GC_win32_get_mem();
1.6       noro     2083: #         define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
                   2084: #      else
                   2085: #        ifdef MACOS
                   2086: #          if defined(USE_TEMPORARY_MEMORY)
                   2087:                        extern Ptr GC_MacTemporaryNewPtr(size_t size,
                   2088:                                                         Boolean clearMemory);
                   2089: #               define GET_MEM(bytes) HBLKPTR( \
                   2090:                            GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
                   2091:                            + GC_page_size-1)
                   2092: #          else
                   2093: #                  define GET_MEM(bytes) HBLKPTR( \
                   2094:                                NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
                   2095: #          endif
                   2096: #        else
                   2097: #          ifdef MSWINCE
1.9       noro     2098:              extern ptr_t GC_wince_get_mem();
1.6       noro     2099: #            define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
                   2100: #          else
                   2101: #            if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
                   2102:                        extern void *GC_amiga_get_mem(size_t size);
                   2103:                        define GET_MEM(bytes) HBLKPTR((size_t) \
                   2104:                          GC_amiga_get_mem((size_t)bytes + GC_page_size) \
                   2105:                          + GC_page_size-1)
                   2106: #            else
1.9       noro     2107:                extern ptr_t GC_unix_get_mem();
1.6       noro     2108: #               define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
                   2109: #            endif
                   2110: #          endif
                   2111: #        endif
                   2112: #      endif
                   2113: #     endif
                   2114: #   endif
1.1       noro     2115: # endif
1.6       noro     2116:
                   2117: #endif /* GC_PRIVATE_H */
1.1       noro     2118:
1.3       noro     2119: # endif /* GCCONFIG_H */

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