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