OSDN Git Service

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