OSDN Git Service

75405dcd7af73e64826c49fe99acc4b5693a5580
[pf3gnuchains/gcc-fork.git] / boehm-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  * Copyright (c) 2000 by Hewlett-Packard Company.  All rights reserved.
6  *
7  * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
8  * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
9  *
10  * Permission is hereby granted to use or copy this program
11  * for any purpose,  provided the above notices are retained on all copies.
12  * Permission to modify the code and to distribute modified code is granted,
13  * provided the above notices are retained, and a notice that the code was
14  * modified is included with the above copyright notice.
15  */
16  
17 #ifndef GCCONFIG_H
18
19 # define GCCONFIG_H
20
21 /* Machine dependent parameters.  Some tuning parameters can be found   */
22 /* near the top of gc_private.h.                                        */
23
24 /* Machine specific parts contributed by various people.  See README file. */
25
26 /* First a unified test for Linux: */
27 # if defined(linux) || defined(__linux__)
28 #    define LINUX
29 # endif
30
31 /* And one for NetBSD: */
32 # if defined(__NetBSD__)
33 #    define NETBSD
34 # endif
35
36 /* And one for OpenBSD: */
37 # if defined(__OpenBSD__)
38 #    define OPENBSD
39 # endif
40
41 /* Determine the machine type: */
42 # if defined(sun) && defined(mc68000)
43 #    define M68K
44 #    define SUNOS4
45 #    define mach_type_known
46 # endif
47 # if defined(hp9000s300)
48 #    define M68K
49 #    define HP
50 #    define mach_type_known
51 # endif
52 # if defined(OPENBSD) && defined(m68k)
53 #    define M68K
54 #    define mach_type_known
55 # endif
56 # if defined(OPENBSD) && defined(__sparc__)
57 #    define SPARC
58 #    define mach_type_known
59 # endif
60 # if defined(NETBSD) && defined(m68k)
61 #    define M68K
62 #    define mach_type_known
63 # endif
64 # if defined(NETBSD) && defined(__powerpc__)
65 #    define POWERPC
66 #    define mach_type_known
67 # endif
68 # if defined(NETBSD) && defined(__arm32__)
69 #    define ARM32
70 #    define mach_type_known
71 # endif
72 # if defined(vax)
73 #    define VAX
74 #    ifdef ultrix
75 #       define ULTRIX
76 #    else
77 #       define BSD
78 #    endif
79 #    define mach_type_known
80 # endif
81 # if defined(mips) || defined(__mips)
82 #    define MIPS
83 #    if !defined(LINUX)
84 #      if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
85 #        define ULTRIX
86 #      else
87 #        if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
88             || defined(__SYSTYPE_SVR4__)
89 #          define IRIX5   /* or IRIX 6.X */
90 #        else
91 #          define RISCOS  /* or IRIX 4.X */
92 #        endif
93 #      endif
94 #    endif /* !LINUX */
95 #    if defined(__NetBSD__) && defined(__MIPSEL__)
96 #      undef ULTRIX
97 #    endif
98 #    define mach_type_known
99 # endif
100 # if defined(sequent) && (defined(i386) || defined(__i386__))
101 #    define I386
102 #    define SEQUENT
103 #    define mach_type_known
104 # endif
105 # if defined(sun) && (defined(i386) || defined(__i386__))
106 #    define I386
107 #    define SUNOS5
108 #    define mach_type_known
109 # endif
110 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
111 #    define I386
112 #    define OS2
113 #    define mach_type_known
114 # endif
115 # if defined(ibm032)
116 #   define RT
117 #   define mach_type_known
118 # endif
119 # if defined(sun) && (defined(sparc) || defined(__sparc))
120 #   define SPARC
121     /* Test for SunOS 5.x */
122 #     include <errno.h>
123 #     ifdef ECHRNG
124 #       define SUNOS5
125 #     else
126 #       define SUNOS4
127 #     endif
128 #   define mach_type_known
129 # endif
130 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
131      && !defined(__OpenBSD__) && !(__NetBSD__)
132 #   define SPARC
133 #   define DRSNX
134 #   define mach_type_known
135 # endif
136 # if defined(_IBMR2)
137 #   define RS6000
138 #   define mach_type_known
139 # endif
140 # if defined(__NetBSD__) && defined(__sparc__)
141 #   define SPARC
142 #   define mach_type_known
143 # endif
144 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
145         /* The above test may need refinement   */
146 #   define I386
147 #   if defined(_SCO_ELF)
148 #     define SCO_ELF
149 #   else
150 #     define SCO
151 #   endif
152 #   define mach_type_known
153 # endif
154 # if defined(_AUX_SOURCE)
155 #   define M68K
156 #   define SYSV
157 #   define mach_type_known
158 # endif
159 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
160      || defined(hppa) || defined(__hppa__)
161 #   define HP_PA
162 #   ifndef LINUX
163 #     define HPUX
164 #   endif
165 #   define mach_type_known
166 # endif
167 # if defined(__ia64) && defined(_HPUX_SOURCE)
168 #   define IA64
169 #   define HPUX
170 #   define mach_type_known
171 # endif
172 # if defined(__BEOS__) && defined(_X86_)
173 #    define I386
174 #    define BEOS
175 #    define mach_type_known
176 # endif
177 # if defined(LINUX) && (defined(i386) || defined(__i386__))
178 #    define I386
179 #    define mach_type_known
180 # endif
181 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
182 #    define IA64
183 #    define mach_type_known
184 # endif
185 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__))
186 #    define POWERPC
187 #    define mach_type_known
188 # endif
189 # if defined(LINUX) && defined(__mc68000__)
190 #    define M68K
191 #    define mach_type_known
192 # endif
193 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
194 #    define SPARC
195 #    define mach_type_known
196 # endif
197 # if defined(LINUX) && defined(__arm__)
198 #    define ARM32
199 #    define mach_type_known
200 # endif
201 # if defined(LINUX) && defined(__sh__)
202 #    define SH
203 #    define mach_type_known
204 # endif
205 # if defined(__alpha) || defined(__alpha__)
206 #   define ALPHA
207 #   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD)
208 #     define OSF1       /* a.k.a Digital Unix */
209 #   endif
210 #   define mach_type_known
211 # endif
212 # if defined(_AMIGA) && !defined(AMIGA)
213 #   define AMIGA
214 # endif
215 # ifdef AMIGA 
216 #   define M68K
217 #   define mach_type_known
218 # endif
219 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
220 #   define M68K
221 #   define MACOS
222 #   define mach_type_known
223 # endif
224 # if defined(__MWERKS__) && defined(__powerc)
225 #   define POWERPC
226 #   define MACOS
227 #   define mach_type_known
228 # endif
229 # if defined(macosx) || \
230      defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
231 #    define MACOSX
232 #    define POWERPC
233 #    define mach_type_known
234 # endif
235 # if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
236 #    define MACOSX
237 #    define I386
238      --> Not really supported, but at least we recognize it.
239 # endif
240 # if defined(NeXT) && defined(mc68000)
241 #   define M68K
242 #   define NEXT
243 #   define mach_type_known
244 # endif
245 # if defined(NeXT) && (defined(i386) || defined(__i386__))
246 #   define I386
247 #   define NEXT
248 #   define mach_type_known
249 # endif
250 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
251 #   define I386
252 #   define OPENBSD
253 #   define mach_type_known
254 # endif
255 # if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
256 #   define I386
257 #   define FREEBSD
258 #   define mach_type_known
259 # endif
260 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
261 #   define I386
262 #   define mach_type_known
263 # endif
264 # if defined(bsdi) && (defined(i386) || defined(__i386__))
265 #    define I386
266 #    define BSDI
267 #    define mach_type_known
268 # endif
269 # if !defined(mach_type_known) && defined(__386BSD__)
270 #   define I386
271 #   define THREE86BSD
272 #   define mach_type_known
273 # endif
274 # if defined(_CX_UX) && defined(_M88K)
275 #   define M88K
276 #   define CX_UX
277 #   define mach_type_known
278 # endif
279 # if defined(DGUX)
280 #   define M88K
281     /* DGUX defined */
282 #   define mach_type_known
283 # endif
284 # if defined(_WIN32_WCE)
285     /* SH3, SH4, MIPS already defined for corresponding architectures */
286 #   if defined(SH3) || defined(SH4)
287 #     define SH
288 #   endif
289 #   if defined(x86)
290 #     define I386
291 #   endif
292 #   if defined(ARM)
293 #     define ARM32
294 #   endif
295 #   define MSWINCE
296 #   define mach_type_known
297 # else
298 #   if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
299         || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
300 #     define I386
301 #     define MSWIN32    /* or Win32s */
302 #     define mach_type_known
303 #   endif
304 # endif
305 # if defined(__DJGPP__)
306 #   define I386
307 #   ifndef DJGPP
308 #     define DJGPP  /* MSDOS running the DJGPP port of GCC */
309 #   endif
310 #   define mach_type_known
311 # endif
312 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
313 #   define I386
314 #   define CYGWIN32
315 #   define mach_type_known
316 # endif
317 # if defined(__MINGW32__)
318 #   define I386
319 #   define MSWIN32
320 #   define mach_type_known
321 # endif
322 # if defined(__BORLANDC__)
323 #   define I386
324 #   define MSWIN32
325 #   define mach_type_known
326 # endif
327 # if defined(_UTS) && !defined(mach_type_known)
328 #   define S370
329 #   define UTS4
330 #   define mach_type_known
331 # endif
332 # if defined(__pj__)
333 #   define PJ
334 #   define mach_type_known
335 # endif
336 # if defined(__embedded__) && defined(PPC)
337 #   define POWERPC
338 #   define NOSYS
339 #   define mach_type_known
340 # endif
341 /* Ivan Demakov */
342 # if defined(__WATCOMC__) && defined(__386__)
343 #   define I386
344 #   if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
345 #     if defined(__OS2__)
346 #       define OS2
347 #     else
348 #       if defined(__WINDOWS_386__) || defined(__NT__)
349 #         define MSWIN32
350 #       else
351 #         define DOS4GW
352 #       endif
353 #     endif
354 #   endif
355 #   define mach_type_known
356 # endif
357 # if defined(__s390__) && defined(LINUX)
358 #    define S370
359 #    define mach_type_known
360 # endif
361 # if defined(__GNU__)
362 #   if defined(__i386__)
363 /* The Debian Hurd running on generic PC */  
364 #     define  HURD
365 #     define  I386
366 #     define  mach_type_known
367 #    endif 
368 # endif
369
370 /* Feel free to add more clauses here */
371
372 /* Or manually define the machine type here.  A machine type is         */
373 /* characterized by the architecture.  Some                             */
374 /* machine types are further subdivided by OS.                          */
375 /* the macros ULTRIX, RISCOS, and BSD to distinguish.                   */
376 /* Note that SGI IRIX is treated identically to RISCOS.                 */
377 /* SYSV on an M68K actually means A/UX.                                 */
378 /* The distinction in these cases is usually the stack starting address */
379 # ifndef mach_type_known
380         --> unknown machine type
381 # endif
382                     /* Mapping is: M68K       ==> Motorola 680X0        */
383                     /*             (SUNOS4,HP,NEXT, and SYSV (A/UX),    */
384                     /*             MACOS and AMIGA variants)            */
385                     /*             I386       ==> Intel 386             */
386                     /*              (SEQUENT, OS2, SCO, LINUX, NETBSD,  */
387                     /*               FREEBSD, THREE86BSD, MSWIN32,      */
388                     /*               BSDI,SUNOS5, NEXT, other variants) */
389                     /*             NS32K      ==> Encore Multimax       */
390                     /*             MIPS       ==> R2000 or R3000        */
391                     /*                  (RISCOS, ULTRIX variants)       */
392                     /*             VAX        ==> DEC VAX               */
393                     /*                  (BSD, ULTRIX variants)          */
394                     /*             RS6000     ==> IBM RS/6000 AIX3.X    */
395                     /*             RT         ==> IBM PC/RT             */
396                     /*             HP_PA      ==> HP9000/700 & /800     */
397                     /*                            HP/UX, LINUX          */
398                     /*             SPARC      ==> SPARC v7/v8/v9        */
399                     /*                  (SUNOS4, SUNOS5, LINUX,         */
400                     /*                   DRSNX variants)                */
401                     /*             ALPHA      ==> DEC Alpha             */
402                     /*                  (OSF1 and LINUX variants)       */
403                     /*             M88K       ==> Motorola 88XX0        */
404                     /*                  (CX_UX and DGUX)                */
405                     /*             S370       ==> 370-like machine      */
406                     /*                  running Amdahl UTS4             */
407                     /*                  or a 390 running LINUX          */
408                     /*             ARM32      ==> Intel StrongARM       */
409                     /*             IA64       ==> Intel IPF             */
410                     /*                            (e.g. Itanium)        */
411                     /*                  (LINUX and HPUX)                */
412                     /*             IA64_32    ==> IA64 w/32 bit ABI     */
413                     /*                  (HPUX)                          */
414                     /*             SH         ==> Hitachi SuperH        */
415                     /*                  (LINUX & MSWINCE)               */
416
417
418 /*
419  * For each architecture and OS, the following need to be defined:
420  *
421  * CPP_WORD_SZ is a simple integer constant representing the word size.
422  * in bits.  We assume byte addressibility, where a byte has 8 bits.
423  * We also assume CPP_WORD_SZ is either 32 or 64.
424  * (We care about the length of pointers, not hardware
425  * bus widths.  Thus a 64 bit processor with a C compiler that uses
426  * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
427  *
428  * MACH_TYPE is a string representation of the machine type.
429  * OS_TYPE is analogous for the OS.
430  *
431  * ALIGNMENT is the largest N, such that
432  * all pointer are guaranteed to be aligned on N byte boundaries.
433  * defining it to be 1 will always work, but perform poorly.
434  *
435  * DATASTART is the beginning of the data segment.
436  * On UNIX systems, the collector will scan the area between DATASTART
437  * and DATAEND for root pointers.
438  *
439  * DATAEND, if not &end.
440  *
441  * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
442  * the pointer size.
443  *
444  * STACKBOTTOM is the cool end of the stack, which is usually the
445  * highest address in the stack.
446  * Under PCR or OS/2, we have other ways of finding thread stacks.
447  * For each machine, the following should:
448  * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
449  * 2) define exactly one of
450  *      STACKBOTTOM (should be defined to be an expression)
451  *      HEURISTIC1
452  *      HEURISTIC2
453  * If either of the last two macros are defined, then STACKBOTTOM is computed
454  * during collector startup using one of the following two heuristics:
455  * HEURISTIC1:  Take an address inside GC_init's frame, and round it up to
456  *              the next multiple of STACK_GRAN.
457  * HEURISTIC2:  Take an address inside GC_init's frame, increment it repeatedly
458  *              in small steps (decrement if STACK_GROWS_UP), and read the value
459  *              at each location.  Remember the value when the first
460  *              Segmentation violation or Bus error is signalled.  Round that
461  *              to the nearest plausible page boundary, and use that instead
462  *              of STACKBOTTOM.
463  *
464  * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
465  * the value of environ is a pointer that can serve as STACKBOTTOM.
466  * I expect that HEURISTIC2 can be replaced by this approach, which
467  * interferes far less with debugging.  However it has the disadvantage
468  * that it's confused by a putenv call before the collector is initialized.
469  * This could be dealt with by intercepting putenv ...
470  *
471  * If no expression for STACKBOTTOM can be found, and neither of the above
472  * heuristics are usable, the collector can still be used with all of the above
473  * undefined, provided one of the following is done:
474  * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
475  *    without reference to STACKBOTTOM.  This is appropriate for use in
476  *    conjunction with thread packages, since there will be multiple stacks.
477  *    (Allocating thread stacks in the heap, and treating them as ordinary
478  *    heap data objects is also possible as a last resort.  However, this is
479  *    likely to introduce significant amounts of excess storage retention
480  *    unless the dead parts of the thread stacks are periodically cleared.)
481  * 2) Client code may set GC_stackbottom before calling any GC_ routines.
482  *    If the author of the client code controls the main program, this is
483  *    easily accomplished by introducing a new main program, setting
484  *    GC_stackbottom to the address of a local variable, and then calling
485  *    the original main program.  The new main program would read something
486  *    like:
487  *
488  *              # include "gc_private.h"
489  *
490  *              main(argc, argv, envp)
491  *              int argc;
492  *              char **argv, **envp;
493  *              {
494  *                  int dummy;
495  *
496  *                  GC_stackbottom = (ptr_t)(&dummy);
497  *                  return(real_main(argc, argv, envp));
498  *              }
499  *
500  *
501  * Each architecture may also define the style of virtual dirty bit
502  * implementation to be used:
503  *   MPROTECT_VDB: Write protect the heap and catch faults.
504  *   PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
505  *
506  * An architecture may define DYNAMIC_LOADING if dynamic_load.c
507  * defined GC_register_dynamic_libraries() for the architecture.
508  *
509  * An architecture may define PREFETCH(x) to preload the cache with *x.
510  * This defaults to a no-op.
511  *
512  * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
513  *
514  * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
515  * clear the two words at GC_malloc-aligned address x.  By default,
516  * word stores of 0 are used instead.
517  */
518
519 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
520  * to push the relevant registers onto the stack.  This generally makes
521  * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
522  */
523 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
524                            (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
525 #   define HAVE_BUILTIN_UNWIND_INIT
526 # endif
527
528 # define STACK_GRAN 0x1000000
529 # ifdef M68K
530 #   define MACH_TYPE "M68K"
531 #   define ALIGNMENT 2
532 #   ifdef OPENBSD
533 #       define OS_TYPE "OPENBSD"
534 #       define HEURISTIC2
535         extern char etext;
536 #       define DATASTART ((ptr_t)(&etext))
537 #   endif
538 #   ifdef NETBSD
539 #       define OS_TYPE "NETBSD"
540 #       define HEURISTIC2
541         extern char etext;
542 #       define DATASTART ((ptr_t)(&etext))
543 #   endif
544 #   ifdef LINUX
545 #       define OS_TYPE "LINUX"
546 #       define STACKBOTTOM ((ptr_t)0xf0000000)
547 /* #       define MPROTECT_VDB - Reported to not work  9/17/01 */
548 #       ifdef __ELF__
549 #            define DYNAMIC_LOADING
550 #            include <features.h>
551 #            if defined(__GLIBC__)&& __GLIBC__>=2
552 #              define LINUX_DATA_START
553 #            else /* !GLIBC2 */
554                extern char **__environ;
555 #              define DATASTART ((ptr_t)(&__environ))
556                              /* hideous kludge: __environ is the first */
557                              /* word in crt0.o, and delimits the start */
558                              /* of the data segment, no matter which   */
559                              /* ld options were passed through.        */
560                              /* We could use _etext instead, but that  */
561                              /* would include .rodata, which may       */
562                              /* contain large read-only data tables    */
563                              /* that we'd rather not scan.             */
564 #            endif /* !GLIBC2 */
565              extern int _end;
566 #            define DATAEND (&_end)
567 #       else
568              extern int etext;
569 #            define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
570 #       endif
571 #   endif
572 #   ifdef SUNOS4
573 #       define OS_TYPE "SUNOS4"
574         extern char etext;
575 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
576 #       define HEURISTIC1       /* differs      */
577 #       define DYNAMIC_LOADING
578 #   endif
579 #   ifdef HP
580 #       define OS_TYPE "HP"
581         extern char etext;
582 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
583 #       define STACKBOTTOM ((ptr_t) 0xffeffffc)
584                               /* empirically determined.  seems to work. */
585 #       include <unistd.h>
586 #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
587 #   endif
588 #   ifdef SYSV
589 #       define OS_TYPE "SYSV"
590         extern etext;
591 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
592                                    & ~0x3fffff) \
593                                   +((word)&etext & 0x1fff))
594         /* This only works for shared-text binaries with magic number 0413.
595            The other sorts of SysV binaries put the data at the end of the text,
596            in which case the default of &etext would work.  Unfortunately,
597            handling both would require having the magic-number available.
598                                 -- Parag
599            */
600 #       define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
601                         /* The stack starts at the top of memory, but   */
602                         /* 0x0 cannot be used as setjump_test complains */
603                         /* that the stack direction is incorrect.  Two  */
604                         /* bytes down from 0x0 should be safe enough.   */
605                         /*              --Parag                         */
606 #       include <sys/mmu.h>
607 #       define GETPAGESIZE() PAGESIZE   /* Is this still right? */
608 #   endif
609 #   ifdef AMIGA
610 #       define OS_TYPE "AMIGA"
611                 /* STACKBOTTOM and DATASTART handled specially  */
612                 /* in os_dep.c                                  */
613 #       define DATAEND  /* not needed */
614 #       define GETPAGESIZE() 4096
615 #   endif
616 #   ifdef MACOS
617 #     ifndef __LOWMEM__
618 #     include <LowMem.h>
619 #     endif
620 #     define OS_TYPE "MACOS"
621                         /* see os_dep.c for details of global data segments. */
622 #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
623 #     define DATAEND    /* not needed */
624 #     define GETPAGESIZE() 4096
625 #   endif
626 #   ifdef NEXT
627 #       define OS_TYPE "NEXT"
628 #       define DATASTART ((ptr_t) get_etext())
629 #       define STACKBOTTOM ((ptr_t) 0x4000000)
630 #       define DATAEND  /* not needed */
631 #   endif
632 # endif
633
634 # ifdef POWERPC
635 #   define MACH_TYPE "POWERPC"
636 #   ifdef MACOS
637 #     define ALIGNMENT 2  /* Still necessary?  Could it be 4?   */
638 #     ifndef __LOWMEM__
639 #     include <LowMem.h>
640 #     endif
641 #     define OS_TYPE "MACOS"
642                         /* see os_dep.c for details of global data segments. */
643 #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
644 #     define DATAEND  /* not needed */
645 #   endif
646 #   ifdef LINUX
647 #     define ALIGNMENT 4        /* Guess.  Can someone verify?  */
648                                 /* This was 2, but that didn't sound right. */
649 #     define OS_TYPE "LINUX"
650 #     define HEURISTIC1
651 #     define DYNAMIC_LOADING
652 #     undef STACK_GRAN
653 #     define STACK_GRAN 0x10000000
654         /* Stack usually starts at 0x80000000 */
655 #     define LINUX_DATA_START
656       extern int _end;
657 #     define DATAEND (&_end)
658 #   endif
659 #   ifdef MACOSX
660       /* There are reasons to suspect this may not be reliable.         */
661 #     define ALIGNMENT 4
662 #     define OS_TYPE "MACOSX"
663 #     define DATASTART ((ptr_t) get_etext())
664 #     define STACKBOTTOM ((ptr_t) 0xc0000000)
665 #     define DATAEND    /* not needed */
666 #     define MPROTECT_VDB
667 #     include <unistd.h>
668 #     define GETPAGESIZE() getpagesize()
669 #   endif
670 #   ifdef NETBSD
671 #     define ALIGNMENT 4
672 #     define OS_TYPE "NETBSD"
673 #     define HEURISTIC2
674       extern char etext;
675 #     define DATASTART GC_data_start
676 #     define DYNAMIC_LOADING
677 #   endif
678 #   ifdef NOSYS
679 #     define ALIGNMENT 4
680 #     define OS_TYPE "NOSYS"
681       extern void __end, __dso_handle;
682 #     define DATASTART (&__dso_handle)  /* OK, that's ugly.  */
683 #     define DATAEND (&__end)
684         /* Stack starts at 0xE0000000 for the simulator.  */
685 #     undef STACK_GRAN
686 #     define STACK_GRAN 0x10000000
687 #     define HEURISTIC1
688 #   endif
689 # endif
690
691 # ifdef VAX
692 #   define MACH_TYPE "VAX"
693 #   define ALIGNMENT 4  /* Pointers are longword aligned by 4.2 C compiler */
694     extern char etext;
695 #   define DATASTART ((ptr_t)(&etext))
696 #   ifdef BSD
697 #       define OS_TYPE "BSD"
698 #       define HEURISTIC1
699                         /* HEURISTIC2 may be OK, but it's hard to test. */
700 #   endif
701 #   ifdef ULTRIX
702 #       define OS_TYPE "ULTRIX"
703 #       define STACKBOTTOM ((ptr_t) 0x7fffc800)
704 #   endif
705 # endif
706
707 # ifdef RT
708 #   define MACH_TYPE "RT"
709 #   define ALIGNMENT 4
710 #   define DATASTART ((ptr_t) 0x10000000)
711 #   define STACKBOTTOM ((ptr_t) 0x1fffd800)
712 # endif
713
714 # ifdef SPARC
715 #   define MACH_TYPE "SPARC"
716 #   if defined(__arch64__) || defined(__sparcv9)
717 #     define ALIGNMENT 8
718 #     define CPP_WORDSZ 64
719 #     define ELF_CLASS ELFCLASS64
720 #   else
721 #     define ALIGNMENT 4        /* Required by hardware */
722 #   endif
723 #   define ALIGN_DOUBLE
724 #   ifdef SUNOS5
725 #       define OS_TYPE "SUNOS5"
726         extern int _etext;
727         extern int _end;
728         extern char * GC_SysVGetDataStart();
729 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
730 #       define DATAEND (&_end)
731 #       ifndef USE_MMAP
732 #           define USE_MMAP
733 #       endif
734 #       ifdef USE_MMAP
735 #         define HEAP_START (ptr_t)0x40000000
736 #       else
737 #         define HEAP_START DATAEND
738 #       endif
739 #       define PROC_VDB
740 /*      HEURISTIC1 reportedly no longer works under 2.7.                */
741 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
742 /*      Apparently USRSTACK is defined to be USERLIMIT, but in some     */
743 /*      installations that's undefined.  We work around this with a     */
744 /*      gross hack:                                                     */
745 #       include <sys/vmparam.h>
746 #       ifdef USERLIMIT
747           /* This should work everywhere, but doesn't.  */
748 #         define STACKBOTTOM USRSTACK
749 #       else
750 #         define HEURISTIC2
751 #       endif
752 #       include <unistd.h>
753 #       define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
754                 /* getpagesize() appeared to be missing from at least one */
755                 /* Solaris 5.4 installation.  Weird.                      */
756 #       define DYNAMIC_LOADING
757 #   endif
758 #   ifdef SUNOS4
759 #       define OS_TYPE "SUNOS4"
760         /* [If you have a weak stomach, don't read this.]               */
761         /* We would like to use:                                        */
762 /* #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
763         /* This fails occasionally, due to an ancient, but very         */
764         /* persistent ld bug.  &etext is set 32 bytes too high.         */
765         /* We instead read the text segment size from the a.out         */
766         /* header, which happens to be mapped into our address space    */
767         /* at the start of the text segment.  The detective work here   */
768         /* was done by Robert Ehrlich, Manuel Serrano, and Bernard      */
769         /* Serpette of INRIA.                                           */
770         /* This assumes ZMAGIC, i.e. demand-loadable executables.       */
771 #       define TEXTSTART 0x2000
772 #       define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
773 #       define MPROTECT_VDB
774 #       define HEURISTIC1
775 #       define DYNAMIC_LOADING
776 #   endif
777 #   ifdef DRSNX
778 #       define CPP_WORDSZ 32
779 #       define OS_TYPE "DRSNX"
780         extern char * GC_SysVGetDataStart();
781         extern int etext;
782 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
783 #       define MPROTECT_VDB
784 #       define STACKBOTTOM ((ptr_t) 0xdfff0000)
785 #       define DYNAMIC_LOADING
786 #   endif
787 #   ifdef LINUX
788 #     define OS_TYPE "LINUX"
789 #     ifdef __ELF__
790 #       define DYNAMIC_LOADING
791 #     else
792           Linux Sparc/a.out not supported
793 #     endif
794       extern int _end;
795       extern int _etext;
796 #     define DATAEND (&_end)
797 #     define SVR4
798 #     ifdef __arch64__
799 #       define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
800 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
801 #       define CPP_WORDSZ 64
802 #     else
803 #       define STACKBOTTOM ((ptr_t) 0xf0000000)
804 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
805 #     endif
806 #   endif
807 #   ifdef OPENBSD
808 #     define OS_TYPE "OPENBSD"
809 #     define STACKBOTTOM ((ptr_t) 0xf8000000)
810       extern int etext;
811 #     define DATASTART ((ptr_t)(&etext))
812 #   endif
813 #   ifdef NETBSD
814 #     define OS_TYPE "NETBSD"
815 #     define HEURISTIC2
816 #     ifdef __ELF__
817 #       define DATASTART GC_data_start
818 #       define DYNAMIC_LOADING
819 #     else
820         extern char etext;
821 #       define DATASTART ((ptr_t)(&etext))
822 #     endif
823 #   endif
824 # endif
825
826 # ifdef I386
827 #   define MACH_TYPE "I386"
828 #   define ALIGNMENT 4  /* Appears to hold for all "32 bit" compilers   */
829                         /* except Borland.  The -a4 option fixes        */
830                         /* Borland.                                     */
831                         /* Ivan Demakov: For Watcom the option is -zp4. */
832 #   ifndef SMALL_CONFIG
833 #     define ALIGN_DOUBLE /* Not strictly necessary, but may give speed   */
834                           /* improvement on Pentiums.                     */
835 #   endif
836 #   ifdef HAVE_BUILTIN_UNWIND_INIT
837 #       define USE_GENERIC_PUSH_REGS
838 #   endif
839 #   ifdef SEQUENT
840 #       define OS_TYPE "SEQUENT"
841         extern int etext;
842 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
843 #       define STACKBOTTOM ((ptr_t) 0x3ffff000) 
844 #   endif
845 #   ifdef BEOS
846 #     define OS_TYPE "BEOS"
847 #     include <OS.h>
848 #     define GETPAGESIZE() B_PAGE_SIZE
849       extern int etext;
850 #     define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
851 #   endif
852 #   ifdef SUNOS5
853 #       define OS_TYPE "SUNOS5"
854         extern int _etext, _end;
855         extern char * GC_SysVGetDataStart();
856 #       define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
857 #       define DATAEND (&_end)
858 /*      # define STACKBOTTOM ((ptr_t)(&_start)) worked through 2.7,     */
859 /*      but reportedly breaks under 2.8.  It appears that the stack     */
860 /*      base is a property of the executable, so this should not break  */
861 /*      old executables.                                                */
862 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
863 #       include <sys/vmparam.h>
864 #       define STACKBOTTOM USRSTACK
865 /** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
866 #       ifdef SOLARIS25_PROC_VDB_BUG_FIXED
867 #         define PROC_VDB
868 #       endif
869 #       define DYNAMIC_LOADING
870 #       ifndef USE_MMAP
871 #           define USE_MMAP
872 #       endif
873 #       ifdef USE_MMAP
874 #         define HEAP_START (ptr_t)0x40000000
875 #       else
876 #         define HEAP_START DATAEND
877 #       endif
878 #   endif
879 #   ifdef SCO
880 #       define OS_TYPE "SCO"
881         extern int etext;
882 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
883                                   & ~0x3fffff) \
884                                  +((word)&etext & 0xfff))
885 #       define STACKBOTTOM ((ptr_t) 0x7ffffffc)
886 #   endif
887 #   ifdef SCO_ELF
888 #       define OS_TYPE "SCO_ELF"
889         extern int etext;
890 #       define DATASTART ((ptr_t)(&etext))
891 #       define STACKBOTTOM ((ptr_t) 0x08048000)
892 #       define DYNAMIC_LOADING
893 #       define ELF_CLASS ELFCLASS32
894 #   endif
895 #   ifdef LINUX
896 #       define OS_TYPE "LINUX"
897 #       define LINUX_STACKBOTTOM
898 #       if 0
899 #         define HEURISTIC1
900 #         undef STACK_GRAN
901 #         define STACK_GRAN 0x10000000
902           /* STACKBOTTOM is usually 0xc0000000, but this changes with   */
903           /* different kernel configurations.  In particular, systems   */
904           /* with 2GB physical memory will usually move the user        */
905           /* address space limit, and hence initial SP to 0x80000000.   */
906 #       endif
907 #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
908 #           define MPROTECT_VDB
909 #       else
910             /* We seem to get random errors in incremental mode,        */
911             /* possibly because Linux threads is itself a malloc client */
912             /* and can't deal with the signals.                         */
913 #       endif
914 #       ifdef __ELF__
915 #            define DYNAMIC_LOADING
916 #            ifdef UNDEFINED    /* includes ro data */
917                extern int _etext;
918 #              define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
919 #            endif
920 #            include <features.h>
921 #            if defined(__GLIBC__) && __GLIBC__ >= 2
922 #                define LINUX_DATA_START
923 #            else
924                  extern char **__environ;
925 #                define DATASTART ((ptr_t)(&__environ))
926                               /* hideous kludge: __environ is the first */
927                               /* word in crt0.o, and delimits the start */
928                               /* of the data segment, no matter which   */
929                               /* ld options were passed through.        */
930                               /* We could use _etext instead, but that  */
931                               /* would include .rodata, which may       */
932                               /* contain large read-only data tables    */
933                               /* that we'd rather not scan.             */
934 #            endif
935              extern int _end;
936 #            define DATAEND (&_end)
937 #       else
938              extern int etext;
939 #            define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
940 #       endif
941 #       ifdef USE_I686_PREFETCH
942 #         define PREFETCH(x) \
943             __asm__ __volatile__ ("     prefetchnta     %0": : "m"(*(char *)(x)))
944             /* Empirically prefetcht0 is much more effective at reducing        */
945             /* cache miss stalls for the targetted load instructions.  But it   */
946             /* seems to interfere enough with other cache traffic that the net  */
947             /* result is worse than prefetchnta.                                */
948 #         if 0 
949             /* Using prefetches for write seems to have a slight negative       */
950             /* impact on performance, at least for a PIII/500.                  */
951 #           define PREFETCH_FOR_WRITE(x) \
952               __asm__ __volatile__ ("   prefetcht0      %0": : "m"(*(char *)(x)))
953 #         endif
954 #       endif
955 #       ifdef USE_3DNOW_PREFETCH
956 #         define PREFETCH(x) \
957             __asm__ __volatile__ ("     prefetch        %0": : "m"(*(char *)(x)))
958 #         define PREFETCH_FOR_WRITE(x) \
959             __asm__ __volatile__ ("     prefetchw       %0": : "m"(*(char *)(x)))
960 #       endif
961 #   endif
962 #   ifdef CYGWIN32
963 #       define OS_TYPE "CYGWIN32"
964           extern int _data_start__;
965           extern int _data_end__;
966           extern int _bss_start__;
967           extern int _bss_end__;
968         /* For binutils 2.9.1, we have                  */
969         /*      DATASTART   = _data_start__             */
970         /*      DATAEND     = _bss_end__                */
971         /* whereas for some earlier versions it was     */
972         /*      DATASTART   = _bss_start__              */
973         /*      DATAEND     = _data_end__               */
974         /* To get it right for both, we take the        */
975         /* minumum/maximum of the two.                  */
976 #       define MAX(x,y) ((x) > (y) ? (x) : (y))
977 #       define MIN(x,y) ((x) < (y) ? (x) : (y))
978 #       define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
979 #       define DATAEND   ((ptr_t) MAX(&_data_end__, &_bss_end__))
980 #       undef STACK_GRAN
981 #       define STACK_GRAN 0x10000
982 #       define HEURISTIC1
983 #   endif
984 #   ifdef OS2
985 #       define OS_TYPE "OS2"
986                 /* STACKBOTTOM and DATASTART are handled specially in   */
987                 /* os_dep.c. OS2 actually has the right                 */
988                 /* system call!                                         */
989 #       define DATAEND  /* not needed */
990 #       define USE_GENERIC_PUSH_REGS
991 #   endif
992 #   ifdef MSWIN32
993 #       define OS_TYPE "MSWIN32"
994                 /* STACKBOTTOM and DATASTART are handled specially in   */
995                 /* os_dep.c.                                            */
996 #       ifndef __WATCOMC__
997 #         define MPROTECT_VDB
998 #       endif
999 #       define DATAEND  /* not needed */
1000 #   endif
1001 #   ifdef MSWINCE
1002 #       define OS_TYPE "MSWINCE"
1003 #       define DATAEND  /* not needed */
1004 #   endif
1005 #   ifdef DJGPP
1006 #       define OS_TYPE "DJGPP"
1007 #       include "stubinfo.h"
1008         extern int etext;
1009         extern int _stklen;
1010         extern int __djgpp_stack_limit;
1011 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
1012 /* #       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1013                                                      + _stklen)) */
1014 #       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1015                 /* This may not be right.  */
1016 #   endif
1017 #   ifdef OPENBSD
1018 #       define OS_TYPE "OPENBSD"
1019 #   endif
1020 #   ifdef FREEBSD
1021 #       define OS_TYPE "FREEBSD"
1022 #       ifndef GC_FREEBSD_THREADS
1023 #           define MPROTECT_VDB
1024 #       endif
1025 #       define SIG_SUSPEND SIGUSR1
1026 #       define SIG_THR_RESTART SIGUSR2
1027 #       define FREEBSD_STACKBOTTOM
1028 #       ifdef __ELF__
1029 #           define DYNAMIC_LOADING
1030 #       endif
1031 #   endif
1032 #   ifdef NETBSD
1033 #       define OS_TYPE "NETBSD"
1034 #   endif
1035 #   ifdef THREE86BSD
1036 #       define OS_TYPE "THREE86BSD"
1037 #   endif
1038 #   ifdef BSDI
1039 #       define OS_TYPE "BSDI"
1040 #   endif
1041 #   if defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1042         || defined(THREE86BSD) || defined(BSDI)
1043 #       define HEURISTIC2
1044         extern char etext;
1045 #       define DATASTART ((ptr_t)(&etext))
1046 #   endif
1047 #   ifdef NEXT
1048 #       define OS_TYPE "NEXT"
1049 #       define DATASTART ((ptr_t) get_etext())
1050 #       define STACKBOTTOM ((ptr_t)0xc0000000)
1051 #       define DATAEND  /* not needed */
1052 #   endif
1053 #   ifdef DOS4GW
1054 #     define OS_TYPE "DOS4GW"
1055       extern long __nullarea;
1056       extern char _end;
1057       extern char *_STACKTOP;
1058       /* Depending on calling conventions Watcom C either precedes
1059          or does not precedes with undescore names of C-variables.
1060          Make sure startup code variables always have the same names.  */
1061       #pragma aux __nullarea "*";
1062       #pragma aux _end "*";
1063 #     define STACKBOTTOM ((ptr_t) _STACKTOP)
1064                          /* confused? me too. */
1065 #     define DATASTART ((ptr_t) &__nullarea)
1066 #     define DATAEND ((ptr_t) &_end)
1067 #   endif
1068 #   ifdef HURD
1069 #     define OS_TYPE "HURD"
1070 #     define STACK_GROWS_DOWN
1071 #     define HEURISTIC2
1072       extern int  __data_start;
1073 #     define DATASTART ( (ptr_t) (&__data_start))
1074       extern int   _end;
1075 #     define DATAEND ( (ptr_t) (&_end))
1076 /* #     define MPROTECT_VDB  Not quite working yet? */
1077 #     define DYNAMIC_LOADING
1078 #   endif
1079 # endif
1080
1081 # ifdef NS32K
1082 #   define MACH_TYPE "NS32K"
1083 #   define ALIGNMENT 4
1084     extern char **environ;
1085 #   define DATASTART ((ptr_t)(&environ))
1086                               /* hideous kludge: environ is the first   */
1087                               /* word in crt0.o, and delimits the start */
1088                               /* of the data segment, no matter which   */
1089                               /* ld options were passed through.        */
1090 #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1091 # endif
1092
1093 # ifdef MIPS
1094 #   define MACH_TYPE "MIPS"
1095 #   ifdef LINUX
1096       /* This was developed for a linuxce style platform.  Probably     */
1097       /* needs to be tweaked for workstation class machines.            */
1098 #     define OS_TYPE "LINUX"
1099       extern int __data_start;
1100 #     define DATASTART ((ptr_t)(&__data_start))
1101 #     define ALIGNMENT 4
1102 #     define USE_GENERIC_PUSH_REGS
1103 #     define STACKBOTTOM ((ptr_t)0x7fff8000)
1104         /* Older toolchains may need 0x80000000.        */
1105         /* In many cases, this should probably use LINUX_STACKBOTTOM    */
1106         /* instead. But some kernel versions seem to give the wrong     */
1107         /* value from /proc.                                            */
1108 #   endif /* Linux */
1109 #   ifdef ULTRIX
1110 #       define HEURISTIC2
1111 #       define DATASTART (ptr_t)0x10000000
1112                               /* Could probably be slightly higher since */
1113                               /* startup code allocates lots of stuff.   */
1114 #       define OS_TYPE "ULTRIX"
1115 #       define ALIGNMENT 4
1116 #   endif
1117 #   ifdef RISCOS
1118 #       define HEURISTIC2
1119 #       define DATASTART (ptr_t)0x10000000
1120 #       define OS_TYPE "RISCOS"
1121 #       define ALIGNMENT 4  /* Required by hardware */
1122 #   endif
1123 #   ifdef IRIX5
1124 #       define HEURISTIC2
1125         extern int _fdata;
1126 #       define DATASTART ((ptr_t)(&_fdata))
1127 #       ifdef USE_MMAP
1128 #         define HEAP_START (ptr_t)0x30000000
1129 #       else
1130 #         define HEAP_START DATASTART
1131 #       endif
1132                               /* Lowest plausible heap address.         */
1133                               /* In the MMAP case, we map there.        */
1134                               /* In either case it is used to identify  */
1135                               /* heap sections so they're not           */
1136                               /* considered as roots.                   */
1137 #       define OS_TYPE "IRIX5"
1138 #       define MPROTECT_VDB
1139 #       ifdef _MIPS_SZPTR
1140 #         define CPP_WORDSZ _MIPS_SZPTR
1141 #         define ALIGNMENT (_MIPS_SZPTR/8)
1142 #         if CPP_WORDSZ != 64
1143 #           define ALIGN_DOUBLE
1144 #         endif
1145 #       else
1146 #         define ALIGNMENT 4
1147 #         define ALIGN_DOUBLE
1148 #       endif
1149 #       define DYNAMIC_LOADING
1150 #   endif
1151 #   ifdef MSWINCE
1152 #       define OS_TYPE "MSWINCE"
1153 #       define ALIGNMENT 4
1154 #       define DATAEND /* not needed */
1155 #   endif
1156 #   if defined(NETBSD)
1157       /* This also checked for __MIPSEL__ .  Why?  NETBSD recognition   */
1158       /* should be handled at the top of the file.                      */
1159 #     define ALIGNMENT 4
1160 #     define OS_TYPE "NETBSD"
1161 #     define HEURISTIC2
1162 #     define USE_GENERIC_PUSH_REGS
1163 #     ifdef __ELF__
1164         extern int etext;
1165 #       define DATASTART GC_data_start
1166 #       define NEED_FIND_LIMIT
1167 #       define DYNAMIC_LOADING
1168 #     else
1169 #       define DATASTART ((ptr_t) 0x10000000)
1170 #       define STACKBOTTOM ((ptr_t) 0x7ffff000)
1171 #     endif /* _ELF_ */
1172 #  endif
1173 # endif
1174
1175 # ifdef RS6000
1176 #   define MACH_TYPE "RS6000"
1177 #   define ALIGNMENT 4
1178 #   define DATASTART ((ptr_t)0x20000000)
1179     extern int errno;
1180 #   define STACKBOTTOM ((ptr_t)((ulong)&errno))
1181 #   define DYNAMIC_LOADING
1182         /* For really old versions of AIX, this may have to be removed. */
1183 # endif
1184
1185 # ifdef HP_PA
1186 #   define MACH_TYPE "HP_PA"
1187 #   ifdef __LP64__
1188 #     define CPP_WORDSZ 64
1189 #     define ALIGNMENT 8
1190 #   else
1191 #     define CPP_WORDSZ 32
1192 #     define ALIGNMENT 4
1193 #     define ALIGN_DOUBLE
1194 #   endif
1195 #   if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1196 #     ifndef LINUX /* For now. */
1197 #       define MPROTECT_VDB
1198 #     endif
1199 #   else
1200 #     define GENERIC_COMPARE_AND_SWAP
1201         /* No compare-and-swap instruction.  Use pthread mutexes        */
1202         /* when we absolutely have to.                                  */
1203 #     ifdef PARALLEL_MARK
1204 #       define USE_MARK_BYTES
1205                 /* Minimize compare-and-swap usage.             */
1206 #     endif
1207 #   endif
1208 #   define STACK_GROWS_UP
1209 #   ifdef HPUX
1210 #     define OS_TYPE "HPUX"
1211       extern int __data_start;
1212 #     define DATASTART ((ptr_t)(&__data_start))
1213 #     if 0
1214         /* The following appears to work for 7xx systems running HP/UX  */
1215         /* 9.xx Furthermore, it might result in much faster             */
1216         /* collections than HEURISTIC2, which may involve scanning      */
1217         /* segments that directly precede the stack.  It is not the     */
1218         /* default, since it may not work on older machine/OS           */
1219         /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1220         /* this.)                                                       */
1221 #       define STACKBOTTOM ((ptr_t) 0x7b033000)  /* from /etc/conf/h/param.h */
1222 #     else
1223         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
1224         /* to this.  Note that the GC must be initialized before the    */
1225         /* first putenv call.                                           */
1226         extern char ** environ;
1227 #       define STACKBOTTOM ((ptr_t)environ)
1228 #     endif
1229 #     define DYNAMIC_LOADING
1230 #     include <unistd.h>
1231 #     define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1232 #     ifndef __GNUC__
1233 #       define PREFETCH(x)  { \
1234                               register long addr = (long)(x); \
1235                               (void) _asm ("LDW", 0, 0, addr, 0); \
1236                             }
1237 #     endif
1238 #   endif /* HPUX */
1239 #   ifdef LINUX
1240 #     define OS_TYPE "LINUX"
1241 #     define LINUX_STACKBOTTOM
1242 #     define DYNAMIC_LOADING
1243 #     define LINUX_DATA_START
1244       extern int _end;
1245 #     define DATAEND (&_end)
1246 #   endif /* LINUX */
1247 # endif /* HP_PA */
1248
1249 # ifdef ALPHA
1250 #   define MACH_TYPE "ALPHA"
1251 #   define ALIGNMENT 8
1252 #   ifdef NETBSD
1253 #       define OS_TYPE "NETBSD"
1254 #       define HEURISTIC2
1255 #       define DATASTART GC_data_start
1256 #       define ELFCLASS32 32
1257 #       define ELFCLASS64 64
1258 #       define ELF_CLASS ELFCLASS64
1259 #       define CPP_WORDSZ 64
1260 #       define DYNAMIC_LOADING
1261 #   endif
1262 #   ifdef OPENBSD
1263 #       define OS_TYPE "OPENBSD"
1264 #       define HEURISTIC2
1265 #       define CPP_WORDSZ 64
1266 #       ifdef __ELF__   /* since OpenBSD/Alpha 2.9 */
1267 #          define DATASTART GC_data_start
1268 #          define ELFCLASS32 32
1269 #          define ELFCLASS64 64
1270 #          define ELF_CLASS ELFCLASS64
1271 #       else            /* ECOFF, until OpenBSD/Alpha 2.7 */
1272 #          define DATASTART ((ptr_t) 0x140000000)
1273 #       endif
1274 #   endif
1275 #   ifdef OSF1
1276 #       define OS_TYPE "OSF1"
1277 #       define DATASTART ((ptr_t) 0x140000000)
1278         extern int _end;
1279 #       define DATAEND ((ptr_t) &_end)
1280         extern char ** environ;
1281         /* round up from the value of environ to the nearest page boundary */
1282         /* Probably breaks if putenv is called before collector            */
1283         /* initialization.                                                 */
1284 #       define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1285 /* #    define HEURISTIC2 */
1286         /* Normally HEURISTIC2 is too conervative, since                */
1287         /* the text segment immediately follows the stack.              */
1288         /* Hence we give an upper pound.                                */
1289         /* This is currently unused, since we disabled HEURISTIC2       */
1290         extern int __start;
1291 #       define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
1292 #       define CPP_WORDSZ 64
1293 #       define MPROTECT_VDB
1294 #       define DYNAMIC_LOADING
1295 #   endif
1296 #   ifdef LINUX
1297 #       define OS_TYPE "LINUX"
1298 #       define CPP_WORDSZ 64
1299 #       define STACKBOTTOM ((ptr_t) 0x120000000)
1300 #       ifdef __ELF__
1301 #         define SEARCH_FOR_DATA_START
1302 #         define DATASTART GC_data_start
1303 #         define DYNAMIC_LOADING
1304 #       else
1305 #           define DATASTART ((ptr_t) 0x140000000)
1306 #       endif
1307         extern int _end;
1308 #       define DATAEND (&_end)
1309 #       define MPROTECT_VDB
1310                 /* Has only been superficially tested.  May not */
1311                 /* work on all versions.                        */
1312 #   endif
1313 # endif
1314
1315 # ifdef IA64
1316 #   define MACH_TYPE "IA64"
1317 #   define USE_GENERIC_PUSH_REGS
1318         /* We need to get preserved registers in addition to register   */
1319         /* windows.   That's easiest to do with setjmp.                 */
1320 #   ifdef PARALLEL_MARK
1321 #       define USE_MARK_BYTES
1322             /* Compare-and-exchange is too expensive to use for         */
1323             /* setting mark bits.                                       */
1324 #   endif
1325 #   ifdef HPUX
1326 #       ifdef _ILP32
1327 #         define CPP_WORDSZ 32
1328 #         define ALIGN_DOUBLE
1329             /* Requires 8 byte alignment for malloc */
1330 #         define ALIGNMENT 4
1331 #       else
1332 #         ifndef _LP64
1333                 ---> unknown ABI
1334 #         endif
1335 #         define CPP_WORDSZ 64
1336 #         define ALIGN_DOUBLE
1337             /* Requires 16 byte alignment for malloc */
1338 #         define ALIGNMENT 8
1339 #       endif
1340 #       define OS_TYPE "HPUX"   
1341         extern int __data_start;
1342 #       define DATASTART ((ptr_t)(&__data_start))
1343         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
1344         /* to this.  Note that the GC must be initialized before the    */
1345         /* first putenv call.                                           */
1346         extern char ** environ;
1347 #       define STACKBOTTOM ((ptr_t)environ)
1348 #       define DYNAMIC_LOADING
1349 #       include <unistd.h>
1350 #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1351         /* The following was empirically determined, and is probably    */
1352         /* not very robust.                                             */
1353         /* Note that the backing store base seems to be at a nice       */
1354         /* address minus one page.                                      */
1355 #       define BACKING_STORE_DISPLACEMENT 0x1000000
1356 #       define BACKING_STORE_ALIGNMENT 0x1000
1357 #       define BACKING_STORE_BASE \
1358           (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \
1359                         & ~(BACKING_STORE_ALIGNMENT - 1))
1360 #   endif
1361 #   ifdef LINUX
1362 #       define CPP_WORDSZ 64
1363 #       define ALIGN_DOUBLE
1364           /* Requires 16 byte alignment for malloc */
1365 #       define ALIGNMENT 8
1366 #       define OS_TYPE "LINUX"
1367         /* The following works on NUE and older kernels:        */
1368 /* #       define STACKBOTTOM ((ptr_t) 0xa000000000000000l)     */
1369         /* This does not work on NUE:                           */
1370 #       define LINUX_STACKBOTTOM
1371         /* We also need the base address of the register stack  */
1372         /* backing store.  This is computed in                  */
1373         /* GC_linux_register_stack_base based on the following  */
1374         /* constants:                                           */
1375 #       define BACKING_STORE_ALIGNMENT 0x100000
1376 #       define BACKING_STORE_DISPLACEMENT 0x80000000
1377         extern char * GC_register_stackbottom;
1378 #       define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1379 #       define SEARCH_FOR_DATA_START
1380 #       define DATASTART GC_data_start
1381 #       define DYNAMIC_LOADING
1382 #       define MPROTECT_VDB
1383                 /* Requires Linux 2.3.47 or later.      */
1384         extern int _end;
1385 #       define DATAEND (&_end)
1386 #       ifdef __GNUC__
1387 #         define PREFETCH(x) \
1388             __asm__ ("  lfetch  [%0]": : "r"((void *)(x)))
1389 #         define PREFETCH_FOR_WRITE(x) \
1390             __asm__ ("  lfetch.excl     [%0]": : "r"((void *)(x)))
1391 #         define CLEAR_DOUBLE(x) \
1392             __asm__ ("  stf.spill       [%0]=f0": : "r"((void *)(x)))
1393 #       endif
1394 #   endif
1395 # endif
1396
1397 # ifdef M88K
1398 #   define MACH_TYPE "M88K"
1399 #   define ALIGNMENT 4
1400 #   define ALIGN_DOUBLE
1401     extern int etext;
1402 #   ifdef CX_UX
1403 #       define OS_TYPE "CX_UX"
1404 #       define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1405 #   endif
1406 #   ifdef  DGUX
1407 #       define OS_TYPE "DGUX"
1408         extern char * GC_SysVGetDataStart();
1409 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
1410 #   endif
1411 #   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1412 # endif
1413
1414 # ifdef S370
1415 #   define MACH_TYPE "S370"
1416 #   define ALIGNMENT 4  /* Required by hardware */
1417 #   define USE_GENERIC_PUSH_REGS
1418 #   ifdef UTS4
1419 #       define OS_TYPE "UTS4"
1420         extern int etext;
1421         extern int _etext;
1422         extern int _end;
1423         extern char * GC_SysVGetDataStart();
1424 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
1425 #       define DATAEND (&_end)
1426 #       define HEURISTIC2
1427 #   endif
1428 #   ifdef LINUX
1429 #       define OS_TYPE "LINUX"
1430 #       define HEURISTIC1
1431 #       define DYNAMIC_LOADING
1432         extern int __data_start;
1433 #       define DATASTART ((ptr_t)(&__data_start))
1434 #   endif
1435 # endif
1436
1437 # if defined(PJ)
1438 #   define ALIGNMENT 4
1439     extern int _etext;
1440 #   define DATASTART ((ptr_t)(&_etext))
1441 #   define HEURISTIC1
1442 # endif
1443
1444 # ifdef ARM32
1445 #   define CPP_WORDSZ 32
1446 #   define MACH_TYPE "ARM32"
1447 #   define ALIGNMENT 4
1448 #   ifdef NETBSD
1449 #       define OS_TYPE "NETBSD"
1450 #       define HEURISTIC2
1451         extern char etext;
1452 #       define DATASTART ((ptr_t)(&etext))
1453 #       define USE_GENERIC_PUSH_REGS
1454 #   endif
1455 #   ifdef LINUX
1456 #       define OS_TYPE "LINUX"
1457 #       define HEURISTIC1
1458 #       undef STACK_GRAN
1459 #       define STACK_GRAN 0x10000000
1460 #       define USE_GENERIC_PUSH_REGS
1461 #       ifdef __ELF__
1462 #            define DYNAMIC_LOADING
1463 #            include <features.h>
1464 #            if defined(__GLIBC__) && __GLIBC__ >= 2
1465 #                define LINUX_DATA_START
1466 #            else
1467                  extern char **__environ;
1468 #                define DATASTART ((ptr_t)(&__environ))
1469                               /* hideous kludge: __environ is the first */
1470                               /* word in crt0.o, and delimits the start */
1471                               /* of the data segment, no matter which   */
1472                               /* ld options were passed through.        */
1473                               /* We could use _etext instead, but that  */
1474                               /* would include .rodata, which may       */
1475                               /* contain large read-only data tables    */
1476                               /* that we'd rather not scan.             */
1477 #            endif
1478              extern int _end;
1479 #            define DATAEND (&_end)
1480 #       else
1481              extern int etext;
1482 #            define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
1483 #       endif
1484 #   endif
1485 #   ifdef MSWINCE
1486 #     define OS_TYPE "MSWINCE"
1487 #     define DATAEND /* not needed */
1488 #   endif
1489 #endif
1490
1491 # ifdef SH
1492 #   define MACH_TYPE "SH"
1493 #   define ALIGNMENT 4
1494 #   ifdef MSWINCE
1495 #     define OS_TYPE "MSWINCE"
1496 #     define DATAEND /* not needed */
1497 #   endif
1498 #   ifdef LINUX
1499 #     define OS_TYPE "LINUX"
1500 #     define STACKBOTTOM ((ptr_t) 0x7c000000)
1501 #     define USE_GENERIC_PUSH_REGS
1502 #     define DYNAMIC_LOADING
1503 #     define LINUX_DATA_START
1504       extern int _end;
1505 #     define DATAEND (&_end)
1506 #   endif
1507 # endif
1508  
1509 # ifdef SH4
1510 #   define MACH_TYPE "SH4"
1511 #   define OS_TYPE "MSWINCE"
1512 #   define ALIGNMENT 4
1513 #   define DATAEND /* not needed */
1514 # endif
1515
1516 #ifdef LINUX_DATA_START
1517     /* Some Linux distributions arrange to define __data_start.  Some   */
1518     /* define data_start as a weak symbol.  The latter is technically   */
1519     /* broken, since the user program may define data_start, in which   */
1520     /* case we lose.  Nonetheless, we try both, prefering __data_start. */
1521     /* We assume gcc.   */
1522 #   pragma weak __data_start
1523     extern int __data_start;
1524 #   pragma weak data_start
1525     extern int data_start;
1526 #   define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
1527 #endif
1528
1529 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1530     /* Rld appears to allocate some memory with its own allocator, and  */
1531     /* some through malloc, which might be redirected.  To make this    */
1532     /* work with collectable memory, we have to scan memory allocated   */
1533     /* by rld's internal malloc.                                        */
1534 #   define USE_PROC_FOR_LIBRARIES
1535 #endif
1536     
1537 # ifndef STACK_GROWS_UP
1538 #   define STACK_GROWS_DOWN
1539 # endif
1540
1541 # ifndef CPP_WORDSZ
1542 #   define CPP_WORDSZ 32
1543 # endif
1544
1545 # ifndef OS_TYPE
1546 #   define OS_TYPE ""
1547 # endif
1548
1549 # ifndef DATAEND
1550     extern int end;
1551 #   define DATAEND (&end)
1552 # endif
1553
1554 # if defined(SVR4) && !defined(GETPAGESIZE)
1555 #    include <unistd.h>
1556 #    define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
1557 # endif
1558
1559 # ifndef GETPAGESIZE
1560 #   if defined(SUNOS5) || defined(IRIX5)
1561 #       include <unistd.h>
1562 #   endif
1563 #   define GETPAGESIZE() getpagesize()
1564 # endif
1565
1566 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1567     /* OS has SVR4 generic features.  Probably others also qualify.     */
1568 #   define SVR4
1569 # endif
1570
1571 # if defined(SUNOS5) || defined(DRSNX)
1572     /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
1573     /* loader.                                                          */
1574 #   define SUNOS5DL
1575     /* OS has SUNOS5 style signal handlers.                             */
1576 #   define SUNOS5SIGS
1577 # endif
1578
1579 # if defined(HPUX)
1580 #   define SUNOS5SIGS
1581 # endif
1582
1583 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1584     || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1585     || defined(BSD) || defined(AIX) || defined(MACOSX) || defined(OSF1)
1586 #   define UNIX_LIKE   /* Basic Unix-like system calls work.    */
1587 # endif
1588
1589 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1590    -> bad word size
1591 # endif
1592
1593 # ifdef PCR
1594 #   undef DYNAMIC_LOADING
1595 #   undef STACKBOTTOM
1596 #   undef HEURISTIC1
1597 #   undef HEURISTIC2
1598 #   undef PROC_VDB
1599 #   undef MPROTECT_VDB
1600 #   define PCR_VDB
1601 # endif
1602
1603 # ifdef SRC_M3
1604 /* Postponed for now. */
1605 #   undef PROC_VDB
1606 #   undef MPROTECT_VDB
1607 # endif
1608
1609 # ifdef SMALL_CONFIG
1610 /* Presumably not worth the space it takes. */
1611 #   undef PROC_VDB
1612 #   undef MPROTECT_VDB
1613 # endif
1614
1615 # ifdef USE_MUNMAP
1616 #   undef MPROTECT_VDB  /* Can't deal with address space holes. */
1617 # endif
1618
1619 # ifdef PARALLEL_MARK
1620 #   undef MPROTECT_VDB  /* For now.     */
1621 # endif
1622
1623 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1624 #   define DEFAULT_VDB
1625 # endif
1626
1627 # ifndef PREFETCH
1628 #   define PREFETCH(x)
1629 #   define NO_PREFETCH
1630 # endif
1631
1632 # ifndef PREFETCH_FOR_WRITE
1633 #   define PREFETCH_FOR_WRITE(x)
1634 #   define NO_PREFETCH_FOR_WRITE
1635 # endif
1636
1637 # ifndef CACHE_LINE_SIZE
1638 #   define CACHE_LINE_SIZE 32   /* Wild guess   */
1639 # endif
1640
1641 # ifndef CLEAR_DOUBLE
1642 #   define CLEAR_DOUBLE(x) \
1643         ((word*)x)[0] = 0; \
1644         ((word*)x)[1] = 0;
1645 # endif /* CLEAR_DOUBLE */
1646
1647 /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
1648 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
1649 #   define GC_SOLARIS_THREADS
1650 # endif
1651
1652 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
1653 --> inconsistent configuration
1654 # endif
1655 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
1656 --> inconsistent configuration
1657 # endif
1658 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
1659 --> inconsistent configuration
1660 # endif
1661 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
1662 --> inconsistent configuration
1663 # endif
1664 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32)
1665     /* Ideally CYGWIN32 should work, in addition to MSWIN32.  I suspect */
1666     /* the necessary code is mostly there, but nobody has actually made */
1667     /* sure the right combination of pieces is compiled in, etc.        */
1668 --> inconsistent configuration
1669 # endif
1670
1671 # if defined(PCR) || defined(SRC_M3) || \
1672         defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
1673         defined(GC_PTHREADS)
1674 #   define THREADS
1675 # endif
1676
1677 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1678      || defined(LINT) || defined(MSWINCE) \
1679      || (defined(I386) && defined(__LCC__))
1680         /* Use setjmp based hack to mark from callee-save registers.    */
1681         /* The define should move to the individual platform            */
1682         /* descriptions.                                                */
1683 #       define USE_GENERIC_PUSH_REGS
1684 # endif
1685 # if defined(I386) && defined(LINUX)
1686     /* SAVE_CALL_CHAIN is supported if the code is compiled to save     */
1687     /* frame pointers by default, i.e. no -fomit-frame-pointer flag.    */
1688 # ifdef SAVE_CALL_COUNT
1689 #   define SAVE_CALL_CHAIN 
1690 # endif
1691 # endif
1692 # if defined(SPARC)
1693 #   define SAVE_CALL_CHAIN
1694 #   define ASM_CLEAR_CODE       /* Stack clearing is crucial, and we    */
1695                                 /* include assembly code to do it well. */
1696 # endif
1697
1698 # endif /* GCCONFIG_H */