OSDN Git Service

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