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