Annotation of OpenXM_contrib2/asir2000/gc/gcconfig.h, Revision 1.1
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.
! 5: *
! 6: * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
! 7: * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
! 8: *
! 9: * Permission is hereby granted to use or copy this program
! 10: * for any purpose, provided the above notices are retained on all copies.
! 11: * Permission to modify the code and to distribute modified code is granted,
! 12: * provided the above notices are retained, and a notice that the code was
! 13: * modified is included with the above copyright notice.
! 14: */
! 15:
! 16: #ifndef CONFIG_H
! 17:
! 18: # define CONFIG_H
! 19:
! 20: /* Machine dependent parameters. Some tuning parameters can be found */
! 21: /* near the top of gc_private.h. */
! 22:
! 23: /* Machine specific parts contributed by various people. See README file. */
! 24:
! 25: /* First a unified test for Linux: */
! 26: # if defined(linux) || defined(__linux__)
! 27: # define LINUX
! 28: # endif
! 29:
! 30: /* Determine the machine type: */
! 31: # if defined(sun) && defined(mc68000)
! 32: # define M68K
! 33: # define SUNOS4
! 34: # define mach_type_known
! 35: # endif
! 36: # if defined(hp9000s300)
! 37: # define M68K
! 38: # define HP
! 39: # define mach_type_known
! 40: # endif
! 41: # if defined(__OpenBSD__) && defined(m68k)
! 42: # define M68K
! 43: # define OPENBSD
! 44: # define mach_type_known
! 45: # endif
! 46: # if defined(__OpenBSD__) && defined(__sparc__)
! 47: # define SPARC
! 48: # define OPENBSD
! 49: # define mach_type_known
! 50: # endif
! 51: # if defined(__NetBSD__) && defined(m68k)
! 52: # define M68K
! 53: # define NETBSD
! 54: # define mach_type_known
! 55: # endif
! 56: # if defined(vax)
! 57: # define VAX
! 58: # ifdef ultrix
! 59: # define ULTRIX
! 60: # else
! 61: # define BSD
! 62: # endif
! 63: # define mach_type_known
! 64: # endif
! 65: # if defined(mips) || defined(__mips)
! 66: # define MIPS
! 67: # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
! 68: # define ULTRIX
! 69: # else
! 70: # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__)
! 71: # define IRIX5 /* or IRIX 6.X */
! 72: # else
! 73: # define RISCOS /* or IRIX 4.X */
! 74: # endif
! 75: # endif
! 76: # define mach_type_known
! 77: # endif
! 78: # if defined(sequent) && defined(i386)
! 79: # define I386
! 80: # define SEQUENT
! 81: # define mach_type_known
! 82: # endif
! 83: # if defined(sun) && defined(i386)
! 84: # define I386
! 85: # define SUNOS5
! 86: # define mach_type_known
! 87: # endif
! 88: # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
! 89: # define I386
! 90: # define OS2
! 91: # define mach_type_known
! 92: # endif
! 93: # if defined(ibm032)
! 94: # define RT
! 95: # define mach_type_known
! 96: # endif
! 97: # if defined(sun) && (defined(sparc) || defined(__sparc))
! 98: # define SPARC
! 99: /* Test for SunOS 5.x */
! 100: # include <errno.h>
! 101: # ifdef ECHRNG
! 102: # define SUNOS5
! 103: # else
! 104: # define SUNOS4
! 105: # endif
! 106: # define mach_type_known
! 107: # endif
! 108: # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
! 109: && !defined(__OpenBSD__)
! 110: # define SPARC
! 111: # define DRSNX
! 112: # define mach_type_known
! 113: # endif
! 114: # if defined(_IBMR2)
! 115: # define RS6000
! 116: # define mach_type_known
! 117: # endif
! 118: # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
! 119: /* The above test may need refinement */
! 120: # define I386
! 121: # if defined(_SCO_ELF)
! 122: # define SCO_ELF
! 123: # else
! 124: # define SCO
! 125: # endif
! 126: # define mach_type_known
! 127: # endif
! 128: # if defined(_AUX_SOURCE)
! 129: # define M68K
! 130: # define SYSV
! 131: # define mach_type_known
! 132: # endif
! 133: # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) \
! 134: || defined(hppa) || defined(__hppa__)
! 135: # define HP_PA
! 136: # define mach_type_known
! 137: # endif
! 138: # if defined(LINUX) && (defined(i386) || defined(__i386__))
! 139: # define I386
! 140: # define mach_type_known
! 141: # endif
! 142: # if defined(LINUX) && defined(powerpc)
! 143: # define POWERPC
! 144: # define mach_type_known
! 145: # endif
! 146: # if defined(LINUX) && defined(__mc68000__)
! 147: # define M68K
! 148: # define mach_type_known
! 149: # endif
! 150: # if defined(linux) && defined(sparc)
! 151: # define SPARC
! 152: # define LINUX
! 153: # define mach_type_known
! 154: # endif
! 155: # if defined(__alpha) || defined(__alpha__)
! 156: # define ALPHA
! 157: # if !defined(LINUX)
! 158: # define OSF1 /* a.k.a Digital Unix */
! 159: # endif
! 160: # define mach_type_known
! 161: # endif
! 162: # if defined(_AMIGA) && !defined(AMIGA)
! 163: # define AMIGA
! 164: # endif
! 165: # ifdef AMIGA
! 166: # define M68K
! 167: # define mach_type_known
! 168: # endif
! 169: # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
! 170: # define M68K
! 171: # define MACOS
! 172: # define mach_type_known
! 173: # endif
! 174: # if defined(__MWERKS__) && defined(__powerc)
! 175: # define POWERPC
! 176: # define MACOS
! 177: # define mach_type_known
! 178: # endif
! 179: # if defined(macosx)
! 180: # define MACOSX
! 181: # define POWERPC
! 182: # define mach_type_known
! 183: # endif
! 184: # if defined(NeXT) && defined(mc68000)
! 185: # define M68K
! 186: # define NEXT
! 187: # define mach_type_known
! 188: # endif
! 189: # if defined(NeXT) && defined(i386)
! 190: # define I386
! 191: # define NEXT
! 192: # define mach_type_known
! 193: # endif
! 194: # if defined(__OpenBSD__) && defined(i386)
! 195: # define I386
! 196: # define OPENBSD
! 197: # define mach_type_known
! 198: # endif
! 199: # if defined(__FreeBSD__) && defined(i386)
! 200: # define I386
! 201: # define FREEBSD
! 202: # define mach_type_known
! 203: # endif
! 204: # if defined(__NetBSD__) && defined(i386)
! 205: # define I386
! 206: # define NETBSD
! 207: # define mach_type_known
! 208: # endif
! 209: # if defined(bsdi) && defined(i386)
! 210: # define I386
! 211: # define BSDI
! 212: # define mach_type_known
! 213: # endif
! 214: # if !defined(mach_type_known) && defined(__386BSD__)
! 215: # define I386
! 216: # define THREE86BSD
! 217: # define mach_type_known
! 218: # endif
! 219: # if defined(_CX_UX) && defined(_M88K)
! 220: # define M88K
! 221: # define CX_UX
! 222: # define mach_type_known
! 223: # endif
! 224: # if defined(DGUX)
! 225: # define M88K
! 226: /* DGUX defined */
! 227: # define mach_type_known
! 228: # endif
! 229: # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
! 230: || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
! 231: # define I386
! 232: # define MSWIN32 /* or Win32s */
! 233: # define mach_type_known
! 234: # endif
! 235: # if defined(__DJGPP__)
! 236: # define I386
! 237: # ifndef DJGPP
! 238: # define DJGPP /* MSDOS running the DJGPP port of GCC */
! 239: # endif
! 240: # define mach_type_known
! 241: # endif
! 242: # if defined(__CYGWIN32__) || defined(__CYGWIN__)
! 243: # define I386
! 244: # define CYGWIN32
! 245: # define mach_type_known
! 246: # endif
! 247: # if defined(__BORLANDC__)
! 248: # define I386
! 249: # define MSWIN32
! 250: # define mach_type_known
! 251: # endif
! 252: # if defined(_UTS) && !defined(mach_type_known)
! 253: # define S370
! 254: # define UTS4
! 255: # define mach_type_known
! 256: # endif
! 257: /* Ivan Demakov */
! 258: # if defined(__WATCOMC__) && defined(__386__)
! 259: # define I386
! 260: # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
! 261: # if defined(__OS2__)
! 262: # define OS2
! 263: # else
! 264: # if defined(__WINDOWS_386__) || defined(__NT__)
! 265: # define MSWIN32
! 266: # else
! 267: # define DOS4GW
! 268: # endif
! 269: # endif
! 270: # endif
! 271: # define mach_type_known
! 272: # endif
! 273:
! 274: /* Feel free to add more clauses here */
! 275:
! 276: /* Or manually define the machine type here. A machine type is */
! 277: /* characterized by the architecture. Some */
! 278: /* machine types are further subdivided by OS. */
! 279: /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
! 280: /* Note that SGI IRIX is treated identically to RISCOS. */
! 281: /* SYSV on an M68K actually means A/UX. */
! 282: /* The distinction in these cases is usually the stack starting address */
! 283: # ifndef mach_type_known
! 284: --> unknown machine type
! 285: # endif
! 286: /* Mapping is: M68K ==> Motorola 680X0 */
! 287: /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
! 288: /* MACOS and AMIGA variants) */
! 289: /* I386 ==> Intel 386 */
! 290: /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
! 291: /* FREEBSD, THREE86BSD, MSWIN32, */
! 292: /* BSDI,SUNOS5, NEXT, other variants) */
! 293: /* NS32K ==> Encore Multimax */
! 294: /* MIPS ==> R2000 or R3000 */
! 295: /* (RISCOS, ULTRIX variants) */
! 296: /* VAX ==> DEC VAX */
! 297: /* (BSD, ULTRIX variants) */
! 298: /* RS6000 ==> IBM RS/6000 AIX3.X */
! 299: /* RT ==> IBM PC/RT */
! 300: /* HP_PA ==> HP9000/700 & /800 */
! 301: /* HP/UX */
! 302: /* SPARC ==> SPARC under SunOS */
! 303: /* (SUNOS4, SUNOS5, */
! 304: /* DRSNX variants) */
! 305: /* ALPHA ==> DEC Alpha */
! 306: /* (OSF1 and LINUX variants) */
! 307: /* M88K ==> Motorola 88XX0 */
! 308: /* (CX_UX and DGUX) */
! 309: /* S370 ==> 370-like machine */
! 310: /* running Amdahl UTS4 */
! 311:
! 312:
! 313: /*
! 314: * For each architecture and OS, the following need to be defined:
! 315: *
! 316: * CPP_WORD_SZ is a simple integer constant representing the word size.
! 317: * in bits. We assume byte addressibility, where a byte has 8 bits.
! 318: * We also assume CPP_WORD_SZ is either 32 or 64.
! 319: * (We care about the length of pointers, not hardware
! 320: * bus widths. Thus a 64 bit processor with a C compiler that uses
! 321: * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
! 322: *
! 323: * MACH_TYPE is a string representation of the machine type.
! 324: * OS_TYPE is analogous for the OS.
! 325: *
! 326: * ALIGNMENT is the largest N, such that
! 327: * all pointer are guaranteed to be aligned on N byte boundaries.
! 328: * defining it to be 1 will always work, but perform poorly.
! 329: *
! 330: * DATASTART is the beginning of the data segment.
! 331: * On UNIX systems, the collector will scan the area between DATASTART
! 332: * and DATAEND for root pointers.
! 333: *
! 334: * DATAEND, if not &end.
! 335: *
! 336: * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
! 337: * the pointer size.
! 338: *
! 339: * STACKBOTTOM is the cool end of the stack, which is usually the
! 340: * highest address in the stack.
! 341: * Under PCR or OS/2, we have other ways of finding thread stacks.
! 342: * For each machine, the following should:
! 343: * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
! 344: * 2) define exactly one of
! 345: * STACKBOTTOM (should be defined to be an expression)
! 346: * HEURISTIC1
! 347: * HEURISTIC2
! 348: * If either of the last two macros are defined, then STACKBOTTOM is computed
! 349: * during collector startup using one of the following two heuristics:
! 350: * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
! 351: * the next multiple of STACK_GRAN.
! 352: * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
! 353: * in small steps (decrement if STACK_GROWS_UP), and read the value
! 354: * at each location. Remember the value when the first
! 355: * Segmentation violation or Bus error is signalled. Round that
! 356: * to the nearest plausible page boundary, and use that instead
! 357: * of STACKBOTTOM.
! 358: *
! 359: * If no expression for STACKBOTTOM can be found, and neither of the above
! 360: * heuristics are usable, the collector can still be used with all of the above
! 361: * undefined, provided one of the following is done:
! 362: * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
! 363: * without reference to STACKBOTTOM. This is appropriate for use in
! 364: * conjunction with thread packages, since there will be multiple stacks.
! 365: * (Allocating thread stacks in the heap, and treating them as ordinary
! 366: * heap data objects is also possible as a last resort. However, this is
! 367: * likely to introduce significant amounts of excess storage retention
! 368: * unless the dead parts of the thread stacks are periodically cleared.)
! 369: * 2) Client code may set GC_stackbottom before calling any GC_ routines.
! 370: * If the author of the client code controls the main program, this is
! 371: * easily accomplished by introducing a new main program, setting
! 372: * GC_stackbottom to the address of a local variable, and then calling
! 373: * the original main program. The new main program would read something
! 374: * like:
! 375: *
! 376: * # include "gc_private.h"
! 377: *
! 378: * main(argc, argv, envp)
! 379: * int argc;
! 380: * char **argv, **envp;
! 381: * {
! 382: * int dummy;
! 383: *
! 384: * GC_stackbottom = (ptr_t)(&dummy);
! 385: * return(real_main(argc, argv, envp));
! 386: * }
! 387: *
! 388: *
! 389: * Each architecture may also define the style of virtual dirty bit
! 390: * implementation to be used:
! 391: * MPROTECT_VDB: Write protect the heap and catch faults.
! 392: * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
! 393: *
! 394: * An architecture may define DYNAMIC_LOADING if dynamic_load.c
! 395: * defined GC_register_dynamic_libraries() for the architecture.
! 396: */
! 397:
! 398:
! 399: # define STACK_GRAN 0x1000000
! 400: # ifdef M68K
! 401: # define MACH_TYPE "M68K"
! 402: # define ALIGNMENT 2
! 403: # ifdef OPENBSD
! 404: # define OS_TYPE "OPENBSD"
! 405: # define HEURISTIC2
! 406: extern char etext;
! 407: # define DATASTART ((ptr_t)(&etext))
! 408: # endif
! 409: # ifdef NETBSD
! 410: # define OS_TYPE "NETBSD"
! 411: # define HEURISTIC2
! 412: extern char etext;
! 413: # define DATASTART ((ptr_t)(&etext))
! 414: # endif
! 415: # ifdef LINUX
! 416: # define OS_TYPE "LINUX"
! 417: # define STACKBOTTOM ((ptr_t)0xf0000000)
! 418: # define MPROTECT_VDB
! 419: # ifdef __ELF__
! 420: # define DYNAMIC_LOADING
! 421: extern char **__environ;
! 422: # define DATASTART ((ptr_t)(&__environ))
! 423: /* hideous kludge: __environ is the first */
! 424: /* word in crt0.o, and delimits the start */
! 425: /* of the data segment, no matter which */
! 426: /* ld options were passed through. */
! 427: /* We could use _etext instead, but that */
! 428: /* would include .rodata, which may */
! 429: /* contain large read-only data tables */
! 430: /* that we'd rather not scan. */
! 431: extern int _end;
! 432: # define DATAEND (&_end)
! 433: # else
! 434: extern int etext;
! 435: # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
! 436: # endif
! 437: # endif
! 438: # ifdef SUNOS4
! 439: # define OS_TYPE "SUNOS4"
! 440: extern char etext;
! 441: # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
! 442: # define HEURISTIC1 /* differs */
! 443: # define DYNAMIC_LOADING
! 444: # endif
! 445: # ifdef HP
! 446: # define OS_TYPE "HP"
! 447: extern char etext;
! 448: # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
! 449: # define STACKBOTTOM ((ptr_t) 0xffeffffc)
! 450: /* empirically determined. seems to work. */
! 451: # include <unistd.h>
! 452: # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
! 453: # endif
! 454: # ifdef SYSV
! 455: # define OS_TYPE "SYSV"
! 456: extern etext;
! 457: # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
! 458: & ~0x3fffff) \
! 459: +((word)&etext & 0x1fff))
! 460: /* This only works for shared-text binaries with magic number 0413.
! 461: The other sorts of SysV binaries put the data at the end of the text,
! 462: in which case the default of &etext would work. Unfortunately,
! 463: handling both would require having the magic-number available.
! 464: -- Parag
! 465: */
! 466: # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
! 467: /* The stack starts at the top of memory, but */
! 468: /* 0x0 cannot be used as setjump_test complains */
! 469: /* that the stack direction is incorrect. Two */
! 470: /* bytes down from 0x0 should be safe enough. */
! 471: /* --Parag */
! 472: # include <sys/mmu.h>
! 473: # define GETPAGESIZE() PAGESIZE /* Is this still right? */
! 474: # endif
! 475: # ifdef AMIGA
! 476: # define OS_TYPE "AMIGA"
! 477: /* STACKBOTTOM and DATASTART handled specially */
! 478: /* in os_dep.c */
! 479: # define DATAEND /* not needed */
! 480: # define GETPAGESIZE() 4096
! 481: # endif
! 482: # ifdef MACOS
! 483: # ifndef __LOWMEM__
! 484: # include <LowMem.h>
! 485: # endif
! 486: # define OS_TYPE "MACOS"
! 487: /* see os_dep.c for details of global data segments. */
! 488: # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
! 489: # define DATAEND /* not needed */
! 490: # define GETPAGESIZE() 4096
! 491: # endif
! 492: # ifdef NEXT
! 493: # define OS_TYPE "NEXT"
! 494: # define DATASTART ((ptr_t) get_etext())
! 495: # define STACKBOTTOM ((ptr_t) 0x4000000)
! 496: # define DATAEND /* not needed */
! 497: # endif
! 498: # endif
! 499:
! 500: # ifdef POWERPC
! 501: # define MACH_TYPE "POWERPC"
! 502: # ifdef MACOS
! 503: # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
! 504: # ifndef __LOWMEM__
! 505: # include <LowMem.h>
! 506: # endif
! 507: # define OS_TYPE "MACOS"
! 508: /* see os_dep.c for details of global data segments. */
! 509: # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
! 510: # define DATAEND /* not needed */
! 511: # endif
! 512: # ifdef LINUX
! 513: # define ALIGNMENT 4 /* Guess. Can someone verify? */
! 514: /* This was 2, but that didn't sound right. */
! 515: # define OS_TYPE "LINUX"
! 516: # define HEURISTIC1
! 517: # undef STACK_GRAN
! 518: # define STACK_GRAN 0x10000000
! 519: /* Stack usually starts at 0x80000000 */
! 520: # define DATASTART GC_data_start
! 521: extern int _end;
! 522: # define DATAEND (&_end)
! 523: # endif
! 524: # ifdef MACOSX
! 525: # define ALIGNMENT 4
! 526: # define OS_TYPE "MACOSX"
! 527: # define DATASTART ((ptr_t) get_etext())
! 528: # define STACKBOTTOM ((ptr_t) 0xc0000000)
! 529: # define DATAEND /* not needed */
! 530: # endif
! 531: # endif
! 532:
! 533: # ifdef VAX
! 534: # define MACH_TYPE "VAX"
! 535: # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
! 536: extern char etext;
! 537: # define DATASTART ((ptr_t)(&etext))
! 538: # ifdef BSD
! 539: # define OS_TYPE "BSD"
! 540: # define HEURISTIC1
! 541: /* HEURISTIC2 may be OK, but it's hard to test. */
! 542: # endif
! 543: # ifdef ULTRIX
! 544: # define OS_TYPE "ULTRIX"
! 545: # define STACKBOTTOM ((ptr_t) 0x7fffc800)
! 546: # endif
! 547: # endif
! 548:
! 549: # ifdef RT
! 550: # define MACH_TYPE "RT"
! 551: # define ALIGNMENT 4
! 552: # define DATASTART ((ptr_t) 0x10000000)
! 553: # define STACKBOTTOM ((ptr_t) 0x1fffd800)
! 554: # endif
! 555:
! 556: # ifdef SPARC
! 557: # define MACH_TYPE "SPARC"
! 558: # define ALIGNMENT 4 /* Required by hardware */
! 559: # define ALIGN_DOUBLE
! 560: extern int etext;
! 561: # ifdef SUNOS5
! 562: # define OS_TYPE "SUNOS5"
! 563: extern int _etext;
! 564: extern int _end;
! 565: extern char * GC_SysVGetDataStart();
! 566: # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
! 567: # define DATAEND (&_end)
! 568: # ifndef USE_MMAP
! 569: # define USE_MMAP
! 570: # endif
! 571: # ifdef USE_MMAP
! 572: # define HEAP_START (ptr_t)0x40000000
! 573: # else
! 574: # define HEAP_START DATAEND
! 575: # endif
! 576: # define PROC_VDB
! 577: /* HEURISTIC1 reportedly no longer works under 2.7. Thus we */
! 578: /* switched to HEURISTIC2, eventhough it creates some debugging */
! 579: /* issues. */
! 580: #if MPI
! 581: extern int *StackBottom;
! 582: # define STACKBOTTOM (ptr_t)(StackBottom)
! 583: #else
! 584: # define HEURISTIC2
! 585: #endif
! 586: # include <unistd.h>
! 587: # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
! 588: /* getpagesize() appeared to be missing from at least one */
! 589: /* Solaris 5.4 installation. Weird. */
! 590: # define DYNAMIC_LOADING
! 591: # endif
! 592: # ifdef SUNOS4
! 593: # define OS_TYPE "SUNOS4"
! 594: /* [If you have a weak stomach, don't read this.] */
! 595: /* We would like to use: */
! 596: /* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
! 597: /* This fails occasionally, due to an ancient, but very */
! 598: /* persistent ld bug. &etext is set 32 bytes too high. */
! 599: /* We instead read the text segment size from the a.out */
! 600: /* header, which happens to be mapped into our address space */
! 601: /* at the start of the text segment. The detective work here */
! 602: /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
! 603: /* Serpette of INRIA. */
! 604: /* This assumes ZMAGIC, i.e. demand-loadable executables. */
! 605: # define TEXTSTART 0x2000
! 606: # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
! 607: # define MPROTECT_VDB
! 608: # define HEURISTIC1
! 609: # define DYNAMIC_LOADING
! 610: # endif
! 611: # ifdef DRSNX
! 612: # define CPP_WORDSZ 32
! 613: # define OS_TYPE "DRSNX"
! 614: extern char * GC_SysVGetDataStart();
! 615: extern int etext;
! 616: # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
! 617: # define MPROTECT_VDB
! 618: # define STACKBOTTOM ((ptr_t) 0xdfff0000)
! 619: # define DYNAMIC_LOADING
! 620: # endif
! 621: # ifdef LINUX
! 622: # define OS_TYPE "LINUX"
! 623: # ifdef __ELF__
! 624: # define DATASTART GC_data_start
! 625: # define DYNAMIC_LOADING
! 626: # else
! 627: Linux Sparc non elf ?
! 628: # endif
! 629: extern int _end;
! 630: # define DATAEND (&_end)
! 631: # define SVR4
! 632: # define STACKBOTTOM ((ptr_t) 0xf0000000)
! 633: # endif
! 634: # ifdef OPENBSD
! 635: # define OS_TYPE "OPENBSD"
! 636: # define STACKBOTTOM ((ptr_t) 0xf8000000)
! 637: # define DATASTART ((ptr_t)(&etext))
! 638: # endif
! 639: # endif
! 640:
! 641: # ifdef I386
! 642: # define MACH_TYPE "I386"
! 643: # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
! 644: /* except Borland. The -a4 option fixes */
! 645: /* Borland. */
! 646: /* Ivan Demakov: For Watcom the option is -zp4. */
! 647: # ifndef SMALL_CONFIG
! 648: # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
! 649: /* improvement on Pentiums. */
! 650: # endif
! 651: # ifdef SEQUENT
! 652: # define OS_TYPE "SEQUENT"
! 653: extern int etext;
! 654: # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
! 655: # define STACKBOTTOM ((ptr_t) 0x3ffff000)
! 656: # endif
! 657: # ifdef SUNOS5
! 658: # define OS_TYPE "SUNOS5"
! 659: extern int etext, _start;
! 660: extern char * GC_SysVGetDataStart();
! 661: # define DATASTART GC_SysVGetDataStart(0x1000, &etext)
! 662: # define STACKBOTTOM ((ptr_t)(&_start))
! 663: /** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
! 664: /*# define PROC_VDB*/
! 665: # define DYNAMIC_LOADING
! 666: # ifndef USE_MMAP
! 667: # define USE_MMAP
! 668: # endif
! 669: # ifdef USE_MMAP
! 670: # define HEAP_START (ptr_t)0x40000000
! 671: # else
! 672: # define HEAP_START DATAEND
! 673: # endif
! 674: # endif
! 675: # ifdef SCO
! 676: # define OS_TYPE "SCO"
! 677: extern int etext;
! 678: # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
! 679: & ~0x3fffff) \
! 680: +((word)&etext & 0xfff))
! 681: # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
! 682: # endif
! 683: # ifdef SCO_ELF
! 684: # define OS_TYPE "SCO_ELF"
! 685: extern int etext;
! 686: # define DATASTART ((ptr_t)(&etext))
! 687: # define STACKBOTTOM ((ptr_t) 0x08048000)
! 688: # define DYNAMIC_LOADING
! 689: # define ELF_CLASS ELFCLASS32
! 690: # endif
! 691: # ifdef LINUX
! 692: # define OS_TYPE "LINUX"
! 693: # define STACKBOTTOM ((ptr_t)0xc0000000)
! 694: /* Appears to be 0xe0000000 for at least one 2.1.91 kernel. */
! 695: /* Probably needs to be more flexible, but I don't yet */
! 696: /* fully understand how flexible. */
! 697: # if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC)
! 698: # define MPROTECT_VDB
! 699: # else
! 700: /* We seem to get random errors in incremental mode, */
! 701: /* possibly because Linux threads is itself a malloc client */
! 702: /* and can't deal with the signals. */
! 703: # endif
! 704: # ifdef __ELF__
! 705: # define DYNAMIC_LOADING
! 706: # ifdef UNDEFINED /* includes ro data */
! 707: extern int _etext;
! 708: # define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
! 709: # endif
! 710: # include <features.h>
! 711: # if defined(__GLIBC__) && __GLIBC__ >= 2
! 712: extern int __data_start;
! 713: # define DATASTART ((ptr_t)(&__data_start))
! 714: # else
! 715: extern char **__environ;
! 716: # define DATASTART ((ptr_t)(&__environ))
! 717: /* hideous kludge: __environ is the first */
! 718: /* word in crt0.o, and delimits the start */
! 719: /* of the data segment, no matter which */
! 720: /* ld options were passed through. */
! 721: /* We could use _etext instead, but that */
! 722: /* would include .rodata, which may */
! 723: /* contain large read-only data tables */
! 724: /* that we'd rather not scan. */
! 725: # endif
! 726: extern int _end;
! 727: # define DATAEND (&_end)
! 728: # else
! 729: extern int etext;
! 730: # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
! 731: # endif
! 732: # endif
! 733: # ifdef CYGWIN32
! 734: # define OS_TYPE "CYGWIN32"
! 735: extern int _data_start__;
! 736: extern int _data_end__;
! 737: extern int _bss_start__;
! 738: extern int _bss_end__;
! 739: /* For binutils 2.9.1, we have */
! 740: /* DATASTART = _data_start__ */
! 741: /* DATAEND = _bss_end__ */
! 742: /* whereas for some earlier versions it was */
! 743: /* DATASTART = _bss_start__ */
! 744: /* DATAEND = _data_end__ */
! 745: /* To get it right for both, we take the */
! 746: /* minumum/maximum of the two. */
! 747: # define MAX(x,y) ((x) > (y) ? (x) : (y))
! 748: # define MIN(x,y) ((x) < (y) ? (x) : (y))
! 749: # define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
! 750: # define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__))
! 751: # undef STACK_GRAN
! 752: # define STACK_GRAN 0x10000
! 753: # define HEURISTIC1
! 754: # endif
! 755: # ifdef OS2
! 756: # define OS_TYPE "OS2"
! 757: /* STACKBOTTOM and DATASTART are handled specially in */
! 758: /* os_dep.c. OS2 actually has the right */
! 759: /* system call! */
! 760: # define DATAEND /* not needed */
! 761: # endif
! 762: # ifdef MSWIN32
! 763: # define OS_TYPE "MSWIN32"
! 764: /* STACKBOTTOM and DATASTART are handled specially in */
! 765: /* os_dep.c. */
! 766: # ifndef __WATCOMC__
! 767: # define MPROTECT_VDB
! 768: # endif
! 769: # define DATAEND /* not needed */
! 770: # endif
! 771: # ifdef DJGPP
! 772: # define OS_TYPE "DJGPP"
! 773: # include "stubinfo.h"
! 774: extern int etext;
! 775: extern int _stklen;
! 776: extern int __djgpp_stack_limit;
! 777: # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
! 778: /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
! 779: + _stklen)) */
! 780: # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
! 781: /* This may not be right. */
! 782: # endif
! 783: # ifdef OPENBSD
! 784: # define OS_TYPE "OPENBSD"
! 785: # endif
! 786: # ifdef FREEBSD
! 787: # define OS_TYPE "FREEBSD"
! 788: # define MPROTECT_VDB
! 789: # endif
! 790: # ifdef NETBSD
! 791: # define OS_TYPE "NETBSD"
! 792: # endif
! 793: # ifdef THREE86BSD
! 794: # define OS_TYPE "THREE86BSD"
! 795: # endif
! 796: # ifdef BSDI
! 797: # define OS_TYPE "BSDI"
! 798: # endif
! 799: # if defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD) \
! 800: || defined(THREE86BSD) || defined(BSDI)
! 801: # define HEURISTIC2
! 802: extern char etext;
! 803: # define DATASTART ((ptr_t)(&etext))
! 804: # endif
! 805: # ifdef NEXT
! 806: # define OS_TYPE "NEXT"
! 807: # define DATASTART ((ptr_t) get_etext())
! 808: # define STACKBOTTOM ((ptr_t)0xc0000000)
! 809: # define DATAEND /* not needed */
! 810: # endif
! 811: # ifdef DOS4GW
! 812: # define OS_TYPE "DOS4GW"
! 813: extern long __nullarea;
! 814: extern char _end;
! 815: extern char *_STACKTOP;
! 816: /* Depending on calling conventions Watcom C either precedes
! 817: or does not precedes with undescore names of C-variables.
! 818: Make sure startup code variables always have the same names. */
! 819: #pragma aux __nullarea "*";
! 820: #pragma aux _end "*";
! 821: # define STACKBOTTOM ((ptr_t) _STACKTOP)
! 822: /* confused? me too. */
! 823: # define DATASTART ((ptr_t) &__nullarea)
! 824: # define DATAEND ((ptr_t) &_end)
! 825: # endif
! 826: # endif
! 827:
! 828: # ifdef NS32K
! 829: # define MACH_TYPE "NS32K"
! 830: # define ALIGNMENT 4
! 831: extern char **environ;
! 832: # define DATASTART ((ptr_t)(&environ))
! 833: /* hideous kludge: environ is the first */
! 834: /* word in crt0.o, and delimits the start */
! 835: /* of the data segment, no matter which */
! 836: /* ld options were passed through. */
! 837: # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
! 838: # endif
! 839:
! 840: # ifdef MIPS
! 841: # define MACH_TYPE "MIPS"
! 842: # ifndef IRIX5
! 843: # define DATASTART (ptr_t)0x10000000
! 844: /* Could probably be slightly higher since */
! 845: /* startup code allocates lots of stuff. */
! 846: # else
! 847: extern int _fdata;
! 848: # define DATASTART ((ptr_t)(&_fdata))
! 849: # ifdef USE_MMAP
! 850: # define HEAP_START (ptr_t)0x30000000
! 851: # else
! 852: # define HEAP_START DATASTART
! 853: # endif
! 854: /* Lowest plausible heap address. */
! 855: /* In the MMAP case, we map there. */
! 856: /* In either case it is used to identify */
! 857: /* heap sections so they're not */
! 858: /* considered as roots. */
! 859: # endif /* IRIX5 */
! 860: # define HEURISTIC2
! 861: /* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */
! 862: # ifdef ULTRIX
! 863: # define OS_TYPE "ULTRIX"
! 864: # define ALIGNMENT 4
! 865: # endif
! 866: # ifdef RISCOS
! 867: # define OS_TYPE "RISCOS"
! 868: # define ALIGNMENT 4 /* Required by hardware */
! 869: # endif
! 870: # ifdef IRIX5
! 871: # define OS_TYPE "IRIX5"
! 872: # define MPROTECT_VDB
! 873: # ifdef _MIPS_SZPTR
! 874: # define CPP_WORDSZ _MIPS_SZPTR
! 875: # define ALIGNMENT (_MIPS_SZPTR/8)
! 876: # if CPP_WORDSZ != 64
! 877: # define ALIGN_DOUBLE
! 878: # endif
! 879: # else
! 880: # define ALIGNMENT 4
! 881: # define ALIGN_DOUBLE
! 882: # endif
! 883: # define DYNAMIC_LOADING
! 884: # endif
! 885: # endif
! 886:
! 887: # ifdef RS6000
! 888: # define MACH_TYPE "RS6000"
! 889: # define ALIGNMENT 4
! 890: # define DATASTART ((ptr_t)0x20000000)
! 891: extern int errno;
! 892: # define STACKBOTTOM ((ptr_t)((ulong)&errno))
! 893: # define DYNAMIC_LOADING
! 894: /* For really old versions of AIX, this may have to be removed. */
! 895: # endif
! 896:
! 897: # ifdef HP_PA
! 898: # define MACH_TYPE "HP_PA"
! 899: # define ALIGNMENT 4
! 900: # define ALIGN_DOUBLE
! 901: extern int __data_start;
! 902: # define DATASTART ((ptr_t)(&__data_start))
! 903: # if 0
! 904: /* The following appears to work for 7xx systems running HP/UX */
! 905: /* 9.xx Furthermore, it might result in much faster */
! 906: /* collections than HEURISTIC2, which may involve scanning */
! 907: /* segments that directly precede the stack. It is not the */
! 908: /* default, since it may not work on older machine/OS */
! 909: /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
! 910: /* this.) */
! 911: # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
! 912: # else
! 913: # define HEURISTIC2
! 914: # endif
! 915: # define STACK_GROWS_UP
! 916: # define DYNAMIC_LOADING
! 917: # include <unistd.h>
! 918: # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
! 919: /* They misspelled the Posix macro? */
! 920: # endif
! 921:
! 922: # ifdef ALPHA
! 923: # define MACH_TYPE "ALPHA"
! 924: # define ALIGNMENT 8
! 925: # ifdef OSF1
! 926: # define OS_TYPE "OSF1"
! 927: # define DATASTART ((ptr_t) 0x140000000)
! 928: extern _end;
! 929: # define DATAEND ((ptr_t) &_end)
! 930: # define HEURISTIC2
! 931: /* Normally HEURISTIC2 is too conervative, since */
! 932: /* the text segment immediately follows the stack. */
! 933: /* Hence we give an upper pound. */
! 934: extern int __start;
! 935: # define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
! 936: # define CPP_WORDSZ 64
! 937: # define MPROTECT_VDB
! 938: # define DYNAMIC_LOADING
! 939: # endif
! 940: # ifdef LINUX
! 941: # define OS_TYPE "LINUX"
! 942: # define CPP_WORDSZ 64
! 943: # define STACKBOTTOM ((ptr_t) 0x120000000)
! 944: # ifdef __ELF__
! 945: # if 0
! 946: /* __data_start apparently disappeared in some recent releases. */
! 947: extern int __data_start;
! 948: # define DATASTART &__data_start
! 949: # endif
! 950: # define DATASTART GC_data_start
! 951: # define DYNAMIC_LOADING
! 952: # else
! 953: # define DATASTART ((ptr_t) 0x140000000)
! 954: # endif
! 955: extern int _end;
! 956: # define DATAEND (&_end)
! 957: # define MPROTECT_VDB
! 958: /* Has only been superficially tested. May not */
! 959: /* work on all versions. */
! 960: # endif
! 961: # endif
! 962:
! 963: # ifdef M88K
! 964: # define MACH_TYPE "M88K"
! 965: # define ALIGNMENT 4
! 966: # define ALIGN_DOUBLE
! 967: extern int etext;
! 968: # ifdef CX_UX
! 969: # define OS_TYPE "CX_UX"
! 970: # define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
! 971: # endif
! 972: # ifdef DGUX
! 973: # define OS_TYPE "DGUX"
! 974: extern char * GC_SysVGetDataStart();
! 975: # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
! 976: # endif
! 977: # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
! 978: # endif
! 979:
! 980: # ifdef S370
! 981: # define MACH_TYPE "S370"
! 982: # define OS_TYPE "UTS4"
! 983: # define ALIGNMENT 4 /* Required by hardware */
! 984: extern int etext;
! 985: extern int _etext;
! 986: extern int _end;
! 987: extern char * GC_SysVGetDataStart();
! 988: # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
! 989: # define DATAEND (&_end)
! 990: # define HEURISTIC2
! 991: # endif
! 992:
! 993: # ifndef STACK_GROWS_UP
! 994: # define STACK_GROWS_DOWN
! 995: # endif
! 996:
! 997: # ifndef CPP_WORDSZ
! 998: # define CPP_WORDSZ 32
! 999: # endif
! 1000:
! 1001: # ifndef OS_TYPE
! 1002: # define OS_TYPE ""
! 1003: # endif
! 1004:
! 1005: # ifndef DATAEND
! 1006: extern int end;
! 1007: # define DATAEND (&end)
! 1008: # endif
! 1009:
! 1010: # if defined(SVR4) && !defined(GETPAGESIZE)
! 1011: # include <unistd.h>
! 1012: # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
! 1013: # endif
! 1014:
! 1015: # ifndef GETPAGESIZE
! 1016: # if defined(SUNOS5) || defined(IRIX5)
! 1017: # include <unistd.h>
! 1018: # endif
! 1019: # define GETPAGESIZE() getpagesize()
! 1020: # endif
! 1021:
! 1022: # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
! 1023: /* OS has SVR4 generic features. Probably others also qualify. */
! 1024: # define SVR4
! 1025: # endif
! 1026:
! 1027: # if defined(SUNOS5) || defined(DRSNX)
! 1028: /* OS has SUNOS5 style semi-undocumented interface to dynamic */
! 1029: /* loader. */
! 1030: # define SUNOS5DL
! 1031: /* OS has SUNOS5 style signal handlers. */
! 1032: # define SUNOS5SIGS
! 1033: # endif
! 1034:
! 1035: # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
! 1036: -> bad word size
! 1037: # endif
! 1038:
! 1039: # ifdef PCR
! 1040: # undef DYNAMIC_LOADING
! 1041: # undef STACKBOTTOM
! 1042: # undef HEURISTIC1
! 1043: # undef HEURISTIC2
! 1044: # undef PROC_VDB
! 1045: # undef MPROTECT_VDB
! 1046: # define PCR_VDB
! 1047: # endif
! 1048:
! 1049: # ifdef SRC_M3
! 1050: /* Postponed for now. */
! 1051: # undef PROC_VDB
! 1052: # undef MPROTECT_VDB
! 1053: # endif
! 1054:
! 1055: # ifdef SMALL_CONFIG
! 1056: /* Presumably not worth the space it takes. */
! 1057: # undef PROC_VDB
! 1058: # undef MPROTECT_VDB
! 1059: # endif
! 1060:
! 1061: # ifdef USE_MUNMAP
! 1062: # undef MPROTECT_VDB /* Can't deal with address space holes. */
! 1063: # endif
! 1064:
! 1065: # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
! 1066: # define DEFAULT_VDB
! 1067: # endif
! 1068:
! 1069: # if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
! 1070: # define SOLARIS_THREADS
! 1071: # endif
! 1072: # if defined(IRIX_THREADS) && !defined(IRIX5)
! 1073: --> inconsistent configuration
! 1074: # endif
! 1075: # if defined(IRIX_JDK_THREADS) && !defined(IRIX5)
! 1076: --> inconsistent configuration
! 1077: # endif
! 1078: # if defined(LINUX_THREADS) && !defined(LINUX)
! 1079: --> inconsistent configuration
! 1080: # endif
! 1081: # if defined(SOLARIS_THREADS) && !defined(SUNOS5)
! 1082: --> inconsistent configuration
! 1083: # endif
! 1084: # if defined(PCR) || defined(SRC_M3) || \
! 1085: defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
! 1086: defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
! 1087: defined(IRIX_JDK_THREADS)
! 1088: # define THREADS
! 1089: # endif
! 1090:
! 1091: # if defined(HP_PA) || defined(M88K) || defined(POWERPC) \
! 1092: || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT)
! 1093: /* Use setjmp based hack to mark from callee-save registers. */
! 1094: # define USE_GENERIC_PUSH_REGS
! 1095: # endif
! 1096: # if defined(SPARC) && !defined(LINUX)
! 1097: # define SAVE_CALL_CHAIN
! 1098: # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
! 1099: /* include assembly code to do it well. */
! 1100: # endif
! 1101:
! 1102: # endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>