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