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