* toplev.c (rest_of_compilation): Fix thinko in this change:
[official-gcc.git] / boehm-gc / config.h
blobd3370ba6c1440ae02a01c9acf25edf97e243aa8b
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 CONFIG_H
18 # define CONFIG_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 /* Determine the machine type: */
26 # if defined(sun) && defined(mc68000)
27 # define M68K
28 # define SUNOS4
29 # define mach_type_known
30 # endif
31 # if defined(hp9000s300)
32 # define M68K
33 # define HP
34 # define mach_type_known
35 # endif
36 # if defined(__NetBSD__) && defined(m68k)
37 # define M68K
38 # define NETBSD
39 # define mach_type_known
40 # endif
41 # if defined(vax)
42 # define VAX
43 # ifdef ultrix
44 # define ULTRIX
45 # else
46 # define BSD
47 # endif
48 # define mach_type_known
49 # endif
50 # if defined(mips) || defined(__mips)
51 # define MIPS
52 # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
53 # define ULTRIX
54 # else
55 # if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) || defined(__SYSTYPE_SVR4__)
56 # define IRIX5 /* or IRIX 6.X */
57 # else
58 # define RISCOS /* or IRIX 4.X */
59 # endif
60 # endif
61 # define mach_type_known
62 # endif
63 # if defined(sequent) && defined(i386)
64 # define I386
65 # define SEQUENT
66 # define mach_type_known
67 # endif
68 # if defined(sun) && defined(i386)
69 # define I386
70 # define SUNOS5
71 # define mach_type_known
72 # endif
73 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
74 # define I386
75 # define OS2
76 # define mach_type_known
77 # endif
78 # if defined(ibm032)
79 # define RT
80 # define mach_type_known
81 # endif
82 # if defined(sun) && (defined(sparc) || defined(__sparc))
83 # define SPARC
84 /* Test for SunOS 5.x */
85 # include <errno.h>
86 # ifdef ECHRNG
87 # define SUNOS5
88 # else
89 # define SUNOS4
90 # endif
91 # define mach_type_known
92 # endif
93 # if defined(sparc) && defined(unix) && !defined(sun)
94 # define SPARC
95 # define DRSNX
96 # define mach_type_known
97 # endif
98 # if defined(_IBMR2)
99 # define RS6000
100 # define mach_type_known
101 # endif
102 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
103 /* The above test may need refinement */
104 # define I386
105 # if defined(_SCO_ELF)
106 # define SCO_ELF
107 # else
108 # define SCO
109 # endif
110 # define mach_type_known
111 # endif
112 # if defined(_AUX_SOURCE)
113 # define M68K
114 # define SYSV
115 # define mach_type_known
116 # endif
117 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1)
118 # define HP_PA
119 # define mach_type_known
120 # endif
121 # if defined(linux) && defined(i386)
122 # define I386
123 # define LINUX
124 # define mach_type_known
125 # endif
126 # if defined(linux) && defined(powerpc)
127 # define POWERPC
128 # define LINUX
129 # define mach_type_known
130 # endif
131 # if defined(__alpha) || defined(__alpha__)
132 # define ALPHA
133 # if defined(linux) || defined(__linux__)
134 # define LINUX
135 # else
136 # define OSF1 /* a.k.a Digital Unix */
137 # endif
138 # define mach_type_known
139 # endif
140 # if defined(_AMIGA)
141 # define M68K
142 # define AMIGA
143 # define mach_type_known
144 # endif
145 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
146 # define M68K
147 # define MACOS
148 # define mach_type_known
149 # endif
150 # if defined(__MWERKS__) && defined(__powerc)
151 # define POWERPC
152 # define MACOS
153 # define mach_type_known
154 # endif
155 # if defined(NeXT) && defined(mc68000)
156 # define M68K
157 # define NEXT
158 # define mach_type_known
159 # endif
160 # if defined(NeXT) && defined(i386)
161 # define I386
162 # define NEXT
163 # define mach_type_known
164 # endif
165 # if defined(__FreeBSD__) && defined(i386)
166 # define I386
167 # define FREEBSD
168 # define mach_type_known
169 # endif
170 # if defined(__NetBSD__) && defined(i386)
171 # define I386
172 # define NETBSD
173 # define mach_type_known
174 # endif
175 # if defined(bsdi) && defined(i386)
176 # define I386
177 # define BSDI
178 # define mach_type_known
179 # endif
180 # if !defined(mach_type_known) && defined(__386BSD__)
181 # define I386
182 # define THREE86BSD
183 # define mach_type_known
184 # endif
185 # if defined(_CX_UX) && defined(_M88K)
186 # define M88K
187 # define CX_UX
188 # define mach_type_known
189 # endif
190 # if defined(DGUX)
191 # define M88K
192 /* DGUX defined */
193 # define mach_type_known
194 # endif
195 # if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300)
196 # define I386
197 # define MSWIN32 /* or Win32s */
198 # define mach_type_known
199 # endif
200 # if defined(__DJGPP__)
201 # define I386
202 # ifndef DJGPP
203 # define DJGPP /* MSDOS running the DJGPP port of GCC */
204 # endif
205 # define mach_type_known
206 # endif
207 # if defined(__CYGWIN32__)
208 # define I386
209 # define CYGWIN32
210 # define mach_type_known
211 # endif
212 # if defined(__BORLANDC__)
213 # define I386
214 # define MSWIN32
215 # define mach_type_known
216 # endif
217 # if defined(_UTS) && !defined(mach_type_known)
218 # define S370
219 # define UTS4
220 # define mach_type_known
221 # endif
222 /* Ivan Demakov */
223 # if defined(__WATCOMC__) && defined(__386__)
224 # define I386
225 # if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
226 # if defined(__OS2__)
227 # define OS2
228 # else
229 # if defined(__WINDOWS_386__) || defined(__NT__)
230 # define MSWIN32
231 # else
232 # define DOS4GW
233 # endif
234 # endif
235 # endif
236 # define mach_type_known
237 # endif
238 # if defined(__pj__)
239 # define PJ
240 # define mach_type_known
241 # endif
243 /* Feel free to add more clauses here */
245 /* Or manually define the machine type here. A machine type is */
246 /* characterized by the architecture. Some */
247 /* machine types are further subdivided by OS. */
248 /* the macros ULTRIX, RISCOS, and BSD to distinguish. */
249 /* Note that SGI IRIX is treated identically to RISCOS. */
250 /* SYSV on an M68K actually means A/UX. */
251 /* The distinction in these cases is usually the stack starting address */
252 # ifndef mach_type_known
253 --> unknown machine type
254 # endif
255 /* Mapping is: M68K ==> Motorola 680X0 */
256 /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
257 /* MACOS and AMIGA variants) */
258 /* I386 ==> Intel 386 */
259 /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
260 /* FREEBSD, THREE86BSD, MSWIN32, */
261 /* BSDI, SUNOS5, NEXT variants) */
262 /* NS32K ==> Encore Multimax */
263 /* MIPS ==> R2000 or R3000 */
264 /* (RISCOS, ULTRIX variants) */
265 /* VAX ==> DEC VAX */
266 /* (BSD, ULTRIX variants) */
267 /* RS6000 ==> IBM RS/6000 AIX3.X */
268 /* RT ==> IBM PC/RT */
269 /* HP_PA ==> HP9000/700 & /800 */
270 /* HP/UX */
271 /* SPARC ==> SPARC under SunOS */
272 /* (SUNOS4, SUNOS5, */
273 /* DRSNX variants) */
274 /* ALPHA ==> DEC Alpha */
275 /* (OSF1 and LINUX variants) */
276 /* M88K ==> Motorola 88XX0 */
277 /* (CX_UX and DGUX) */
278 /* S370 ==> 370-like machine */
279 /* running Amdahl UTS4 */
283 * For each architecture and OS, the following need to be defined:
285 * CPP_WORD_SZ is a simple integer constant representing the word size.
286 * in bits. We assume byte addressibility, where a byte has 8 bits.
287 * We also assume CPP_WORD_SZ is either 32 or 64.
288 * (We care about the length of pointers, not hardware
289 * bus widths. Thus a 64 bit processor with a C compiler that uses
290 * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
292 * MACH_TYPE is a string representation of the machine type.
293 * OS_TYPE is analogous for the OS.
295 * ALIGNMENT is the largest N, such that
296 * all pointer are guaranteed to be aligned on N byte boundaries.
297 * defining it to be 1 will always work, but perform poorly.
299 * DATASTART is the beginning of the data segment.
300 * On UNIX systems, the collector will scan the area between DATASTART
301 * and DATAEND for root pointers.
303 * DATAEND, if not &end.
305 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
306 * the pointer size.
308 * STACKBOTTOM is the cool end of the stack, which is usually the
309 * highest address in the stack.
310 * Under PCR or OS/2, we have other ways of finding thread stacks.
311 * For each machine, the following should:
312 * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
313 * 2) define exactly one of
314 * STACKBOTTOM (should be defined to be an expression)
315 * HEURISTIC1
316 * HEURISTIC2
317 * If either of the last two macros are defined, then STACKBOTTOM is computed
318 * during collector startup using one of the following two heuristics:
319 * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
320 * the next multiple of STACK_GRAN.
321 * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
322 * in small steps (decrement if STACK_GROWS_UP), and read the value
323 * at each location. Remember the value when the first
324 * Segmentation violation or Bus error is signalled. Round that
325 * to the nearest plausible page boundary, and use that instead
326 * of STACKBOTTOM.
328 * If no expression for STACKBOTTOM can be found, and neither of the above
329 * heuristics are usable, the collector can still be used with all of the above
330 * undefined, provided one of the following is done:
331 * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
332 * without reference to STACKBOTTOM. This is appropriate for use in
333 * conjunction with thread packages, since there will be multiple stacks.
334 * (Allocating thread stacks in the heap, and treating them as ordinary
335 * heap data objects is also possible as a last resort. However, this is
336 * likely to introduce significant amounts of excess storage retention
337 * unless the dead parts of the thread stacks are periodically cleared.)
338 * 2) Client code may set GC_stackbottom before calling any GC_ routines.
339 * If the author of the client code controls the main program, this is
340 * easily accomplished by introducing a new main program, setting
341 * GC_stackbottom to the address of a local variable, and then calling
342 * the original main program. The new main program would read something
343 * like:
345 * # include "gc_private.h"
347 * main(argc, argv, envp)
348 * int argc;
349 * char **argv, **envp;
351 * int dummy;
353 * GC_stackbottom = (ptr_t)(&dummy);
354 * return(real_main(argc, argv, envp));
358 * Each architecture may also define the style of virtual dirty bit
359 * implementation to be used:
360 * MPROTECT_VDB: Write protect the heap and catch faults.
361 * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
363 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
364 * defined GC_register_dynamic_libraries() for the architecture.
368 # define STACK_GRAN 0x1000000
369 # ifdef M68K
370 # define MACH_TYPE "M68K"
371 # define ALIGNMENT 2
372 # ifdef NETBSD
373 # define OS_TYPE "NETBSD"
374 # define HEURISTIC2
375 extern char etext;
376 # define DATASTART ((ptr_t)(&etext))
377 # endif
378 # ifdef SUNOS4
379 # define OS_TYPE "SUNOS4"
380 extern char etext;
381 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
382 # define HEURISTIC1 /* differs */
383 # define DYNAMIC_LOADING
384 # endif
385 # ifdef HP
386 # define OS_TYPE "HP"
387 extern char etext;
388 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
389 # define STACKBOTTOM ((ptr_t) 0xffeffffc)
390 /* empirically determined. seems to work. */
391 # include <unistd.h>
392 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
393 # endif
394 # ifdef SYSV
395 # define OS_TYPE "SYSV"
396 extern etext;
397 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
398 & ~0x3fffff) \
399 +((word)&etext & 0x1fff))
400 /* This only works for shared-text binaries with magic number 0413.
401 The other sorts of SysV binaries put the data at the end of the text,
402 in which case the default of &etext would work. Unfortunately,
403 handling both would require having the magic-number available.
404 -- Parag
406 # define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
407 /* The stack starts at the top of memory, but */
408 /* 0x0 cannot be used as setjump_test complains */
409 /* that the stack direction is incorrect. Two */
410 /* bytes down from 0x0 should be safe enough. */
411 /* --Parag */
412 # include <sys/mmu.h>
413 # define GETPAGESIZE() PAGESIZE /* Is this still right? */
414 # endif
415 # ifdef AMIGA
416 # define OS_TYPE "AMIGA"
417 /* STACKBOTTOM and DATASTART handled specially */
418 /* in os_dep.c */
419 # define DATAEND /* not needed */
420 # define GETPAGESIZE() 4096
421 # endif
422 # ifdef MACOS
423 # ifndef __LOWMEM__
424 # include <LowMem.h>
425 # endif
426 # define OS_TYPE "MACOS"
427 /* see os_dep.c for details of global data segments. */
428 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
429 # define DATAEND /* not needed */
430 # define GETPAGESIZE() 4096
431 # endif
432 # ifdef NEXT
433 # define OS_TYPE "NEXT"
434 # define DATASTART ((ptr_t) get_etext())
435 # define STACKBOTTOM ((ptr_t) 0x4000000)
436 # define DATAEND /* not needed */
437 # endif
438 # endif
440 # ifdef POWERPC
441 # define MACH_TYPE "POWERPC"
442 # define ALIGNMENT 2
443 # ifdef MACOS
444 # ifndef __LOWMEM__
445 # include <LowMem.h>
446 # endif
447 # define OS_TYPE "MACOS"
448 /* see os_dep.c for details of global data segments. */
449 # define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
450 # define DATAEND /* not needed */
451 # endif
452 # ifdef LINUX
453 # define OS_TYPE "LINUX"
454 # define STACKBOTTOM ((ptr_t)0x80000000)
455 # define DATASTART GC_data_start
456 extern int _end;
457 # define DATAEND (&_end)
458 # endif
459 # endif
461 # ifdef VAX
462 # define MACH_TYPE "VAX"
463 # define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
464 extern char etext;
465 # define DATASTART ((ptr_t)(&etext))
466 # ifdef BSD
467 # define OS_TYPE "BSD"
468 # define HEURISTIC1
469 /* HEURISTIC2 may be OK, but it's hard to test. */
470 # endif
471 # ifdef ULTRIX
472 # define OS_TYPE "ULTRIX"
473 # define STACKBOTTOM ((ptr_t) 0x7fffc800)
474 # endif
475 # endif
477 # ifdef RT
478 # define MACH_TYPE "RT"
479 # define ALIGNMENT 4
480 # define DATASTART ((ptr_t) 0x10000000)
481 # define STACKBOTTOM ((ptr_t) 0x1fffd800)
482 # endif
484 # ifdef SPARC
485 # define MACH_TYPE "SPARC"
486 # define ALIGNMENT 4 /* Required by hardware */
487 # define ALIGN_DOUBLE
488 extern int etext;
489 # ifdef SUNOS5
490 # define OS_TYPE "SUNOS5"
491 extern int _etext;
492 extern int _end;
493 extern char * GC_SysVGetDataStart();
494 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
495 # define DATAEND (&_end)
496 # ifndef USE_MMAP
497 # define USE_MMAP
498 # endif
499 # ifdef USE_MMAP
500 # define HEAP_START (ptr_t)0x40000000
501 # else
502 # define HEAP_START DATAEND
503 # endif
504 # define PROC_VDB
505 # define HEURISTIC1
506 # include <unistd.h>
507 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
508 /* getpagesize() appeared to be missing from at least one */
509 /* Solaris 5.4 installation. Weird. */
510 # endif
511 # ifdef SUNOS4
512 # define OS_TYPE "SUNOS4"
513 /* [If you have a weak stomach, don't read this.] */
514 /* We would like to use: */
515 /* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
516 /* This fails occasionally, due to an ancient, but very */
517 /* persistent ld bug. &etext is set 32 bytes too high. */
518 /* We instead read the text segment size from the a.out */
519 /* header, which happens to be mapped into our address space */
520 /* at the start of the text segment. The detective work here */
521 /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
522 /* Serpette of INRIA. */
523 /* This assumes ZMAGIC, i.e. demand-loadable executables. */
524 # define TEXTSTART 0x2000
525 # define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
526 # define MPROTECT_VDB
527 # define HEURISTIC1
528 # endif
529 # ifdef DRSNX
530 # define CPP_WORDSZ 32
531 # define OS_TYPE "DRSNX"
532 extern char * GC_SysVGetDataStart();
533 extern int etext;
534 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
535 # define MPROTECT_VDB
536 # define STACKBOTTOM ((ptr_t) 0xdfff0000)
537 # endif
538 # define DYNAMIC_LOADING
539 # endif
541 # ifdef I386
542 # define MACH_TYPE "I386"
543 # define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
544 /* except Borland. The -a4 option fixes */
545 /* Borland. */
546 /* Ivan Demakov: For Watcom the option is -zp4. */
547 # ifndef SMALL_CONFIG
548 # define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
549 /* improvement on Pentiums. */
550 # endif
551 # ifdef SEQUENT
552 # define OS_TYPE "SEQUENT"
553 extern int etext;
554 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
555 # define STACKBOTTOM ((ptr_t) 0x3ffff000)
556 # endif
557 # ifdef SUNOS5
558 # define OS_TYPE "SUNOS5"
559 extern int etext, _start;
560 extern char * GC_SysVGetDataStart();
561 # define DATASTART GC_SysVGetDataStart(0x1000, &etext)
562 # define STACKBOTTOM ((ptr_t)(&_start))
563 /** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
564 /*# define PROC_VDB*/
565 # define DYNAMIC_LOADING
566 # ifndef USE_MMAP
567 # define USE_MMAP
568 # endif
569 # ifdef USE_MMAP
570 # define HEAP_START (ptr_t)0x40000000
571 # else
572 # define HEAP_START DATAEND
573 # endif
574 # endif
575 # ifdef SCO
576 # define OS_TYPE "SCO"
577 extern int etext;
578 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
579 & ~0x3fffff) \
580 +((word)&etext & 0xfff))
581 # define STACKBOTTOM ((ptr_t) 0x7ffffffc)
582 # endif
583 # ifdef SCO_ELF
584 # define OS_TYPE "SCO_ELF"
585 extern int etext;
586 # define DATASTART ((ptr_t)(&etext))
587 # define STACKBOTTOM ((ptr_t) 0x08048000)
588 # define DYNAMIC_LOADING
589 # define ELF_CLASS ELFCLASS32
590 # endif
591 # ifdef LINUX
592 # define OS_TYPE "LINUX"
593 # define STACKBOTTOM ((ptr_t)0xc0000000)
594 /* Appears to be 0xe0000000 for at least one 2.1.91 kernel. */
595 /* Probably needs to be more flexible, but I don't yet */
596 /* fully understand how flexible. */
598 /* Linux threads don't interact well with the read() wrapper.
599 Not defining MPROTECT_VDB fixes this. */
600 /* # define MPROTECT_VDB*/
601 # ifdef __ELF__
602 # define DYNAMIC_LOADING
603 # ifdef UNDEFINED /* includes ro data */
604 extern int _etext;
605 # define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
606 # endif
607 # include <linux/version.h>
608 # include <features.h>
609 # if LINUX_VERSION_CODE >= 0x20000 && defined(__GLIBC__) && __GLIBC__ >= 2
610 extern int __data_start;
611 # define DATASTART ((ptr_t)(&__data_start))
612 # else
613 extern char **__environ;
614 # define DATASTART ((ptr_t)(&__environ))
615 /* hideous kludge: __environ is the first */
616 /* word in crt0.o, and delimits the start */
617 /* of the data segment, no matter which */
618 /* ld options were passed through. */
619 /* We could use _etext instead, but that */
620 /* would include .rodata, which may */
621 /* contain large read-only data tables */
622 /* that we'd rather not scan. */
623 # endif
624 extern int _end;
625 # define DATAEND (&_end)
626 # else
627 extern int etext;
628 # define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
629 # endif
630 # endif
631 # ifdef CYGWIN32
632 extern int _data_start__;
633 extern int _data_end__;
634 extern int _bss_start__;
635 extern int _bss_end__;
636 /* For binutils 2.9.1, we have */
637 /* DATASTART = _data_start__ */
638 /* DATAEND = _bss_end__ */
639 /* whereas for some earlier versions it was */
640 /* DATASTART = _bss_start__ */
641 /* DATAEND = _data_end__ */
642 /* To get it right for both, we take the */
643 /* minumum/maximum of the two. */
644 # define MAX(x,y) ((x) > (y) ? (x) : (y))
645 # define MIN(x,y) ((x) < (y) ? (x) : (y))
646 # define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
647 # define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
648 # undef STACK_GRAN
649 # define STACK_GRAN 0x10000
650 # define HEURISTIC1
651 # endif
652 # ifdef OS2
653 # define OS_TYPE "OS2"
654 /* STACKBOTTOM and DATASTART are handled specially in */
655 /* os_dep.c. OS2 actually has the right */
656 /* system call! */
657 # define DATAEND /* not needed */
658 # endif
659 # ifdef MSWIN32
660 # define OS_TYPE "MSWIN32"
661 /* STACKBOTTOM and DATASTART are handled specially in */
662 /* os_dep.c. */
663 # ifndef __WATCOMC__
664 # define MPROTECT_VDB
665 # endif
666 # define DATAEND /* not needed */
667 # endif
668 # ifdef DJGPP
669 # define OS_TYPE "DJGPP"
670 # include "stubinfo.h"
671 extern int etext;
672 extern int _stklen;
673 # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
674 # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
675 + _stklen))
676 /* This may not be right. */
677 # endif
678 # ifdef FREEBSD
679 # define OS_TYPE "FREEBSD"
680 # define MPROTECT_VDB
681 # endif
682 # ifdef NETBSD
683 # define OS_TYPE "NETBSD"
684 # endif
685 # ifdef THREE86BSD
686 # define OS_TYPE "THREE86BSD"
687 # endif
688 # ifdef BSDI
689 # define OS_TYPE "BSDI"
690 # endif
691 # if defined(FREEBSD) || defined(NETBSD) \
692 || defined(THREE86BSD) || defined(BSDI)
693 # define HEURISTIC2
694 extern char etext;
695 # define DATASTART ((ptr_t)(&etext))
696 # endif
697 # ifdef NEXT
698 # define OS_TYPE "NEXT"
699 # define DATASTART ((ptr_t) get_etext())
700 # define STACKBOTTOM ((ptr_t)0xc0000000)
701 # define DATAEND /* not needed */
702 # endif
703 # ifdef DOS4GW
704 # define OS_TYPE "DOS4GW"
705 /* Get_DATASTART, Get_DATAEND, Get_STACKBOTTOM
706 * Defined in gc-watcom.asm
708 extern char* Get_DATASTART (void);
709 extern char* Get_DATAEND (void);
710 extern char* Get_STACKBOTTOM (void);
711 # pragma aux Get_DATASTART "*" value [eax];
712 # pragma aux Get_DATAEND "*" value [eax];
713 # pragma aux Get_STACKBOTTOM "*" value [eax];
714 # define DATASTART ((ptr_t) Get_DATASTART())
715 # define STACKBOTTOM ((ptr_t) Get_STACKBOTTOM())
716 # define DATAEND ((ptr_t) Get_DATAEND())
717 # endif
718 # endif
720 # ifdef NS32K
721 # define MACH_TYPE "NS32K"
722 # define ALIGNMENT 4
723 extern char **environ;
724 # define DATASTART ((ptr_t)(&environ))
725 /* hideous kludge: environ is the first */
726 /* word in crt0.o, and delimits the start */
727 /* of the data segment, no matter which */
728 /* ld options were passed through. */
729 # define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
730 # endif
732 # ifdef MIPS
733 # ifndef ECOS
734 # define MACH_TYPE "MIPS"
735 /* CYGNUS LOCAL: respect predefined DATASTART_IS_ETEXT. */
736 # ifdef DATASTART_IS_ETEXT
737 extern int _etext;
738 # define DATASTART ((ptr_t)(&_etext))
739 # else
740 # ifndef IRIX5
741 # define DATASTART (ptr_t)0x10000000
742 /* Could probably be slightly higher since */
743 /* startup code allocates lots of stuff. */
744 # else
745 extern int _fdata;
746 # define DATASTART ((ptr_t)(&_fdata))
747 # ifdef USE_MMAP
748 # define HEAP_START (ptr_t)0x30000000
749 # else
750 # define HEAP_START DATASTART
751 # endif
752 /* Lowest plausible heap address. */
753 /* In the MMAP case, we map there. */
754 /* In either case it is used to identify */
755 /* heap sections so they're not */
756 /* considered as roots. */
757 # endif /* IRIX5 */
758 # endif /* DATASTART_IS_ETEXT */
759 # define HEURISTIC2
760 /* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */
761 # ifdef ULTRIX
762 # define OS_TYPE "ULTRIX"
763 # define ALIGNMENT 4
764 # endif
765 # ifdef RISCOS
766 # define OS_TYPE "RISCOS"
767 # define ALIGNMENT 4 /* Required by hardware */
768 # endif
769 # ifdef IRIX5
770 # define OS_TYPE "IRIX5"
771 # define MPROTECT_VDB
772 # ifdef _MIPS_SZPTR
773 # define CPP_WORDSZ _MIPS_SZPTR
774 # define ALIGNMENT (_MIPS_SZPTR/8)
775 # if CPP_WORDSZ != 64
776 # define ALIGN_DOUBLE
777 # endif
778 # else
779 # define ALIGNMENT 4
780 # define ALIGN_DOUBLE
781 # endif
782 # define DYNAMIC_LOADING
783 # endif
784 # endif /* ECOS */
785 # ifdef ECOS
786 extern char __ram_data_start;
787 extern char __ram_data_end;
788 # define MACH_TYPE "MIPS"
789 # define DATASTART (ptr_t)(&__ram_data_start)
790 # define DATAEND (ptr_t)(&__ram_data_end)
792 # define HEURISTIC2
793 # define ALIGNMENT 4
794 # define ALIGN_DOUBLE
795 # endif /* ECOS */
796 # endif
798 # ifdef RS6000
799 # define MACH_TYPE "RS6000"
800 # define ALIGNMENT 4
801 # define DATASTART ((ptr_t)0x20000000)
802 extern int errno;
803 # define STACKBOTTOM ((ptr_t)((ulong)&errno))
804 # define DYNAMIC_LOADING
805 /* For really old versions of AIX, this may have to be removed. */
806 # endif
808 # ifdef HP_PA
809 # define MACH_TYPE "HP_PA"
810 # define ALIGNMENT 4
811 # define ALIGN_DOUBLE
812 extern int __data_start;
813 # define DATASTART ((ptr_t)(&__data_start))
814 # if 0
815 /* The following appears to work for 7xx systems running HP/UX */
816 /* 9.xx Furthermore, it might result in much faster */
817 /* collections than HEURISTIC2, which may involve scanning */
818 /* segments that directly precede the stack. It is not the */
819 /* default, since it may not work on older machine/OS */
820 /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
821 /* this.) */
822 # define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
823 # else
824 # define HEURISTIC2
825 # endif
826 # define STACK_GROWS_UP
827 # define DYNAMIC_LOADING
828 # include <unistd.h>
829 # define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
830 /* They misspelled the Posix macro? */
831 # endif
833 # ifdef ALPHA
834 # define MACH_TYPE "ALPHA"
835 # define ALIGNMENT 8
836 # ifdef OSF1
837 # define OS_TYPE "OSF1"
838 # define DATASTART ((ptr_t) 0x140000000)
839 # define HEURISTIC2
840 /* Normally HEURISTIC2 is too conervative, since */
841 /* the text segment immediately follows the stack. */
842 /* Hence we give an upper pound. */
843 extern int __start;
844 # define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
845 # define CPP_WORDSZ 64
846 # define MPROTECT_VDB
847 # define DYNAMIC_LOADING
848 # endif
849 # ifdef LINUX
850 # define OS_TYPE "LINUX"
851 # define CPP_WORDSZ 64
852 # define STACKBOTTOM ((ptr_t) 0x120000000)
853 # ifdef __ELF__
854 # define DATASTART GC_data_start
855 # define USE_PROC
856 # define DYNAMIC_LOADING
857 # else
858 # define DATASTART ((ptr_t) 0x140000000)
859 # endif
860 extern int _end;
861 # define DATAEND (&_end)
862 /* As of 1.3.90, I couldn't find a way to retrieve the correct */
863 /* fault address from a signal handler. */
864 /* Hence MPROTECT_VDB is broken. */
865 # endif
866 # endif
868 # ifdef M88K
869 # define MACH_TYPE "M88K"
870 # define ALIGNMENT 4
871 # define ALIGN_DOUBLE
872 extern int etext;
873 # ifdef CX_UX
874 # define OS_TYPE "CX_UX"
875 # define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
876 # endif
877 # ifdef DGUX
878 # define OS_TYPE "DGUX"
879 extern char * GC_SysVGetDataStart();
880 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
881 # endif
882 # define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
883 # endif
885 # ifdef S370
886 # define MACH_TYPE "S370"
887 # define OS_TYPE "UTS4"
888 # define ALIGNMENT 4 /* Required by hardware */
889 extern int etext;
890 extern int _etext;
891 extern int _end;
892 extern char * GC_SysVGetDataStart();
893 # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
894 # define DATAEND (&_end)
895 # define HEURISTIC2
896 # endif
898 # ifndef STACK_GROWS_UP
899 # define STACK_GROWS_DOWN
900 # endif
902 # ifndef CPP_WORDSZ
903 # define CPP_WORDSZ 32
904 # endif
906 # ifndef OS_TYPE
907 # define OS_TYPE ""
908 # endif
910 # ifndef DATAEND
911 extern int end;
912 # define DATAEND (&end)
913 # endif
915 # if defined(SVR4) && !defined(GETPAGESIZE)
916 # include <unistd.h>
917 # define GETPAGESIZE() sysconf(_SC_PAGESIZE)
918 # endif
920 # ifndef GETPAGESIZE
921 # if defined(SUNOS5) || defined(IRIX5)
922 # include <unistd.h>
923 # endif
924 # define GETPAGESIZE() getpagesize()
925 # endif
927 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
928 /* OS has SVR4 generic features. Probably others also qualify. */
929 # define SVR4
930 # endif
932 # if defined(SUNOS5) || defined(DRSNX)
933 /* OS has SUNOS5 style semi-undocumented interface to dynamic */
934 /* loader. */
935 # define SUNOS5DL
936 /* OS has SUNOS5 style signal handlers. */
937 # define SUNOS5SIGS
938 # endif
940 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
941 -> bad word size
942 # endif
944 # ifdef PCR
945 # undef DYNAMIC_LOADING
946 # undef STACKBOTTOM
947 # undef HEURISTIC1
948 # undef HEURISTIC2
949 # undef PROC_VDB
950 # undef MPROTECT_VDB
951 # define PCR_VDB
952 # endif
954 # ifdef SRC_M3
955 /* Postponed for now. */
956 # undef PROC_VDB
957 # undef MPROTECT_VDB
958 # endif
960 # ifdef SMALL_CONFIG
961 /* Presumably not worth the space it takes. */
962 # undef PROC_VDB
963 # undef MPROTECT_VDB
964 # endif
966 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
967 # define DEFAULT_VDB
968 # endif
970 # if defined(IRIX_THREADS) && !defined(IRIX5)
971 --> inconsistent configuration
972 # endif
973 # if defined(LINUX_THREADS) && !defined(LINUX)
974 --> inconsistent configuration
975 # endif
976 # if defined(SOLARIS_THREADS) && !defined(SUNOS5)
977 --> inconsistent configuration
978 # endif
979 # if defined(PCR) || defined(SRC_M3) || \
980 defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
981 defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
982 defined(QUICK_THREADS)
983 # define THREADS
984 # endif
986 # if defined(SPARC)
987 # define SAVE_CALL_CHAIN
988 # define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
989 /* include assembly code to do it well. */
990 # endif
992 # if defined(PJ)
993 # define ALIGNMENT 4
994 extern int _etext;
995 # define DATASTART ((ptr_t)(&_etext))
996 # define HEURISTIC1
997 # endif
999 # endif