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