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