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.
6 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
7 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
9 * Permission is hereby granted to use or copy this program
10 * for any purpose, provided the above notices are retained on all copies.
11 * Permission to modify the code and to distribute modified code is granted,
12 * provided the above notices are retained, and a notice that the code was
13 * modified is included with the above copyright notice.
20 /* Machine dependent parameters. Some tuning parameters can be found */
21 /* near the top of gc_private.h. */
23 /* Machine specific parts contributed by various people. See README file. */
25 /* First a unified test for Linux: */
26 # if defined(linux) || defined(__linux__)
30 /* Determine the machine type: */
31 # if defined(sun) && defined(mc68000)
34 # define mach_type_known
36 # if defined(hp9000s300)
39 # define mach_type_known
41 # if defined(__OpenBSD__) && defined(m68k)
44 # define mach_type_known
46 # if defined(__OpenBSD__) && defined(__sparc__)
49 # define mach_type_known
51 # if defined(__NetBSD__) && defined(m68k)
54 # define mach_type_known
56 # if defined(__NetBSD__) && defined(arm32)
59 # define mach_type_known
68 # define mach_type_known
70 # if defined(mips) || defined(__mips)
73 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
76 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
77 || defined(__SYSTYPE_SVR4__)
78 # define IRIX5 /* or IRIX 6.X */
80 # define RISCOS /* or IRIX 4.X */
84 # define mach_type_known
86 # if defined(sequent) && defined(i386)
89 # define mach_type_known
91 # if defined(sun) && defined(i386)
94 # define mach_type_known
96 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
99 # define mach_type_known
103 # define mach_type_known
105 # if defined(sun) && (defined(sparc) || defined(__sparc))
107 /* Test for SunOS 5.x */
114 # define mach_type_known
116 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
117 && !defined(__OpenBSD__)
120 # define mach_type_known
124 # define mach_type_known
126 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
127 /* The above test may need refinement */
129 # if defined(_SCO_ELF)
134 # define mach_type_known
136 # if defined(_AUX_SOURCE)
139 # define mach_type_known
141 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
142 || defined(hppa) || defined(__hppa__)
147 # define mach_type_known
149 # if defined(LINUX) && (defined(i386) || defined(__i386__))
151 # define mach_type_known
153 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
155 # define mach_type_known
157 # if defined(LINUX) && defined(powerpc)
159 # define mach_type_known
161 # if defined(LINUX) && defined(__mc68000__)
163 # define mach_type_known
165 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
167 # define mach_type_known
169 # if defined(LINUX) && defined(arm)
171 # define mach_type_known
173 # if defined(__alpha) || defined(__alpha__)
176 # define OSF1 /* a.k.a Digital Unix */
178 # define mach_type_known
180 # if defined(_AMIGA) && !defined(AMIGA)
185 # define mach_type_known
187 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
190 # define mach_type_known
192 # if defined(__MWERKS__) && defined(__powerc)
195 # define mach_type_known
200 # define mach_type_known
202 # if defined(NeXT) && defined(mc68000)
205 # define mach_type_known
207 # if defined(NeXT) && defined(i386)
210 # define mach_type_known
212 # if defined(__OpenBSD__) && defined(i386)
215 # define mach_type_known
217 # if defined(__FreeBSD__) && defined(i386)
220 # define mach_type_known
222 # if defined(__NetBSD__) && defined(i386)
225 # define mach_type_known
227 # if defined(bsdi) && defined(i386)
230 # define mach_type_known
232 # if !defined(mach_type_known) && defined(__386BSD__)
235 # define mach_type_known
237 # if defined(_CX_UX) && defined(_M88K)
240 # define mach_type_known
245 # define mach_type_known
247 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
248 || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
250 # define MSWIN32 /* or Win32s */
251 # define mach_type_known
253 # if defined(__DJGPP__)
256 # define DJGPP /* MSDOS running the DJGPP port of GCC */
258 # define mach_type_known
260 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
263 # define mach_type_known
265 # if defined(__MINGW32__)
268 # define mach_type_known
270 # if defined(__BORLANDC__)
273 # define mach_type_known
275 # if defined(_UTS) && !defined(mach_type_known)
278 # define mach_type_known
282 # define mach_type_known
285 # if defined(__WATCOMC__) && defined(__386__)
287 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
288 # if defined(__OS2__)
291 # if defined(__WINDOWS_386__) || defined(__NT__)
298 # define mach_type_known
301 /* Feel free to add more clauses here */
303 /* Or manually define the machine type here. A machine type is */
304 /* characterized by the architecture. Some */
305 /* machine types are further subdivided by OS. */
306 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
307 /* Note that SGI IRIX is treated identically to RISCOS. */
308 /* SYSV on an M68K actually means A/UX. */
309 /* The distinction in these cases is usually the stack starting address */
310 # ifndef mach_type_known
311 --> unknown machine type
313 /* Mapping is: M68K ==> Motorola 680X0 */
314 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
315 /* MACOS and AMIGA variants) */
316 /* I386 ==> Intel 386 */
317 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
318 /* FREEBSD, THREE86BSD, MSWIN32, */
319 /* BSDI,SUNOS5, NEXT, other variants) */
320 /* NS32K ==> Encore Multimax */
321 /* MIPS ==> R2000 or R3000 */
322 /* (RISCOS, ULTRIX variants) */
323 /* VAX ==> DEC VAX */
324 /* (BSD, ULTRIX variants) */
325 /* RS6000 ==> IBM RS/6000 AIX3.X */
326 /* RT ==> IBM PC/RT */
327 /* HP_PA ==> HP9000/700 & /800 */
329 /* SPARC ==> SPARC v7/v8/v9 */
330 /* (SUNOS4, SUNOS5, LINUX, */
331 /* DRSNX variants) */
332 /* ALPHA ==> DEC Alpha */
333 /* (OSF1 and LINUX variants) */
334 /* M88K ==> Motorola 88XX0 */
335 /* (CX_UX and DGUX) */
336 /* S370 ==> 370-like machine */
337 /* running Amdahl UTS4 */
338 /* ARM32 ==> Intel StrongARM */
339 /* IA64 ==> Intel IA64 */
344 * For each architecture and OS, the following need to be defined:
346 * CPP_WORD_SZ is a simple integer constant representing the word size.
347 * in bits. We assume byte addressibility, where a byte has 8 bits.
348 * We also assume CPP_WORD_SZ is either 32 or 64.
349 * (We care about the length of pointers, not hardware
350 * bus widths. Thus a 64 bit processor with a C compiler that uses
351 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
353 * MACH_TYPE is a string representation of the machine type.
354 * OS_TYPE is analogous for the OS.
356 * ALIGNMENT is the largest N, such that
357 * all pointer are guaranteed to be aligned on N byte boundaries.
358 * defining it to be 1 will always work, but perform poorly.
360 * DATASTART is the beginning of the data segment.
361 * On UNIX systems, the collector will scan the area between DATASTART
362 * and DATAEND for root pointers.
364 * DATAEND, if not &end.
366 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
369 * STACKBOTTOM is the cool end of the stack, which is usually the
370 * highest address in the stack.
371 * Under PCR or OS/2, we have other ways of finding thread stacks.
372 * For each machine, the following should:
373 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
374 * 2) define exactly one of
375 * STACKBOTTOM (should be defined to be an expression)
378 * If either of the last two macros are defined, then STACKBOTTOM is computed
379 * during collector startup using one of the following two heuristics:
380 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
381 * the next multiple of STACK_GRAN.
382 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
383 * in small steps (decrement if STACK_GROWS_UP), and read the value
384 * at each location. Remember the value when the first
385 * Segmentation violation or Bus error is signalled. Round that
386 * to the nearest plausible page boundary, and use that instead
389 * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
390 * the value of environ is a pointer that can serve as STACKBOTTOM.
391 * I expect that HEURISTIC2 can be replaced by this approach, which
392 * interferes far less with debugging.
394 * If no expression for STACKBOTTOM can be found, and neither of the above
395 * heuristics are usable, the collector can still be used with all of the above
396 * undefined, provided one of the following is done:
397 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
398 * without reference to STACKBOTTOM. This is appropriate for use in
399 * conjunction with thread packages, since there will be multiple stacks.
400 * (Allocating thread stacks in the heap, and treating them as ordinary
401 * heap data objects is also possible as a last resort. However, this is
402 * likely to introduce significant amounts of excess storage retention
403 * unless the dead parts of the thread stacks are periodically cleared.)
404 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
405 * If the author of the client code controls the main program, this is
406 * easily accomplished by introducing a new main program, setting
407 * GC_stackbottom to the address of a local variable, and then calling
408 * the original main program. The new main program would read something
411 * # include "gc_private.h"
413 * main(argc, argv, envp)
415 * char **argv, **envp;
419 * GC_stackbottom = (ptr_t)(&dummy);
420 * return(real_main(argc, argv, envp));
424 * Each architecture may also define the style of virtual dirty bit
425 * implementation to be used:
426 * MPROTECT_VDB: Write protect the heap and catch faults.
427 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
429 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
430 * defined GC_register_dynamic_libraries() for the architecture.
432 * An architecture may define PREFETCH(x) to preload the cache with *x.
433 * This defaults to a no-op.
435 * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
437 * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
438 * clear the two words at GC_malloc-aligned address x. By default,
439 * word stores of 0 are used instead.
443 # define STACK_GRAN 0x1000000
445 # define MACH_TYPE "M68K"
448 # define OS_TYPE "OPENBSD"
451 # define DATASTART ((ptr_t)(&etext))
454 # define OS_TYPE "NETBSD"
457 # define DATASTART ((ptr_t)(&etext))
460 # define OS_TYPE "LINUX"
461 # define STACKBOTTOM ((ptr_t)0xf0000000)
462 # define MPROTECT_VDB
464 # define DYNAMIC_LOADING
465 extern char **__environ
;
466 # define DATASTART ((ptr_t)(&__environ))
467 /* hideous kludge: __environ is the first */
468 /* word in crt0.o, and delimits the start */
469 /* of the data segment, no matter which */
470 /* ld options were passed through. */
471 /* We could use _etext instead, but that */
472 /* would include .rodata, which may */
473 /* contain large read-only data tables */
474 /* that we'd rather not scan. */
476 # define DATAEND (&_end)
479 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
483 # define OS_TYPE "SUNOS4"
485 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
486 # define HEURISTIC1 /* differs */
487 # define DYNAMIC_LOADING
490 # define OS_TYPE "HP"
492 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
493 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
494 /* empirically determined. seems to work. */
496 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
499 # define OS_TYPE "SYSV"
501 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
503 +((word)&etext & 0x1fff))
504 /* This only works for shared-text binaries with magic number 0413.
505 The other sorts of SysV binaries put the data at the end of the text,
506 in which case the default of &etext would work. Unfortunately,
507 handling both would require having the magic-number available.
510 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
511 /* The stack starts at the top of memory, but */
512 /* 0x0 cannot be used as setjump_test complains */
513 /* that the stack direction is incorrect. Two */
514 /* bytes down from 0x0 should be safe enough. */
516 # include <sys/mmu.h>
517 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
520 # define OS_TYPE "AMIGA"
521 /* STACKBOTTOM and DATASTART handled specially */
523 # define DATAEND /* not needed */
524 # define GETPAGESIZE() 4096
530 # define OS_TYPE "MACOS"
531 /* see os_dep.c for details of global data segments. */
532 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
533 # define DATAEND /* not needed */
534 # define GETPAGESIZE() 4096
537 # define OS_TYPE "NEXT"
538 # define DATASTART ((ptr_t) get_etext())
539 # define STACKBOTTOM ((ptr_t) 0x4000000)
540 # define DATAEND /* not needed */
545 # define MACH_TYPE "POWERPC"
547 # define ALIGNMENT 2 /* Still necessary? Could it be 4? */
551 # define OS_TYPE "MACOS"
552 /* see os_dep.c for details of global data segments. */
553 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
554 # define DATAEND /* not needed */
557 # define ALIGNMENT 4 /* Guess. Can someone verify? */
558 /* This was 2, but that didn't sound right. */
559 # define OS_TYPE "LINUX"
561 # define DYNAMIC_LOADING
563 # define STACK_GRAN 0x10000000
564 /* Stack usually starts at 0x80000000 */
565 # define LINUX_DATA_START
567 # define DATAEND (&_end)
571 # define OS_TYPE "MACOSX"
572 # define DATASTART ((ptr_t) get_etext())
573 # define STACKBOTTOM ((ptr_t) 0xc0000000)
574 # define DATAEND /* not needed */
579 # define MACH_TYPE "VAX"
580 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
582 # define DATASTART ((ptr_t)(&etext))
584 # define OS_TYPE "BSD"
586 /* HEURISTIC2 may be OK, but it's hard to test. */
589 # define OS_TYPE "ULTRIX"
590 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
595 # define MACH_TYPE "RT"
597 # define DATASTART ((ptr_t) 0x10000000)
598 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
602 # define MACH_TYPE "SPARC"
603 # if defined(__arch64__) || defined(__sparcv9)
606 # define ALIGNMENT 4 /* Required by hardware */
608 # define ALIGN_DOUBLE
611 # define OS_TYPE "SUNOS5"
614 extern char * GC_SysVGetDataStart();
615 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
616 # define DATAEND (&_end)
621 # define HEAP_START (ptr_t)0x40000000
623 # define HEAP_START DATAEND
626 /* HEURISTIC1 reportedly no longer works under 2.7. Thus we */
627 /* switched to HEURISTIC2, eventhough it creates some debugging */
631 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
632 /* getpagesize() appeared to be missing from at least one */
633 /* Solaris 5.4 installation. Weird. */
634 # define DYNAMIC_LOADING
637 # define OS_TYPE "SUNOS4"
638 /* [If you have a weak stomach, don't read this.] */
639 /* We would like to use: */
640 /* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
641 /* This fails occasionally, due to an ancient, but very */
642 /* persistent ld bug. &etext is set 32 bytes too high. */
643 /* We instead read the text segment size from the a.out */
644 /* header, which happens to be mapped into our address space */
645 /* at the start of the text segment. The detective work here */
646 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
647 /* Serpette of INRIA. */
648 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
649 # define TEXTSTART 0x2000
650 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
651 # define MPROTECT_VDB
653 # define DYNAMIC_LOADING
656 # define CPP_WORDSZ 32
657 # define OS_TYPE "DRSNX"
658 extern char * GC_SysVGetDataStart();
660 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
661 # define MPROTECT_VDB
662 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
663 # define DYNAMIC_LOADING
666 # define OS_TYPE "LINUX"
668 # define DYNAMIC_LOADING
670 Linux Sparc
/a
.out
not supported
674 # define DATAEND (&_end)
677 # define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
678 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
679 # define CPP_WORDSZ 64
681 # define STACKBOTTOM ((ptr_t) 0xf0000000)
682 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
686 # define OS_TYPE "OPENBSD"
687 # define STACKBOTTOM ((ptr_t) 0xf8000000)
688 # define DATASTART ((ptr_t)(&etext))
693 # define MACH_TYPE "I386"
694 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
695 /* except Borland. The -a4 option fixes */
697 /* Ivan Demakov: For Watcom the option is -zp4. */
698 # ifndef SMALL_CONFIG
699 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
700 /* improvement on Pentiums. */
703 # define OS_TYPE "SEQUENT"
705 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
706 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
709 # define OS_TYPE "SUNOS5"
710 extern int etext
, _start
;
711 extern char * GC_SysVGetDataStart();
712 # define DATASTART GC_SysVGetDataStart(0x1000, &etext)
713 # define STACKBOTTOM ((ptr_t)(&_start))
714 /** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
715 /*# define PROC_VDB*/
716 # define DYNAMIC_LOADING
721 # define HEAP_START (ptr_t)0x40000000
723 # define HEAP_START DATAEND
727 # define OS_TYPE "SCO"
729 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
731 +((word)&etext & 0xfff))
732 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
735 # define OS_TYPE "SCO_ELF"
737 # define DATASTART ((ptr_t)(&etext))
738 # define STACKBOTTOM ((ptr_t) 0x08048000)
739 # define DYNAMIC_LOADING
740 # define ELF_CLASS ELFCLASS32
743 # define OS_TYPE "LINUX"
744 # define LINUX_STACKBOTTOM
748 # define STACK_GRAN 0x10000000
749 /* STACKBOTTOM is usually 0xc0000000, but this changes with */
750 /* different kernel configurations. In particular, systems */
751 /* with 2GB physical memory will usually move the user */
752 /* address space limit, and hence initial SP to 0x80000000. */
754 # if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC)
755 /* libgcj: Linux threads don't interact well with the read() wrapper.
756 Not defining MPROTECT_VDB fixes this. */
757 /* # define MPROTECT_VDB */
759 /* We seem to get random errors in incremental mode, */
760 /* possibly because Linux threads is itself a malloc client */
761 /* and can't deal with the signals. */
764 # define DYNAMIC_LOADING
765 # ifdef UNDEFINED /* includes ro data */
767 # define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
769 # include <features.h>
770 # if defined(__GLIBC__) && __GLIBC__ >= 2
771 # define LINUX_DATA_START
773 extern char **__environ
;
774 # define DATASTART ((ptr_t)(&__environ))
775 /* hideous kludge: __environ is the first */
776 /* word in crt0.o, and delimits the start */
777 /* of the data segment, no matter which */
778 /* ld options were passed through. */
779 /* We could use _etext instead, but that */
780 /* would include .rodata, which may */
781 /* contain large read-only data tables */
782 /* that we'd rather not scan. */
785 # define DATAEND (&_end)
788 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
790 # ifdef USE_I686_PREFETCH
791 # define PREFETCH(x) \
792 __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
793 /* Empirically prefetcht0 is much more effective at reducing */
794 /* cache miss stalls for the targetted load instructions. But it */
795 /* seems to interfere enough with other cache traffic that the net */
796 /* result is worse than prefetchnta. */
798 /* Using prefetches for write seems to have a slight negative */
799 /* impact on performance, at least for a PIII/500. */
800 # define PREFETCH_FOR_WRITE(x) \
801 __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
804 # ifdef USE_3DNOW_PREFETCH
805 # define PREFETCH(x) \
806 __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
807 # define PREFETCH_FOR_WRITE(x)
808 __asm__
__volatile__ (" prefetchw %0": : "m"(*(char *)(x
)))
812 # define OS_TYPE "CYGWIN32"
813 extern int _data_start__
;
814 extern int _data_end__
;
815 extern int _bss_start__
;
816 extern int _bss_end__
;
817 /* For binutils 2.9.1, we have */
818 /* DATASTART = _data_start__ */
819 /* DATAEND = _bss_end__ */
820 /* whereas for some earlier versions it was */
821 /* DATASTART = _bss_start__ */
822 /* DATAEND = _data_end__ */
823 /* To get it right for both, we take the */
824 /* minumum/maximum of the two. */
825 # define MAX(x,y) ((x) > (y) ? (x) : (y))
826 # define MIN(x,y) ((x) < (y) ? (x) : (y))
827 # define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
828 # define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__))
830 # define STACK_GRAN 0x10000
834 # define OS_TYPE "OS2"
835 /* STACKBOTTOM and DATASTART are handled specially in */
836 /* os_dep.c. OS2 actually has the right */
838 # define DATAEND /* not needed */
841 # define OS_TYPE "MSWIN32"
842 /* STACKBOTTOM and DATASTART are handled specially in */
845 # define MPROTECT_VDB
847 # define DATAEND /* not needed */
850 # define OS_TYPE "DJGPP"
851 # include "stubinfo.h"
854 extern int __djgpp_stack_limit
;
855 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
856 /* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
858 # define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
859 /* This may not be right. */
862 # define OS_TYPE "OPENBSD"
865 # define OS_TYPE "FREEBSD"
866 # define MPROTECT_VDB
869 # define OS_TYPE "NETBSD"
872 # define OS_TYPE "THREE86BSD"
875 # define OS_TYPE "BSDI"
877 # if defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD) \
878 || defined(THREE86BSD) || defined(BSDI)
881 # define DATASTART ((ptr_t)(&etext))
884 # define OS_TYPE "NEXT"
885 # define DATASTART ((ptr_t) get_etext())
886 # define STACKBOTTOM ((ptr_t)0xc0000000)
887 # define DATAEND /* not needed */
890 # define OS_TYPE "DOS4GW"
891 extern long __nullarea
;
893 extern char *_STACKTOP
;
894 /* Depending on calling conventions Watcom C either precedes
895 or does not precedes with undescore names of C-variables.
896 Make sure startup code variables always have the same names. */
897 #pragma aux __nullarea "*";
898 #pragma aux _end "*";
899 # define STACKBOTTOM ((ptr_t) _STACKTOP)
900 /* confused? me too. */
901 # define DATASTART ((ptr_t) &__nullarea)
902 # define DATAEND ((ptr_t) &_end)
907 # define MACH_TYPE "NS32K"
909 extern char **environ
;
910 # define DATASTART ((ptr_t)(&environ))
911 /* hideous kludge: environ is the first */
912 /* word in crt0.o, and delimits the start */
913 /* of the data segment, no matter which */
914 /* ld options were passed through. */
915 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
920 # define MACH_TYPE "MIPS"
921 /* LIBGCJ LOCAL: respect predefined DATASTART_IS_ETEXT. */
922 # ifdef DATASTART_IS_ETEXT
924 # define DATASTART ((ptr_t)(&_etext))
926 /* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */
928 /* This was developed for a linuxce style platform. Probably */
929 /* needs to be tweaked for workstation class machines. */
930 # define OS_TYPE "LINUX"
931 extern int __data_start
;
932 # define DATASTART ((ptr_t)(&__data_start))
934 # define USE_GENERIC_PUSH_REGS 1
935 # define STACKBOTTOM 0x80000000
936 /* In many cases, this should probably use LINUX_STACKBOTTOM */
937 /* instead. But some kernel versions seem to give the wrong */
938 /* value from /proc. */
942 # define DATASTART (ptr_t)0x10000000
943 /* Could probably be slightly higher since */
944 /* startup code allocates lots of stuff. */
945 # define OS_TYPE "ULTRIX"
950 # define DATASTART (ptr_t)0x10000000
951 # define OS_TYPE "RISCOS"
952 # define ALIGNMENT 4 /* Required by hardware */
957 # define DATASTART ((ptr_t)(&_fdata))
959 # define HEAP_START (ptr_t)0x30000000
961 # define HEAP_START DATASTART
963 /* Lowest plausible heap address. */
964 /* In the MMAP case, we map there. */
965 /* In either case it is used to identify */
966 /* heap sections so they're not */
967 /* considered as roots. */
968 # define OS_TYPE "IRIX5"
969 # define MPROTECT_VDB
971 # define CPP_WORDSZ _MIPS_SZPTR
972 # define ALIGNMENT (_MIPS_SZPTR/8)
973 # if CPP_WORDSZ != 64
974 # define ALIGN_DOUBLE
978 # define ALIGN_DOUBLE
980 # define DYNAMIC_LOADING
982 # endif /* DATASTART_IS_ETEXT */
985 extern char __ram_data_start
;
986 extern char __ram_data_end
;
987 # define MACH_TYPE "MIPS"
988 # define DATASTART (ptr_t)(&__ram_data_start)
989 # define DATAEND (ptr_t)(&__ram_data_end)
993 # define ALIGN_DOUBLE
998 # define MACH_TYPE "RS6000"
1000 # define DATASTART ((ptr_t)0x20000000)
1002 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
1003 # define DYNAMIC_LOADING
1004 /* For really old versions of AIX, this may have to be removed. */
1008 /* OS is assumed to be HP/UX */
1009 # define MACH_TYPE "HP_PA"
1010 # define OS_TYPE "HPUX"
1012 # define CPP_WORDSZ 64
1013 # define ALIGNMENT 8
1015 # define CPP_WORDSZ 32
1016 # define ALIGNMENT 4
1017 # define ALIGN_DOUBLE
1019 extern int __data_start
;
1020 # define DATASTART ((ptr_t)(&__data_start))
1022 /* The following appears to work for 7xx systems running HP/UX */
1023 /* 9.xx Furthermore, it might result in much faster */
1024 /* collections than HEURISTIC2, which may involve scanning */
1025 /* segments that directly precede the stack. It is not the */
1026 /* default, since it may not work on older machine/OS */
1027 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1029 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
1031 /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
1032 /* to this. We'll probably do this on other platforms, too. */
1033 /* For now I'll use it where I can test it. */
1034 extern char ** environ
;
1035 # define STACKBOTTOM ((ptr_t)environ)
1037 # define STACK_GROWS_UP
1038 # define DYNAMIC_LOADING
1039 # ifndef HPUX_THREADS
1040 # define MPROTECT_VDB
1042 # include <unistd.h>
1043 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1047 # define MACH_TYPE "ALPHA"
1048 # define ALIGNMENT 8
1049 # define USE_GENERIC_PUSH_REGS
1050 /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1051 /* fp registers in some cases when the target is a 21264. The assembly */
1052 /* code doesn't handle that yet, and version dependencies make that a */
1053 /* bit tricky. Do the easy thing for now. */
1055 # define OS_TYPE "OSF1"
1056 # define DATASTART ((ptr_t) 0x140000000)
1058 # define DATAEND ((ptr_t) &_end)
1060 /* Normally HEURISTIC2 is too conervative, since */
1061 /* the text segment immediately follows the stack. */
1062 /* Hence we give an upper pound. */
1064 # define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
1065 # define CPP_WORDSZ 64
1066 # define MPROTECT_VDB
1067 # define DYNAMIC_LOADING
1070 # define OS_TYPE "LINUX"
1071 # define CPP_WORDSZ 64
1072 # define STACKBOTTOM ((ptr_t) 0x120000000)
1074 # define LINUX_DATA_START
1075 # define DYNAMIC_LOADING
1076 /* This doesn't work if the collector is in a dynamic library. */
1078 # define DATASTART ((ptr_t) 0x140000000)
1081 # define DATAEND (&_end)
1082 # undef MPROTECT_VDB
1083 /* Has only been superficially tested. May not */
1084 /* work on all versions. */
1089 # define MACH_TYPE "IA64"
1090 # define ALIGN_DOUBLE
1091 /* Requires 16 byte alignment for malloc */
1092 # define ALIGNMENT 8
1093 # define USE_GENERIC_PUSH_REGS
1094 /* We need to get preserved registers in addition to register windows. */
1095 /* That's easiest to do with setjmp. */
1100 # define OS_TYPE "LINUX"
1101 # define CPP_WORDSZ 64
1102 /* This should really be done through /proc, but that */
1103 /* requires we run on an IA64 kernel. */
1104 # define STACKBOTTOM ((ptr_t) 0xa000000000000000l)
1105 /* We also need the base address of the register stack */
1106 /* backing store. There is probably a better way to */
1107 /* get that, too ... */
1108 # define BACKING_STORE_BASE ((ptr_t) 0x9fffffff80000000l)
1110 # define SEARCH_FOR_DATA_START
1111 # define DATASTART GC_data_start
1113 extern int data_start
;
1114 # define DATASTART ((ptr_t)(&data_start))
1116 # define DYNAMIC_LOADING
1117 # define MPROTECT_VDB
1118 /* Requires Linux 2.3.47 or later. */
1120 # define DATAEND (&_end)
1121 # define PREFETCH(x) \
1122 __asm__ (" lfetch [%0]": : "r"((void *)(x)))
1123 # define PREFETCH_FOR_WRITE(x) \
1124 __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
1125 # define CLEAR_DOUBLE(x) \
1126 __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
1131 # define MACH_TYPE "M88K"
1132 # define ALIGNMENT 4
1133 # define ALIGN_DOUBLE
1136 # define OS_TYPE "CX_UX"
1137 # define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1140 # define OS_TYPE "DGUX"
1141 extern char * GC_SysVGetDataStart();
1142 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
1144 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1148 # define MACH_TYPE "S370"
1149 # define OS_TYPE "UTS4"
1150 # define ALIGNMENT 4 /* Required by hardware */
1154 extern char * GC_SysVGetDataStart();
1155 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
1156 # define DATAEND (&_end)
1161 # define ALIGNMENT 4
1163 # define DATASTART ((ptr_t)(&_etext))
1168 # define CPP_WORDSZ 32
1169 # define MACH_TYPE "ARM32"
1170 # define ALIGNMENT 4
1172 # define OS_TYPE "NETBSD"
1175 # define DATASTART ((ptr_t)(&etext))
1176 # define USE_GENERIC_PUSH_REGS
1179 # define OS_TYPE "LINUX"
1182 # define STACK_GRAN 0x10000000
1183 # define USE_GENERIC_PUSH_REGS
1185 # define DYNAMIC_LOADING
1186 # include <features.h>
1187 # if defined(__GLIBC__) && __GLIBC__ >= 2
1188 # define LINUX_DATA_START
1190 extern char **__environ
;
1191 # define DATASTART ((ptr_t)(&__environ))
1192 /* hideous kludge: __environ is the first */
1193 /* word in crt0.o, and delimits the start */
1194 /* of the data segment, no matter which */
1195 /* ld options were passed through. */
1196 /* We could use _etext instead, but that */
1197 /* would include .rodata, which may */
1198 /* contain large read-only data tables */
1199 /* that we'd rather not scan. */
1202 # define DATAEND (&_end)
1205 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
1210 #ifdef LINUX_DATA_START
1211 /* Some Linux distributions arrange to define __data_start. Some */
1212 /* define data_start as a weak symbol. The latter is technically */
1213 /* broken, since the user program may define data_start, in which */
1214 /* case we lose. Nonetheless, we try both, prefering __data_start. */
1215 /* We assume gcc. */
1216 # pragma weak __data_start
1217 extern int __data_start
;
1218 # pragma weak data_start
1219 extern int data_start
;
1220 # define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
1223 # ifndef STACK_GROWS_UP
1224 # define STACK_GROWS_DOWN
1228 # define CPP_WORDSZ 32
1237 # define DATAEND (&end)
1240 # if defined(SVR4) && !defined(GETPAGESIZE)
1241 # include <unistd.h>
1242 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
1245 # ifndef GETPAGESIZE
1246 # if defined(SUNOS5) || defined(IRIX5)
1247 # include <unistd.h>
1249 # define GETPAGESIZE() getpagesize()
1252 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1253 /* OS has SVR4 generic features. Probably others also qualify. */
1257 # if defined(SUNOS5) || defined(DRSNX)
1258 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
1261 /* OS has SUNOS5 style signal handlers. */
1269 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1274 # undef DYNAMIC_LOADING
1279 # undef MPROTECT_VDB
1284 /* Postponed for now. */
1286 # undef MPROTECT_VDB
1289 # ifdef SMALL_CONFIG
1290 /* Presumably not worth the space it takes. */
1292 # undef MPROTECT_VDB
1296 # undef MPROTECT_VDB /* Can't deal with address space holes. */
1299 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1300 # define DEFAULT_VDB
1304 # define PREFETCH(x)
1305 # define NO_PREFETCH
1308 # ifndef PREFETCH_FOR_WRITE
1309 # define PREFETCH_FOR_WRITE(x)
1310 # define NO_PREFETCH_FOR_WRITE
1313 # ifndef CACHE_LINE_SIZE
1314 # define CACHE_LINE_SIZE 32 /* Wild guess */
1317 # ifndef CLEAR_DOUBLE
1318 # define CLEAR_DOUBLE(x) \
1319 ((word*)x)[0] = 0; \
1321 # endif /* CLEAR_DOUBLE */
1323 # if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
1324 # define SOLARIS_THREADS
1326 # if defined(IRIX_THREADS) && !defined(IRIX5)
1327 --> inconsistent configuration
1329 # if defined(IRIX_JDK_THREADS) && !defined(IRIX5)
1330 --> inconsistent configuration
1332 # if defined(LINUX_THREADS) && !defined(LINUX)
1333 --> inconsistent configuration
1335 # if defined(SOLARIS_THREADS) && !defined(SUNOS5)
1336 --> inconsistent configuration
1338 # if defined(HPUX_THREADS) && !defined(HPUX)
1339 --> inconsistent configuration
1341 # if defined(PCR) || defined(SRC_M3) || \
1342 defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
1343 defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
1344 defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
1348 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) \
1349 || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT)
1350 /* Use setjmp based hack to mark from callee-save registers. */
1351 # define USE_GENERIC_PUSH_REGS
1354 # define SAVE_CALL_CHAIN
1355 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
1356 /* include assembly code to do it well. */
1359 # endif /* GCCONFIG_H */