OSDN Git Service

2007-01-16 Petr Salinger <Petr.Salinger@seznam.cz>
[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-2004 Hewlett-Packard Development Company, L.P.
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 /*
18  * This header is private to the gc.  It is almost always included from
19  * gc_priv.h.  However it is possible to include it by itself if just the
20  * configuration macros are needed.  In that
21  * case, a few declarations relying on types declared in gc_priv.h will be
22  * omitted.
23  */
24  
25 #ifndef GCCONFIG_H
26
27 # define GCCONFIG_H
28
29 # ifndef GC_PRIVATE_H
30     /* Fake ptr_t declaration, just to avoid compilation errors.        */
31     /* This avoids many instances if "ifndef GC_PRIVATE_H" below.       */
32     typedef struct GC_undefined_struct * ptr_t;
33 # endif
34
35 /* Machine dependent parameters.  Some tuning parameters can be found   */
36 /* near the top of gc_private.h.                                        */
37
38 /* Machine specific parts contributed by various people.  See README file. */
39
40 /* First a unified test for Linux: */
41 # if defined(linux) || defined(__linux__)
42 #  ifndef LINUX
43 #    define LINUX
44 #  endif
45 # endif
46
47 /* And one for NetBSD: */
48 # if defined(__NetBSD__)
49 #    define NETBSD
50 # endif
51
52 /* And one for OpenBSD: */
53 # if defined(__OpenBSD__)
54 #    define OPENBSD
55 # endif
56
57 /* And one for FreeBSD: */
58 # if ( defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ) && !defined(FREEBSD)
59 #    define FREEBSD
60 # endif
61
62 /* Determine the machine type: */
63 # if defined(__arm__) || defined(__thumb__)
64 #    define ARM32
65 #    if !defined(LINUX) && !defined(NETBSD)
66 #      define NOSYS
67 #      define mach_type_known
68 #    endif
69 # endif
70 # if defined(sun) && defined(mc68000)
71 #    define M68K
72 #    define SUNOS4
73 #    define mach_type_known
74 # endif
75 # if defined(hp9000s300)
76 #    define M68K
77 #    define HP
78 #    define mach_type_known
79 # endif
80 # if defined(OPENBSD) && defined(m68k)
81 #    define M68K
82 #    define mach_type_known
83 # endif
84 # if defined(OPENBSD) && defined(__sparc__)
85 #    define SPARC
86 #    define mach_type_known
87 # endif
88 # if defined(NETBSD) && (defined(m68k) || defined(__m68k__))
89 #    define M68K
90 #    define mach_type_known
91 # endif
92 # if defined(NETBSD) && defined(__powerpc__)
93 #    define POWERPC
94 #    define mach_type_known
95 # endif
96 # if defined(NETBSD) && (defined(__arm32__) || defined(__arm__))
97 #    define ARM32
98 #    define mach_type_known
99 # endif
100 # if defined(NETBSD) && defined(__sh__)
101 #    define SH
102 #    define mach_type_known
103 # endif
104 # if defined(vax)
105 #    define VAX
106 #    ifdef ultrix
107 #       define ULTRIX
108 #    else
109 #       define BSD
110 #    endif
111 #    define mach_type_known
112 # endif
113 # if defined(__NetBSD__) && defined(__vax__)
114 #    define VAX
115 #    define mach_type_known
116 # endif
117 # if defined(mips) || defined(__mips) || defined(_mips)
118 #    define MIPS
119 #    if defined(nec_ews) || defined(_nec_ews)
120 #      define EWS4800
121 #    endif
122 #    if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
123 #      if defined(ultrix) || defined(__ultrix)
124 #        define ULTRIX
125 #      else
126 #        if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
127             || defined(__SYSTYPE_SVR4__)
128 #          define IRIX5   /* or IRIX 6.X */
129 #        else
130 #          define RISCOS  /* or IRIX 4.X */
131 #        endif
132 #      endif
133 #    endif /* !LINUX */
134 #    if defined(__NetBSD__) && defined(__MIPSEL__)
135 #      undef ULTRIX
136 #    endif
137 #    define mach_type_known
138 # endif
139 # if defined(DGUX) && (defined(i386) || defined(__i386__))
140 #    define I386
141 #    ifndef _USING_DGUX
142 #    define _USING_DGUX
143 #    endif
144 #    define mach_type_known
145 # endif
146 # if defined(sequent) && (defined(i386) || defined(__i386__))
147 #    define I386
148 #    define SEQUENT
149 #    define mach_type_known
150 # endif
151 # if defined(sun) && (defined(i386) || defined(__i386__))
152 #    define I386
153 #    define SUNOS5
154 #    define mach_type_known
155 # endif
156 # if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
157 #    define I386
158 #    define OS2
159 #    define mach_type_known
160 # endif
161 # if defined(ibm032)
162 #   define RT
163 #   define mach_type_known
164 # endif
165 # if defined(sun) && (defined(sparc) || defined(__sparc))
166 #   define SPARC
167     /* Test for SunOS 5.x */
168 #     include <errno.h>
169 #     ifdef ECHRNG
170 #       define SUNOS5
171 #     else
172 #       define SUNOS4
173 #     endif
174 #   define mach_type_known
175 # endif
176 # if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
177      && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
178 #   define SPARC
179 #   define DRSNX
180 #   define mach_type_known
181 # endif
182 # if defined(_IBMR2)
183 #   define RS6000
184 #   define mach_type_known
185 # endif
186 # if defined(__NetBSD__) && defined(__sparc__)
187 #   define SPARC
188 #   define mach_type_known
189 # endif
190 # if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
191         /* The above test may need refinement   */
192 #   define I386
193 #   if defined(_SCO_ELF)
194 #     define SCO_ELF
195 #   else
196 #     define SCO
197 #   endif
198 #   define mach_type_known
199 # endif
200 # if defined(_AUX_SOURCE)
201 #   define M68K
202 #   define SYSV
203 #   define mach_type_known
204 # endif
205 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
206      || defined(hppa) || defined(__hppa__)
207 #   define HP_PA
208 #   if !defined(LINUX) && !defined(HPUX)
209 #     define HPUX
210 #   endif
211 #   define mach_type_known
212 # endif
213 # if defined(__ia64) && defined(_HPUX_SOURCE)
214 #   define IA64
215 #   ifndef HPUX
216 #     define HPUX
217 #   endif
218 #   define mach_type_known
219 # endif
220 # if defined(__BEOS__) && defined(_X86_)
221 #    define I386
222 #    define BEOS
223 #    define mach_type_known
224 # endif
225 # if defined(LINUX) && (defined(i386) || defined(__i386__))
226 #    define I386
227 #    define mach_type_known
228 # endif
229 # if defined(LINUX) && defined(__x86_64__)
230 #    define X86_64
231 #    define mach_type_known
232 # endif
233 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
234 #    define IA64
235 #    define mach_type_known
236 # endif
237 # if defined(LINUX) && defined(__arm__)
238 #    define ARM32
239 #    define mach_type_known
240 # endif
241 # if defined(LINUX) && defined(__cris__)
242 #    ifndef CRIS
243 #       define CRIS
244 #    endif
245 #    define mach_type_known
246 # endif
247 # if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
248                         defined(powerpc64) || defined(__powerpc64__))
249 #    define POWERPC
250 #    define mach_type_known
251 # endif
252 # if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
253 #    define POWERPC
254 #    define mach_type_known
255 # endif
256 # if defined(LINUX) && defined(__mc68000__)
257 #    define M68K
258 #    define mach_type_known
259 # endif
260 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
261 #    define SPARC
262 #    define mach_type_known
263 # endif
264 # if defined(LINUX) && defined(__arm__)
265 #    define ARM32
266 #    define mach_type_known
267 # endif
268 # if defined(LINUX) && defined(__sh__)
269 #    define SH
270 #    define mach_type_known
271 # endif
272 # if defined(LINUX) && defined(__m32r__)
273 #    define M32R
274 #    define mach_type_known
275 # endif
276 # if defined(__alpha) || defined(__alpha__)
277 #   define ALPHA
278 #   if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
279 #     define OSF1       /* a.k.a Digital Unix */
280 #   endif
281 #   define mach_type_known
282 # endif
283 # if defined(_AMIGA) && !defined(AMIGA)
284 #   define AMIGA
285 # endif
286 # ifdef AMIGA 
287 #   define M68K
288 #   define mach_type_known
289 # endif
290 # if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
291 #   define M68K
292 #   define MACOS
293 #   define mach_type_known
294 # endif
295 # if defined(__MWERKS__) && defined(__powerc) && !defined(__MACH__)
296 #   define POWERPC
297 #   define MACOS
298 #   define mach_type_known
299 # endif
300 # if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
301 #   define DARWIN
302 #   if defined(__ppc__)  || defined(__ppc64__)
303 #    define POWERPC
304 #    define mach_type_known
305 #   elif defined(__x86_64__)
306 #    define X86_64
307 #    define mach_type_known
308 #   elif defined(__i386__)
309 #    define I386
310 #    define mach_type_known
311 #   endif
312 # endif
313 # if defined(NeXT) && defined(mc68000)
314 #   define M68K
315 #   define NEXT
316 #   define mach_type_known
317 # endif
318 # if defined(NeXT) && (defined(i386) || defined(__i386__))
319 #   define I386
320 #   define NEXT
321 #   define mach_type_known
322 # endif
323 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
324 #   define I386
325 #   define OPENBSD
326 #   define mach_type_known
327 # endif
328 # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
329 #   define I386
330 #   define mach_type_known
331 # endif
332 # if defined(FREEBSD) && defined(__x86_64__)
333 #   define X86_64
334 #   define mach_type_known
335 # endif
336 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
337 #   define I386
338 #   define mach_type_known
339 # endif
340 # if defined(__NetBSD__) && defined(__x86_64__)
341 #    define X86_64
342 #    define mach_type_known
343 # endif
344 # if defined(FREEBSD) && defined(__sparc__)
345 #    define SPARC
346 #    define mach_type_known
347 #endif
348 # if defined(bsdi) && (defined(i386) || defined(__i386__))
349 #    define I386
350 #    define BSDI
351 #    define mach_type_known
352 # endif
353 # if !defined(mach_type_known) && defined(__386BSD__)
354 #   define I386
355 #   define THREE86BSD
356 #   define mach_type_known
357 # endif
358 # if defined(_CX_UX) && defined(_M88K)
359 #   define M88K
360 #   define CX_UX
361 #   define mach_type_known
362 # endif
363 # if defined(DGUX) && defined(m88k)
364 #   define M88K
365     /* DGUX defined */
366 #   define mach_type_known
367 # endif
368 # if defined(_WIN32_WCE)
369     /* SH3, SH4, MIPS already defined for corresponding architectures */
370 #   if defined(SH3) || defined(SH4)
371 #     define SH
372 #   endif
373 #   if defined(x86)
374 #     define I386
375 #   endif
376 #   if defined(ARM)
377 #     define ARM32
378 #   endif
379 #   define MSWINCE
380 #   define mach_type_known
381 # else
382 #   if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
383         || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
384 #     define I386
385 #     define MSWIN32    /* or Win32s */
386 #     define mach_type_known
387 #   endif
388 #   if defined(_MSC_VER) && defined(_M_IA64)
389 #     define IA64
390 #     define MSWIN32    /* Really win64, but we don't treat 64-bit      */
391                         /* variants as a differnt platform.             */
392 #   endif
393 # endif
394 # if defined(__DJGPP__)
395 #   define I386
396 #   ifndef DJGPP
397 #     define DJGPP  /* MSDOS running the DJGPP port of GCC */
398 #   endif
399 #   define mach_type_known
400 # endif
401 # if defined(__CYGWIN32__) || defined(__CYGWIN__)
402 #   define I386
403 #   define CYGWIN32
404 #   define mach_type_known
405 # endif
406 # if defined(__MINGW32__)
407 #   define I386
408 #   define MSWIN32
409 #   define mach_type_known
410 # endif
411 # if defined(__BORLANDC__)
412 #   define I386
413 #   define MSWIN32
414 #   define mach_type_known
415 # endif
416 # if defined(_UTS) && !defined(mach_type_known)
417 #   define S370
418 #   define UTS4
419 #   define mach_type_known
420 # endif
421 # if defined(__pj__)
422 #   define PJ
423 #   define mach_type_known
424 # endif
425 # if defined(__embedded__) && defined(PPC)
426 #   define POWERPC
427 #   define NOSYS
428 #   define mach_type_known
429 # endif
430 /* Ivan Demakov */
431 # if defined(__WATCOMC__) && defined(__386__)
432 #   define I386
433 #   if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
434 #     if defined(__OS2__)
435 #       define OS2
436 #     else
437 #       if defined(__WINDOWS_386__) || defined(__NT__)
438 #         define MSWIN32
439 #       else
440 #         define DOS4GW
441 #       endif
442 #     endif
443 #   endif
444 #   define mach_type_known
445 # endif
446 # if defined(__s390__) && defined(LINUX)
447 #    define S390
448 #    define mach_type_known
449 # endif
450 # if defined(__GNU__)
451 #   if defined(__i386__)
452 /* The Debian Hurd running on generic PC */  
453 #     define  HURD
454 #     define  I386
455 #     define  mach_type_known
456 #    endif 
457 # endif
458
459 /* Feel free to add more clauses here */
460
461 /* Or manually define the machine type here.  A machine type is         */
462 /* characterized by the architecture.  Some                             */
463 /* machine types are further subdivided by OS.                          */
464 /* the macros ULTRIX, RISCOS, and BSD to distinguish.                   */
465 /* Note that SGI IRIX is treated identically to RISCOS.                 */
466 /* SYSV on an M68K actually means A/UX.                                 */
467 /* The distinction in these cases is usually the stack starting address */
468 # ifndef mach_type_known
469         --> unknown machine type
470 # endif
471                     /* Mapping is: M68K       ==> Motorola 680X0        */
472                     /*             (SUNOS4,HP,NEXT, and SYSV (A/UX),    */
473                     /*             MACOS and AMIGA variants)            */
474                     /*             I386       ==> Intel 386             */
475                     /*              (SEQUENT, OS2, SCO, LINUX, NETBSD,  */
476                     /*               FREEBSD, THREE86BSD, MSWIN32,      */
477                     /*               BSDI,SUNOS5, NEXT, other variants) */
478                     /*             NS32K      ==> Encore Multimax       */
479                     /*             MIPS       ==> R2000 or R3000        */
480                     /*                  (RISCOS, ULTRIX variants)       */
481                     /*             VAX        ==> DEC VAX               */
482                     /*                  (BSD, ULTRIX variants)          */
483                     /*             RS6000     ==> IBM RS/6000 AIX3.X    */
484                     /*             RT         ==> IBM PC/RT             */
485                     /*             HP_PA      ==> HP9000/700 & /800     */
486                     /*                            HP/UX, LINUX          */
487                     /*             SPARC      ==> SPARC v7/v8/v9        */
488                     /*                  (SUNOS4, SUNOS5, LINUX,         */
489                     /*                   DRSNX variants)                */
490                     /*             ALPHA      ==> DEC Alpha             */
491                     /*                  (OSF1 and LINUX variants)       */
492                     /*             M88K       ==> Motorola 88XX0        */
493                     /*                  (CX_UX and DGUX)                */
494                     /*             S370       ==> 370-like machine      */
495                     /*                  running Amdahl UTS4             */
496                     /*             S390       ==> 390-like machine      */
497                     /*                  running LINUX                   */
498                     /*             ARM32      ==> Intel StrongARM       */
499                     /*             IA64       ==> Intel IPF             */
500                     /*                            (e.g. Itanium)        */
501                     /*                  (LINUX and HPUX)                */
502                     /*             SH         ==> Hitachi SuperH        */
503                     /*                  (LINUX & MSWINCE)               */
504                     /*             X86_64     ==> AMD x86-64            */
505                     /*             POWERPC    ==> IBM/Apple PowerPC     */
506                     /*                  (MACOS(<=9),DARWIN(incl.MACOSX),*/
507                     /*                   LINUX, NETBSD, NOSYS variants) */
508                     /*                  Handles 32 and 64-bit variants. */
509                     /*                  AIX should be handled here, but */
510                     /*                  that's called an RS6000.        */
511                     /*             CRIS       ==> Axis Etrax            */
512                     /*             M32R       ==> Renesas M32R          */
513
514
515 /*
516  * For each architecture and OS, the following need to be defined:
517  *
518  * CPP_WORDSZ is a simple integer constant representing the word size.
519  * in bits.  We assume byte addressibility, where a byte has 8 bits.
520  * We also assume CPP_WORDSZ is either 32 or 64.
521  * (We care about the length of pointers, not hardware
522  * bus widths.  Thus a 64 bit processor with a C compiler that uses
523  * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
524  *
525  * MACH_TYPE is a string representation of the machine type.
526  * OS_TYPE is analogous for the OS.
527  *
528  * ALIGNMENT is the largest N, such that
529  * all pointer are guaranteed to be aligned on N byte boundaries.
530  * defining it to be 1 will always work, but perform poorly.
531  *
532  * DATASTART is the beginning of the data segment.
533  * On some platforms SEARCH_FOR_DATA_START is defined.
534  * SEARCH_FOR_DATASTART will cause GC_data_start to
535  * be set to an address determined by accessing data backwards from _end
536  * until an unmapped page is found.  DATASTART will be defined to be
537  * GC_data_start.
538  * On UNIX-like systems, the collector will scan the area between DATASTART
539  * and DATAEND for root pointers.
540  *
541  * DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
542  * RTH suggests gaining access to linker script synth'd values with
543  * this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
544  * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
545  * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
546  * without any special options.
547  *
548  * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
549  * the pointer size.
550  *
551  * STACKBOTTOM is the cool end of the stack, which is usually the
552  * highest address in the stack.
553  * Under PCR or OS/2, we have other ways of finding thread stacks.
554  * For each machine, the following should:
555  * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
556  * 2) define exactly one of
557  *      STACKBOTTOM (should be defined to be an expression)
558  *      LINUX_STACKBOTTOM
559  *      HEURISTIC1
560  *      HEURISTIC2
561  * If STACKBOTTOM is defined, then it's value will be used directly as the
562  * stack base.  If LINUX_STACKBOTTOM is defined, then it will be determined
563  * with a method appropriate for most Linux systems.  Currently we look
564  * first for __libc_stack_end, and if that fails read it from /proc.
565  * If either of the last two macros are defined, then STACKBOTTOM is computed
566  * during collector startup using one of the following two heuristics:
567  * HEURISTIC1:  Take an address inside GC_init's frame, and round it up to
568  *              the next multiple of STACK_GRAN.
569  * HEURISTIC2:  Take an address inside GC_init's frame, increment it repeatedly
570  *              in small steps (decrement if STACK_GROWS_UP), and read the value
571  *              at each location.  Remember the value when the first
572  *              Segmentation violation or Bus error is signalled.  Round that
573  *              to the nearest plausible page boundary, and use that instead
574  *              of STACKBOTTOM.
575  *
576  * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
577  * the value of environ is a pointer that can serve as STACKBOTTOM.
578  * I expect that HEURISTIC2 can be replaced by this approach, which
579  * interferes far less with debugging.  However it has the disadvantage
580  * that it's confused by a putenv call before the collector is initialized.
581  * This could be dealt with by intercepting putenv ...
582  *
583  * If no expression for STACKBOTTOM can be found, and neither of the above
584  * heuristics are usable, the collector can still be used with all of the above
585  * undefined, provided one of the following is done:
586  * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
587  *    without reference to STACKBOTTOM.  This is appropriate for use in
588  *    conjunction with thread packages, since there will be multiple stacks.
589  *    (Allocating thread stacks in the heap, and treating them as ordinary
590  *    heap data objects is also possible as a last resort.  However, this is
591  *    likely to introduce significant amounts of excess storage retention
592  *    unless the dead parts of the thread stacks are periodically cleared.)
593  * 2) Client code may set GC_stackbottom before calling any GC_ routines.
594  *    If the author of the client code controls the main program, this is
595  *    easily accomplished by introducing a new main program, setting
596  *    GC_stackbottom to the address of a local variable, and then calling
597  *    the original main program.  The new main program would read something
598  *    like:
599  *
600  *              # include "gc_private.h"
601  *
602  *              main(argc, argv, envp)
603  *              int argc;
604  *              char **argv, **envp;
605  *              {
606  *                  int dummy;
607  *
608  *                  GC_stackbottom = (ptr_t)(&dummy);
609  *                  return(real_main(argc, argv, envp));
610  *              }
611  *
612  *
613  * Each architecture may also define the style of virtual dirty bit
614  * implementation to be used:
615  *   MPROTECT_VDB: Write protect the heap and catch faults.
616  *   PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
617  *
618  * An architecture may define DYNAMIC_LOADING if dynamic_load.c
619  * defined GC_register_dynamic_libraries() for the architecture.
620  *
621  * An architecture may define PREFETCH(x) to preload the cache with *x.
622  * This defaults to a no-op.
623  *
624  * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
625  *
626  * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
627  * clear the two words at GC_malloc-aligned address x.  By default,
628  * word stores of 0 are used instead.
629  *
630  * HEAP_START may be defined as the initial address hint for mmap-based
631  * allocation.
632  */
633
634 /* If we are using a recent version of gcc, we can use __builtin_unwind_init()
635  * to push the relevant registers onto the stack.  This generally makes
636  * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
637  */
638 # if defined(__GNUC__) && ((__GNUC__ >= 3) || \
639                            (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
640                        && !defined(__INTEL_COMPILER) \
641                        && !defined(__PATHCC__)
642 #   define HAVE_BUILTIN_UNWIND_INIT
643 # endif
644
645 # define STACK_GRAN 0x1000000
646 # ifdef M68K
647 #   define MACH_TYPE "M68K"
648 #   define ALIGNMENT 2
649 #   ifdef OPENBSD
650 #       define OS_TYPE "OPENBSD"
651 #       define HEURISTIC2
652 #       ifdef __ELF__
653 #         define DATASTART GC_data_start
654 #         define DYNAMIC_LOADING
655 #       else
656           extern char etext[];
657 #         define DATASTART ((ptr_t)(etext))
658 #       endif
659 #       define USE_GENERIC_PUSH_REGS
660 #   endif
661 #   ifdef NETBSD
662 #       define OS_TYPE "NETBSD"
663 #       define HEURISTIC2
664 #       ifdef __ELF__
665 #         define DATASTART GC_data_start
666 #         define DYNAMIC_LOADING
667 #       else
668           extern char etext[];
669 #         define DATASTART ((ptr_t)(etext))
670 #       endif
671 #       define USE_GENERIC_PUSH_REGS
672 #   endif
673 #   ifdef LINUX
674 #       define OS_TYPE "LINUX"
675 #       define STACKBOTTOM ((ptr_t)0xf0000000)
676 #       define USE_GENERIC_PUSH_REGS
677                 /* We never got around to the assembly version. */
678 /* #       define MPROTECT_VDB - Reported to not work  9/17/01 */
679 #       ifdef __ELF__
680 #            define DYNAMIC_LOADING
681 #            include <features.h>
682 #            if defined(__GLIBC__)&& __GLIBC__>=2
683 #              define SEARCH_FOR_DATA_START
684 #            else /* !GLIBC2 */
685                extern char **__environ;
686 #              define DATASTART ((ptr_t)(&__environ))
687                              /* hideous kludge: __environ is the first */
688                              /* word in crt0.o, and delimits the start */
689                              /* of the data segment, no matter which   */
690                              /* ld options were passed through.        */
691                              /* We could use _etext instead, but that  */
692                              /* would include .rodata, which may       */
693                              /* contain large read-only data tables    */
694                              /* that we'd rather not scan.             */
695 #            endif /* !GLIBC2 */
696              extern int _end[];
697 #            define DATAEND (_end)
698 #       else
699              extern int etext[];
700 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
701 #       endif
702 #   endif
703 #   ifdef SUNOS4
704 #       define OS_TYPE "SUNOS4"
705         extern char etext[];
706 #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
707 #       define HEURISTIC1       /* differs      */
708 #       define DYNAMIC_LOADING
709 #   endif
710 #   ifdef HP
711 #       define OS_TYPE "HP"
712         extern char etext[];
713 #       define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
714 #       define STACKBOTTOM ((ptr_t) 0xffeffffc)
715                               /* empirically determined.  seems to work. */
716 #       include <unistd.h>
717 #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
718 #   endif
719 #   ifdef SYSV
720 #       define OS_TYPE "SYSV"
721         extern etext[];
722 #       define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
723                                    & ~0x3fffff) \
724                                   +((word)etext & 0x1fff))
725         /* This only works for shared-text binaries with magic number 0413.
726            The other sorts of SysV binaries put the data at the end of the text,
727            in which case the default of etext would work.  Unfortunately,
728            handling both would require having the magic-number available.
729                                 -- Parag
730            */
731 #       define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
732                         /* The stack starts at the top of memory, but   */
733                         /* 0x0 cannot be used as setjump_test complains */
734                         /* that the stack direction is incorrect.  Two  */
735                         /* bytes down from 0x0 should be safe enough.   */
736                         /*              --Parag                         */
737 #       include <sys/mmu.h>
738 #       define GETPAGESIZE() PAGESIZE   /* Is this still right? */
739 #   endif
740 #   ifdef AMIGA
741 #       define OS_TYPE "AMIGA"
742                 /* STACKBOTTOM and DATASTART handled specially  */
743                 /* in os_dep.c                                  */
744 #       define DATAEND  /* not needed */
745 #       define GETPAGESIZE() 4096
746 #   endif
747 #   ifdef MACOS
748 #     ifndef __LOWMEM__
749 #     include <LowMem.h>
750 #     endif
751 #     define OS_TYPE "MACOS"
752                         /* see os_dep.c for details of global data segments. */
753 #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
754 #     define DATAEND    /* not needed */
755 #     define GETPAGESIZE() 4096
756 #   endif
757 #   ifdef NEXT
758 #       define OS_TYPE "NEXT"
759 #       define DATASTART ((ptr_t) get_etext())
760 #       define STACKBOTTOM ((ptr_t) 0x4000000)
761 #       define DATAEND  /* not needed */
762 #   endif
763 # endif
764
765 # if defined(POWERPC)
766 #   define MACH_TYPE "POWERPC"
767 #   ifdef MACOS
768 #     define ALIGNMENT 2  /* Still necessary?  Could it be 4?   */
769 #     ifndef __LOWMEM__
770 #     include <LowMem.h>
771 #     endif
772 #     define OS_TYPE "MACOS"
773                         /* see os_dep.c for details of global data segments. */
774 #     define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
775 #     define DATAEND  /* not needed */
776 #   endif
777 #   ifdef LINUX
778 #     if defined(__powerpc64__)
779 #       define ALIGNMENT 8
780 #       define CPP_WORDSZ 64
781 #       ifndef HBLKSIZE
782 #         define HBLKSIZE 4096
783 #       endif
784 #     else
785 #       define ALIGNMENT 4
786 #     endif
787 #     define OS_TYPE "LINUX"
788       /* HEURISTIC1 has been reliably reported to fail for a 32-bit     */
789       /* executable on a 64 bit kernel.                                 */
790 #     define LINUX_STACKBOTTOM
791 #     define DYNAMIC_LOADING
792 #     define SEARCH_FOR_DATA_START
793       extern int _end[];
794 #     define DATAEND (_end)
795 #   endif
796 #   ifdef DARWIN
797 #     if defined(__ppc64__)
798 #       define ALIGNMENT 8
799 #       define CPP_WORDSZ 64
800 #     else
801 #       define ALIGNMENT 4
802 #     endif
803 #     define OS_TYPE "DARWIN"
804 #     define DYNAMIC_LOADING
805       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
806          These aren't used when dyld support is enabled (it is by default) */
807 #     define DATASTART ((ptr_t) get_etext())
808 #     define DATAEND    ((ptr_t) get_end())
809 #     define STACKBOTTOM ((ptr_t) 0xc0000000)
810 #     define USE_MMAP
811 #     define USE_MMAP_ANON
812 #     define USE_ASM_PUSH_REGS
813       /* This is potentially buggy. It needs more testing. See the comments in
814          os_dep.c.  It relies on threads to track writes. */
815 #     ifdef GC_DARWIN_THREADS
816 /*#       define MPROTECT_VDB -- diabled for now.  May work for some apps. */
817 #     endif
818 #     include <unistd.h>
819 #     define GETPAGESIZE() getpagesize()
820 #     if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
821         /* The performance impact of prefetches is untested */
822 #       define PREFETCH(x) \
823           __asm__ __volatile__ ("dcbt 0,%0" : : "r" ((const void *) (x)))
824 #       define PREFETCH_FOR_WRITE(x) \
825           __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
826 #     endif
827       /* There seems to be some issues with trylock hanging on darwin. This
828          should be looked into some more */
829 #     define NO_PTHREAD_TRYLOCK
830 #   endif
831 #   ifdef FREEBSD
832 #       define ALIGNMENT 4
833 #       define OS_TYPE "FREEBSD"
834 #       ifndef GC_FREEBSD_THREADS
835 #           define MPROTECT_VDB
836 #       endif
837 #       define SIG_SUSPEND SIGUSR1
838 #       define SIG_THR_RESTART SIGUSR2
839 #       define FREEBSD_STACKBOTTOM
840 #       ifdef __ELF__
841 #           define DYNAMIC_LOADING
842 #       endif
843         extern char etext[];
844         extern char * GC_FreeBSDGetDataStart();
845 #       define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
846 #   endif
847 #   ifdef NETBSD
848 #     define ALIGNMENT 4
849 #     define OS_TYPE "NETBSD"
850 #     define HEURISTIC2
851       extern char etext[];
852 #     define DATASTART GC_data_start
853 #     define DYNAMIC_LOADING
854 #   endif
855 #   ifdef NOSYS
856 #     define ALIGNMENT 4
857 #     define OS_TYPE "NOSYS"
858       extern void __end[], __dso_handle[];
859 #     define DATASTART (__dso_handle)  /* OK, that's ugly.  */
860 #     define DATAEND (__end)
861         /* Stack starts at 0xE0000000 for the simulator.  */
862 #     undef STACK_GRAN
863 #     define STACK_GRAN 0x10000000
864 #     define HEURISTIC1
865 #   endif
866 # endif
867
868 # ifdef VAX
869 #   define MACH_TYPE "VAX"
870 #   define ALIGNMENT 4  /* Pointers are longword aligned by 4.2 C compiler */
871     extern char etext[];
872 #   define DATASTART ((ptr_t)(etext))
873 #   ifdef BSD
874 #       define OS_TYPE "BSD"
875 #       define HEURISTIC1
876                         /* HEURISTIC2 may be OK, but it's hard to test. */
877 #   endif
878 #   ifdef ULTRIX
879 #       define OS_TYPE "ULTRIX"
880 #       define STACKBOTTOM ((ptr_t) 0x7fffc800)
881 #   endif
882 # endif
883
884 # ifdef RT
885 #   define MACH_TYPE "RT"
886 #   define ALIGNMENT 4
887 #   define DATASTART ((ptr_t) 0x10000000)
888 #   define STACKBOTTOM ((ptr_t) 0x1fffd800)
889 # endif
890
891 # ifdef SPARC
892 #   define MACH_TYPE "SPARC"
893 #   if defined(__arch64__) || defined(__sparcv9)
894 #     define ALIGNMENT 8
895 #     define CPP_WORDSZ 64
896 #     define ELF_CLASS ELFCLASS64
897 #   else
898 #     define ALIGNMENT 4        /* Required by hardware */
899 #     define CPP_WORDSZ 32
900 #   endif
901 #   define ALIGN_DOUBLE
902 #   ifdef SUNOS5
903 #       define OS_TYPE "SUNOS5"
904         extern int _etext[];
905         extern int _end[];
906         extern ptr_t GC_SysVGetDataStart();
907 #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
908 #       define DATAEND (_end)
909 #       if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
910 #           define USE_MMAP
911             /* Otherwise we now use calloc.  Mmap may result in the     */
912             /* heap interleaved with thread stacks, which can result in */
913             /* excessive blacklisting.  Sbrk is unusable since it       */
914             /* doesn't interact correctly with the system malloc.       */
915 #       endif
916 #       ifdef USE_MMAP
917 #         define HEAP_START (ptr_t)0x40000000
918 #       else
919 #         define HEAP_START DATAEND
920 #       endif
921 #       define PROC_VDB
922 /*      HEURISTIC1 reportedly no longer works under 2.7.                */
923 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
924 /*      Apparently USRSTACK is defined to be USERLIMIT, but in some     */
925 /*      installations that's undefined.  We work around this with a     */
926 /*      gross hack:                                                     */
927 #       include <sys/vmparam.h>
928 #       ifdef USERLIMIT
929           /* This should work everywhere, but doesn't.  */
930 #         define STACKBOTTOM USRSTACK
931 #       else
932 #         define HEURISTIC2
933 #       endif
934 #       include <unistd.h>
935 #       define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
936                 /* getpagesize() appeared to be missing from at least one */
937                 /* Solaris 5.4 installation.  Weird.                      */
938 #       define DYNAMIC_LOADING
939 #   endif
940 #   ifdef SUNOS4
941 #       define OS_TYPE "SUNOS4"
942         /* [If you have a weak stomach, don't read this.]               */
943         /* We would like to use:                                        */
944 /* #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
945         /* This fails occasionally, due to an ancient, but very         */
946         /* persistent ld bug.  etext is set 32 bytes too high.          */
947         /* We instead read the text segment size from the a.out         */
948         /* header, which happens to be mapped into our address space    */
949         /* at the start of the text segment.  The detective work here   */
950         /* was done by Robert Ehrlich, Manuel Serrano, and Bernard      */
951         /* Serpette of INRIA.                                           */
952         /* This assumes ZMAGIC, i.e. demand-loadable executables.       */
953 #       define TEXTSTART 0x2000
954 #       define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
955 #       define MPROTECT_VDB
956 #       define HEURISTIC1
957 #       define DYNAMIC_LOADING
958 #   endif
959 #   ifdef DRSNX
960 #       define OS_TYPE "DRSNX"
961         extern ptr_t GC_SysVGetDataStart();
962         extern int etext[];
963 #       define DATASTART GC_SysVGetDataStart(0x10000, etext)
964 #       define MPROTECT_VDB
965 #       define STACKBOTTOM ((ptr_t) 0xdfff0000)
966 #       define DYNAMIC_LOADING
967 #   endif
968 #   ifdef LINUX
969 #     define OS_TYPE "LINUX"
970 #     ifdef __ELF__
971 #       define DYNAMIC_LOADING
972 #     else
973           Linux Sparc/a.out not supported
974 #     endif
975       extern int _end[];
976       extern int _etext[];
977 #     define DATAEND (_end)
978 #     define SVR4
979       extern ptr_t GC_SysVGetDataStart();
980 #     ifdef __arch64__
981 #       define DATASTART GC_SysVGetDataStart(0x100000, _etext)
982 #     else
983 #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
984 #     endif
985 #     define LINUX_STACKBOTTOM
986 #   endif
987 #   ifdef OPENBSD
988 #     define OS_TYPE "OPENBSD"
989 #     define STACKBOTTOM ((ptr_t) 0xf8000000)
990       extern int etext[];
991 #     define DATASTART ((ptr_t)(etext))
992 #   endif
993 #   ifdef NETBSD
994 #     define OS_TYPE "NETBSD"
995 #     define HEURISTIC2
996 #     ifdef __ELF__
997 #       define DATASTART GC_data_start
998 #       define DYNAMIC_LOADING
999 #     else
1000         extern char etext[];
1001 #       define DATASTART ((ptr_t)(etext))
1002 #     endif
1003 #   endif
1004 #   ifdef FREEBSD
1005 #       define OS_TYPE "FREEBSD"
1006 #       define SIG_SUSPEND SIGUSR1
1007 #       define SIG_THR_RESTART SIGUSR2
1008 #       define FREEBSD_STACKBOTTOM
1009 #       ifdef __ELF__
1010 #           define DYNAMIC_LOADING
1011 #       endif
1012         extern char etext[];
1013         extern char edata[];
1014         extern char end[];
1015 #       define NEED_FIND_LIMIT
1016 #       define DATASTART ((ptr_t)(&etext))
1017 #       define DATAEND (GC_find_limit (DATASTART, TRUE))
1018 #       define DATASTART2 ((ptr_t)(&edata))
1019 #       define DATAEND2 ((ptr_t)(&end))
1020 #   endif
1021 # endif
1022
1023 # ifdef I386
1024 #   define MACH_TYPE "I386"
1025 #   if defined(__LP64__) || defined(_WIN64)
1026 #     define CPP_WORDSZ 64
1027 #     define ALIGNMENT 8
1028 #   else
1029 #     define CPP_WORDSZ 32
1030 #     define ALIGNMENT 4
1031                         /* Appears to hold for all "32 bit" compilers   */
1032                         /* except Borland.  The -a4 option fixes        */
1033                         /* Borland.                                     */
1034                         /* Ivan Demakov: For Watcom the option is -zp4. */
1035 #   endif
1036 #   ifndef SMALL_CONFIG
1037 #     define ALIGN_DOUBLE /* Not strictly necessary, but may give speed   */
1038                           /* improvement on Pentiums.                     */
1039 #   endif
1040 #   ifdef HAVE_BUILTIN_UNWIND_INIT
1041 #       define USE_GENERIC_PUSH_REGS
1042 #   endif
1043 #   ifdef SEQUENT
1044 #       define OS_TYPE "SEQUENT"
1045         extern int etext[];
1046 #       define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1047 #       define STACKBOTTOM ((ptr_t) 0x3ffff000) 
1048 #   endif
1049 #   ifdef BEOS
1050 #     define OS_TYPE "BEOS"
1051 #     include <OS.h>
1052 #     define GETPAGESIZE() B_PAGE_SIZE
1053       extern int etext[];
1054 #     define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1055 #   endif
1056 #   ifdef SUNOS5
1057 #       define OS_TYPE "SUNOS5"
1058         extern int _etext[], _end[];
1059         extern ptr_t GC_SysVGetDataStart();
1060 #       define DATASTART GC_SysVGetDataStart(0x1000, _etext)
1061 #       define DATAEND (_end)
1062 /*      # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,      */
1063 /*      but reportedly breaks under 2.8.  It appears that the stack     */
1064 /*      base is a property of the executable, so this should not break  */
1065 /*      old executables.                                                */
1066 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
1067 #       include <sys/vm.h>
1068 #       define STACKBOTTOM USRSTACK
1069 /* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
1070 /* It appears to be fixed in 2.8 and 2.9.                               */
1071 #       ifdef SOLARIS25_PROC_VDB_BUG_FIXED
1072 #         define PROC_VDB
1073 #       endif
1074 #       define DYNAMIC_LOADING
1075 #       if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
1076 #           define USE_MMAP
1077             /* Otherwise we now use calloc.  Mmap may result in the     */
1078             /* heap interleaved with thread stacks, which can result in */
1079             /* excessive blacklisting.  Sbrk is unusable since it       */
1080             /* doesn't interact correctly with the system malloc.       */
1081 #       endif
1082 #       ifdef USE_MMAP
1083 #         define HEAP_START (ptr_t)0x40000000
1084 #       else
1085 #         define HEAP_START DATAEND
1086 #       endif
1087 #   endif
1088 #   ifdef SCO
1089 #       define OS_TYPE "SCO"
1090         extern int etext[];
1091 #       define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
1092                                   & ~0x3fffff) \
1093                                  +((word)etext & 0xfff))
1094 #       define STACKBOTTOM ((ptr_t) 0x7ffffffc)
1095 #   endif
1096 #   ifdef SCO_ELF
1097 #       define OS_TYPE "SCO_ELF"
1098         extern int etext[];
1099 #       define DATASTART ((ptr_t)(etext))
1100 #       define STACKBOTTOM ((ptr_t) 0x08048000)
1101 #       define DYNAMIC_LOADING
1102 #       define ELF_CLASS ELFCLASS32
1103 #   endif
1104 #   ifdef DGUX
1105 #       define OS_TYPE "DGUX"
1106         extern int _etext, _end;
1107         extern ptr_t GC_SysVGetDataStart();
1108 #       define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
1109 #       define DATAEND (&_end)
1110 #       define STACK_GROWS_DOWN
1111 #       define HEURISTIC2
1112 #       include <unistd.h>
1113 #       define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
1114 #       define DYNAMIC_LOADING
1115 #       ifndef USE_MMAP
1116 #         define USE_MMAP
1117 #       endif /* USE_MMAP */
1118 #       define MAP_FAILED (void *) -1
1119 #       ifdef USE_MMAP
1120 #         define HEAP_START (ptr_t)0x40000000
1121 #       else /* USE_MMAP */
1122 #         define HEAP_START DATAEND
1123 #       endif /* USE_MMAP */
1124 #   endif /* DGUX */
1125
1126 #   ifdef LINUX
1127 #       ifndef __GNUC__
1128           /* The Intel compiler doesn't like inline assembly */
1129 #         define USE_GENERIC_PUSH_REGS
1130 #       endif
1131 #       define OS_TYPE "LINUX"
1132 #       define LINUX_STACKBOTTOM
1133 #       if 0
1134 #         define HEURISTIC1
1135 #         undef STACK_GRAN
1136 #         define STACK_GRAN 0x10000000
1137           /* STACKBOTTOM is usually 0xc0000000, but this changes with   */
1138           /* different kernel configurations.  In particular, systems   */
1139           /* with 2GB physical memory will usually move the user        */
1140           /* address space limit, and hence initial SP to 0x80000000.   */
1141 #       endif
1142 #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1143 #           define MPROTECT_VDB
1144 #       else
1145             /* We seem to get random errors in incremental mode,        */
1146             /* possibly because Linux threads is itself a malloc client */
1147             /* and can't deal with the signals.                         */
1148 #       endif
1149 #       define HEAP_START (ptr_t)0x1000
1150                 /* This encourages mmap to give us low addresses,       */
1151                 /* thus allowing the heap to grow to ~3GB               */
1152 #       ifdef __ELF__
1153 #            define DYNAMIC_LOADING
1154 #            ifdef UNDEFINED    /* includes ro data */
1155                extern int _etext[];
1156 #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1157 #            endif
1158 #            include <features.h>
1159 #            if defined(__GLIBC__) && __GLIBC__ >= 2
1160 #                define SEARCH_FOR_DATA_START
1161 #            else
1162                  extern char **__environ;
1163 #                define DATASTART ((ptr_t)(&__environ))
1164                               /* hideous kludge: __environ is the first */
1165                               /* word in crt0.o, and delimits the start */
1166                               /* of the data segment, no matter which   */
1167                               /* ld options were passed through.        */
1168                               /* We could use _etext instead, but that  */
1169                               /* would include .rodata, which may       */
1170                               /* contain large read-only data tables    */
1171                               /* that we'd rather not scan.             */
1172 #            endif
1173              extern int _end[];
1174 #            define DATAEND (_end)
1175 #       else
1176              extern int etext[];
1177 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1178 #       endif
1179 #       ifdef USE_I686_PREFETCH
1180           /* FIXME: Thus should use __builtin_prefetch, but we'll leave that    */
1181           /* for the next rtelease.                                             */
1182 #         define PREFETCH(x) \
1183             __asm__ __volatile__ ("     prefetchnta     %0": : "m"(*(char *)(x)))
1184             /* Empirically prefetcht0 is much more effective at reducing        */
1185             /* cache miss stalls for the targetted load instructions.  But it   */
1186             /* seems to interfere enough with other cache traffic that the net  */
1187             /* result is worse than prefetchnta.                                */
1188 #         if 0 
1189             /* Using prefetches for write seems to have a slight negative       */
1190             /* impact on performance, at least for a PIII/500.                  */
1191 #           define PREFETCH_FOR_WRITE(x) \
1192               __asm__ __volatile__ ("   prefetcht0      %0": : "m"(*(char *)(x)))
1193 #         endif
1194 #       endif
1195 #       ifdef USE_3DNOW_PREFETCH
1196 #         define PREFETCH(x) \
1197             __asm__ __volatile__ ("     prefetch        %0": : "m"(*(char *)(x)))
1198 #         define PREFETCH_FOR_WRITE(x) \
1199             __asm__ __volatile__ ("     prefetchw       %0": : "m"(*(char *)(x)))
1200 #       endif
1201 #   endif
1202 #   ifdef CYGWIN32
1203 #       define OS_TYPE "CYGWIN32"
1204 #       define DATASTART ((ptr_t)GC_DATASTART)  /* From gc.h */
1205 #       define DATAEND   ((ptr_t)GC_DATAEND)
1206 #       undef STACK_GRAN
1207 #       define STACK_GRAN 0x10000
1208 #       define HEURISTIC1
1209 #   endif
1210 #   ifdef OS2
1211 #       define OS_TYPE "OS2"
1212                 /* STACKBOTTOM and DATASTART are handled specially in   */
1213                 /* os_dep.c. OS2 actually has the right                 */
1214                 /* system call!                                         */
1215 #       define DATAEND  /* not needed */
1216 #       define USE_GENERIC_PUSH_REGS
1217 #   endif
1218 #   ifdef MSWIN32
1219 #       define OS_TYPE "MSWIN32"
1220                 /* STACKBOTTOM and DATASTART are handled specially in   */
1221                 /* os_dep.c.                                            */
1222 #       ifndef __WATCOMC__
1223 #         define MPROTECT_VDB
1224 #       endif
1225 #       define DATAEND  /* not needed */
1226 #   endif
1227 #   ifdef MSWINCE
1228 #       define OS_TYPE "MSWINCE"
1229 #       define DATAEND  /* not needed */
1230 #   endif
1231 #   ifdef DJGPP
1232 #       define OS_TYPE "DJGPP"
1233 #       include "stubinfo.h"
1234         extern int etext[];
1235         extern int _stklen;
1236         extern int __djgpp_stack_limit;
1237 #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1ff) & ~0x1ff))
1238 /* #       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
1239                                                      + _stklen)) */
1240 #       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
1241                 /* This may not be right.  */
1242 #   endif
1243 #   ifdef OPENBSD
1244 #       define OS_TYPE "OPENBSD"
1245 #   endif
1246 #   ifdef FREEBSD
1247 #       define OS_TYPE "FREEBSD"
1248 #       ifndef GC_FREEBSD_THREADS
1249 #           define MPROTECT_VDB
1250 #       endif
1251 #       ifdef __GLIBC__
1252 #           define SIG_SUSPEND          (32+6)
1253 #           define SIG_THR_RESTART      (32+5)
1254             extern int _end[];
1255 #           define DATAEND (_end)
1256 #       else
1257 #           define SIG_SUSPEND SIGUSR1
1258 #           define SIG_THR_RESTART SIGUSR2
1259 #       endif
1260 #       define FREEBSD_STACKBOTTOM
1261 #       ifdef __ELF__
1262 #           define DYNAMIC_LOADING
1263 #       endif
1264         extern char etext[];
1265         extern char * GC_FreeBSDGetDataStart();
1266 #       define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
1267 #   endif
1268 #   ifdef NETBSD
1269 #       define OS_TYPE "NETBSD"
1270 #       ifdef __ELF__
1271 #           define DYNAMIC_LOADING
1272 #       endif
1273 #   endif
1274 #   ifdef THREE86BSD
1275 #       define OS_TYPE "THREE86BSD"
1276 #   endif
1277 #   ifdef BSDI
1278 #       define OS_TYPE "BSDI"
1279 #   endif
1280 #   if defined(OPENBSD) || defined(NETBSD) \
1281         || defined(THREE86BSD) || defined(BSDI)
1282 #       define HEURISTIC2
1283         extern char etext[];
1284 #       define DATASTART ((ptr_t)(etext))
1285 #   endif
1286 #   ifdef NEXT
1287 #       define OS_TYPE "NEXT"
1288 #       define DATASTART ((ptr_t) get_etext())
1289 #       define STACKBOTTOM ((ptr_t)0xc0000000)
1290 #       define DATAEND  /* not needed */
1291 #   endif
1292 #   ifdef DOS4GW
1293 #     define OS_TYPE "DOS4GW"
1294       extern long __nullarea;
1295       extern char _end;
1296       extern char *_STACKTOP;
1297       /* Depending on calling conventions Watcom C either precedes
1298          or does not precedes with undescore names of C-variables.
1299          Make sure startup code variables always have the same names.  */
1300       #pragma aux __nullarea "*";
1301       #pragma aux _end "*";
1302 #     define STACKBOTTOM ((ptr_t) _STACKTOP)
1303                          /* confused? me too. */
1304 #     define DATASTART ((ptr_t) &__nullarea)
1305 #     define DATAEND ((ptr_t) &_end)
1306 #   endif
1307 #   ifdef HURD
1308 #     define OS_TYPE "HURD"
1309 #     define STACK_GROWS_DOWN
1310 #     define HEURISTIC2
1311       extern int  __data_start[];
1312 #     define DATASTART ( (ptr_t) (__data_start))
1313       extern int   _end[];
1314 #     define DATAEND ( (ptr_t) (_end))
1315 /* #     define MPROTECT_VDB  Not quite working yet? */
1316 #     define DYNAMIC_LOADING
1317 #   endif
1318 #   ifdef DARWIN
1319 #     define OS_TYPE "DARWIN"
1320 #     define DARWIN_DONT_PARSE_STACK
1321 #     define DYNAMIC_LOADING
1322       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1323          These aren't used when dyld support is enabled (it is by default) */
1324 #     define DATASTART ((ptr_t) get_etext())
1325 #     define DATAEND    ((ptr_t) get_end())
1326 #     define STACKBOTTOM ((ptr_t) 0xc0000000)
1327 #     define USE_MMAP
1328 #     define USE_MMAP_ANON
1329 #     define USE_ASM_PUSH_REGS
1330       /* This is potentially buggy. It needs more testing. See the comments in
1331          os_dep.c.  It relies on threads to track writes. */
1332 #     ifdef GC_DARWIN_THREADS
1333 /* #       define MPROTECT_VDB -- disabled for now.  May work for some apps. */
1334 #     endif
1335 #     include <unistd.h>
1336 #     define GETPAGESIZE() getpagesize()
1337       /* There seems to be some issues with trylock hanging on darwin. This
1338          should be looked into some more */
1339 #     define NO_PTHREAD_TRYLOCK
1340 #   endif /* DARWIN */
1341 # endif
1342
1343 # ifdef NS32K
1344 #   define MACH_TYPE "NS32K"
1345 #   define ALIGNMENT 4
1346     extern char **environ;
1347 #   define DATASTART ((ptr_t)(&environ))
1348                               /* hideous kludge: environ is the first   */
1349                               /* word in crt0.o, and delimits the start */
1350                               /* of the data segment, no matter which   */
1351                               /* ld options were passed through.        */
1352 #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1353 # endif
1354
1355 # ifdef MIPS
1356 #   define MACH_TYPE "MIPS"
1357 #   ifdef LINUX
1358       /* This was developed for a linuxce style platform.  Probably     */
1359       /* needs to be tweaked for workstation class machines.            */
1360 #     define OS_TYPE "LINUX"
1361 #     define DYNAMIC_LOADING
1362       extern int _end[];
1363 #     define DATAEND (_end)
1364       extern int __data_start[];
1365 #     define DATASTART ((ptr_t)(__data_start))
1366 #     define ALIGNMENT 4
1367 #     define USE_GENERIC_PUSH_REGS
1368 #     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1369 #        define LINUX_STACKBOTTOM
1370 #     else
1371 #        define STACKBOTTOM 0x80000000
1372 #     endif
1373 #   endif /* Linux */
1374 #   ifdef EWS4800
1375 #      define HEURISTIC2
1376 #      if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64)
1377          extern int _fdata[], _end[];
1378 #        define DATASTART ((ptr_t)_fdata)
1379 #        define DATAEND ((ptr_t)_end)
1380 #        define CPP_WORDSZ _MIPS_SZPTR
1381 #        define ALIGNMENT (_MIPS_SZPTR/8)
1382 #      else
1383          extern int etext[], edata[], end[];
1384          extern int _DYNAMIC_LINKING[], _gp[];
1385 #        define DATASTART ((ptr_t)((((word)etext + 0x3ffff) & ~0x3ffff) \
1386                + ((word)etext & 0xffff)))
1387 #        define DATAEND (edata)
1388 #        define DATASTART2 (_DYNAMIC_LINKING \
1389                ? (ptr_t)(((word)_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \
1390                : (ptr_t)edata)
1391 #        define DATAEND2 (end)
1392 #        define ALIGNMENT 4
1393 #      endif
1394 #      define OS_TYPE "EWS4800"
1395 #      define USE_GENERIC_PUSH_REGS 1
1396 #   endif
1397 #   ifdef ULTRIX
1398 #       define HEURISTIC2
1399 #       define DATASTART (ptr_t)0x10000000
1400                               /* Could probably be slightly higher since */
1401                               /* startup code allocates lots of stuff.   */
1402 #       define OS_TYPE "ULTRIX"
1403 #       define ALIGNMENT 4
1404 #   endif
1405 #   ifdef RISCOS
1406 #       define HEURISTIC2
1407 #       define DATASTART (ptr_t)0x10000000
1408 #       define OS_TYPE "RISCOS"
1409 #       define ALIGNMENT 4  /* Required by hardware */
1410 #   endif
1411 #   ifdef IRIX5
1412 #       define HEURISTIC2
1413         extern int _fdata[];
1414 #       define DATASTART ((ptr_t)(_fdata))
1415 #       ifdef USE_MMAP
1416 #         define HEAP_START (ptr_t)0x30000000
1417 #       else
1418 #         define HEAP_START DATASTART
1419 #       endif
1420                               /* Lowest plausible heap address.         */
1421                               /* In the MMAP case, we map there.        */
1422                               /* In either case it is used to identify  */
1423                               /* heap sections so they're not           */
1424                               /* considered as roots.                   */
1425 #       define OS_TYPE "IRIX5"
1426 /*#       define MPROTECT_VDB DOB: this should work, but there is evidence */
1427 /*              of recent breakage.                                        */
1428 #       ifdef _MIPS_SZPTR
1429 #         define CPP_WORDSZ _MIPS_SZPTR
1430 #         define ALIGNMENT (_MIPS_SZPTR/8)
1431 #         if CPP_WORDSZ != 64
1432 #           define ALIGN_DOUBLE
1433 #         endif
1434 #       else
1435 #         define ALIGNMENT 4
1436 #         define ALIGN_DOUBLE
1437 #       endif
1438 #       define DYNAMIC_LOADING
1439 #   endif
1440 #   ifdef MSWINCE
1441 #       define OS_TYPE "MSWINCE"
1442 #       define ALIGNMENT 4
1443 #       define DATAEND /* not needed */
1444 #   endif
1445 #   if defined(NETBSD)
1446 #     define ALIGNMENT 4
1447 #     define OS_TYPE "NETBSD"
1448 #     define HEURISTIC2
1449 #     define USE_GENERIC_PUSH_REGS
1450 #     ifdef __ELF__
1451         extern int etext[];
1452 #       define DATASTART GC_data_start
1453 #       define NEED_FIND_LIMIT
1454 #       define DYNAMIC_LOADING
1455 #     else
1456 #       define DATASTART ((ptr_t) 0x10000000)
1457 #       define STACKBOTTOM ((ptr_t) 0x7ffff000)
1458 #     endif /* _ELF_ */
1459 #  endif
1460 # endif
1461
1462 # ifdef RS6000
1463 #   define MACH_TYPE "RS6000"
1464 #   ifdef ALIGNMENT
1465 #     undef ALIGNMENT
1466 #   endif
1467 #   ifdef IA64
1468 #     undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1469 #   endif
1470 #   ifdef __64BIT__
1471 #     define ALIGNMENT 8
1472 #     define CPP_WORDSZ 64
1473 #     define STACKBOTTOM ((ptr_t)0x1000000000000000)
1474 #   else
1475 #     define ALIGNMENT 4
1476 #     define CPP_WORDSZ 32
1477 #     define STACKBOTTOM ((ptr_t)((ulong)&errno))
1478 #   endif
1479 #   define USE_MMAP
1480 #   define USE_MMAP_ANON
1481  /* From AIX linker man page:
1482  _text Specifies the first location of the program.
1483  _etext Specifies the first location after the program.
1484  _data Specifies the first location of the data.
1485  _edata Specifies the first location after the initialized data
1486  _end or end Specifies the first location after all data.
1487  */
1488     extern int _data[], _end[];
1489 #   define DATASTART ((ptr_t)((ulong)_data))
1490 #   define DATAEND ((ptr_t)((ulong)_end))
1491     extern int errno;
1492 #   define USE_GENERIC_PUSH_REGS
1493 #   define DYNAMIC_LOADING
1494         /* For really old versions of AIX, this may have to be removed. */
1495 # endif
1496
1497 # ifdef HP_PA
1498 #   define MACH_TYPE "HP_PA"
1499 #   ifdef __LP64__
1500 #     define CPP_WORDSZ 64
1501 #     define ALIGNMENT 8
1502 #   else
1503 #     define CPP_WORDSZ 32
1504 #     define ALIGNMENT 4
1505 #     define ALIGN_DOUBLE
1506 #   endif
1507 #   if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1508 #     ifndef LINUX /* For now. */
1509 #       define MPROTECT_VDB
1510 #     endif
1511 #   else
1512 #     define GENERIC_COMPARE_AND_SWAP
1513         /* No compare-and-swap instruction.  Use pthread mutexes        */
1514         /* when we absolutely have to.                                  */
1515 #     ifdef PARALLEL_MARK
1516 #       define USE_MARK_BYTES
1517                 /* Minimize compare-and-swap usage.             */
1518 #     endif
1519 #   endif
1520 #   define STACK_GROWS_UP
1521 #   ifdef HPUX
1522 #     define OS_TYPE "HPUX"
1523       extern int __data_start[];
1524 #     define DATASTART ((ptr_t)(__data_start))
1525 #     if 0
1526         /* The following appears to work for 7xx systems running HP/UX  */
1527         /* 9.xx Furthermore, it might result in much faster             */
1528         /* collections than HEURISTIC2, which may involve scanning      */
1529         /* segments that directly precede the stack.  It is not the     */
1530         /* default, since it may not work on older machine/OS           */
1531         /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1532         /* this.)                                                       */
1533 #       define STACKBOTTOM ((ptr_t) 0x7b033000)  /* from /etc/conf/h/param.h */
1534 #     else
1535         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
1536         /* to this.  Note that the GC must be initialized before the    */
1537         /* first putenv call.                                           */
1538         extern char ** environ;
1539 #       define STACKBOTTOM ((ptr_t)environ)
1540 #     endif
1541 #     define DYNAMIC_LOADING
1542 #     include <unistd.h>
1543 #     define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1544 #     ifndef __GNUC__
1545 #       define PREFETCH(x)  { \
1546                               register long addr = (long)(x); \
1547                               (void) _asm ("LDW", 0, 0, addr, 0); \
1548                             }
1549 #     endif
1550 #   endif /* HPUX */
1551 #   ifdef LINUX
1552 #     define OS_TYPE "LINUX"
1553 #     define LINUX_STACKBOTTOM
1554 #     define DYNAMIC_LOADING
1555 #     define SEARCH_FOR_DATA_START
1556       extern int _end[];
1557 #     define DATAEND (&_end)
1558 #   endif /* LINUX */
1559 # endif /* HP_PA */
1560
1561 # ifdef ALPHA
1562 #   define MACH_TYPE "ALPHA"
1563 #   define ALIGNMENT 8
1564 #   define CPP_WORDSZ 64
1565 #   ifndef LINUX
1566 #     define USE_GENERIC_PUSH_REGS
1567       /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1568       /* fp registers in some cases when the target is a 21264.  The assembly */
1569       /* code doesn't handle that yet, and version dependencies make that a   */
1570       /* bit tricky.  Do the easy thing for now.                                    */
1571 #   endif
1572 #   ifdef NETBSD
1573 #       define OS_TYPE "NETBSD"
1574 #       define HEURISTIC2
1575 #       define DATASTART GC_data_start
1576 #       define ELFCLASS32 32
1577 #       define ELFCLASS64 64
1578 #       define ELF_CLASS ELFCLASS64
1579 #       define DYNAMIC_LOADING
1580 #   endif
1581 #   ifdef OPENBSD
1582 #       define OS_TYPE "OPENBSD"
1583 #       define HEURISTIC2
1584 #       ifdef __ELF__   /* since OpenBSD/Alpha 2.9 */
1585 #          define DATASTART GC_data_start
1586 #          define ELFCLASS32 32
1587 #          define ELFCLASS64 64
1588 #          define ELF_CLASS ELFCLASS64
1589 #       else            /* ECOFF, until OpenBSD/Alpha 2.7 */
1590 #          define DATASTART ((ptr_t) 0x140000000)
1591 #       endif
1592 #   endif
1593 #   ifdef FREEBSD
1594 #       define OS_TYPE "FREEBSD"
1595 /* MPROTECT_VDB is not yet supported at all on FreeBSD/alpha. */
1596 #       define SIG_SUSPEND SIGUSR1
1597 #       define SIG_THR_RESTART SIGUSR2
1598 #       define FREEBSD_STACKBOTTOM
1599 #       ifdef __ELF__
1600 #           define DYNAMIC_LOADING
1601 #       endif
1602 /* Handle unmapped hole alpha*-*-freebsd[45]* puts between etext and edata. */
1603         extern char etext[];
1604         extern char edata[];
1605         extern char end[];
1606 #       define NEED_FIND_LIMIT
1607 #       define DATASTART ((ptr_t)(&etext))
1608 #       define DATAEND (GC_find_limit (DATASTART, TRUE))
1609 #       define DATASTART2 ((ptr_t)(&edata))
1610 #       define DATAEND2 ((ptr_t)(&end))
1611 #   endif
1612 #   ifdef OSF1
1613 #       define OS_TYPE "OSF1"
1614 #       define DATASTART ((ptr_t) 0x140000000)
1615         extern int _end[];
1616 #       define DATAEND ((ptr_t) &_end)
1617         extern char ** environ;
1618         /* round up from the value of environ to the nearest page boundary */
1619         /* Probably breaks if putenv is called before collector            */
1620         /* initialization.                                                 */
1621 #       define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1622 /* #    define HEURISTIC2 */
1623         /* Normally HEURISTIC2 is too conervative, since                */
1624         /* the text segment immediately follows the stack.              */
1625         /* Hence we give an upper pound.                                */
1626         /* This is currently unused, since we disabled HEURISTIC2       */
1627         extern int __start[];
1628 #       define HEURISTIC2_LIMIT ((ptr_t)((word)(__start) & ~(getpagesize()-1)))
1629 #       ifndef GC_OSF1_THREADS
1630           /* Unresolved signal issues with threads.     */
1631 #         define MPROTECT_VDB
1632 #       endif
1633 #       define DYNAMIC_LOADING
1634 #   endif
1635 #   ifdef LINUX
1636 #       define OS_TYPE "LINUX"
1637 #       define LINUX_STACKBOTTOM
1638 #       ifdef __ELF__
1639 #         define SEARCH_FOR_DATA_START
1640 #         define DYNAMIC_LOADING
1641 #       else
1642 #           define DATASTART ((ptr_t) 0x140000000)
1643 #       endif
1644         extern int _end[];
1645 #       define DATAEND (_end)
1646 #       define MPROTECT_VDB
1647                 /* Has only been superficially tested.  May not */
1648                 /* work on all versions.                        */
1649 #   endif
1650 # endif
1651
1652 # ifdef IA64
1653 #   define MACH_TYPE "IA64"
1654 #   define USE_GENERIC_PUSH_REGS
1655         /* We need to get preserved registers in addition to register   */
1656         /* windows.   That's easiest to do with setjmp.                 */
1657 #   ifdef PARALLEL_MARK
1658 #       define USE_MARK_BYTES
1659             /* Compare-and-exchange is too expensive to use for         */
1660             /* setting mark bits.                                       */
1661 #   endif
1662 #   ifdef HPUX
1663 #       ifdef _ILP32
1664 #         define CPP_WORDSZ 32
1665 #         define ALIGN_DOUBLE
1666             /* Requires 8 byte alignment for malloc */
1667 #         define ALIGNMENT 4
1668 #       else
1669 #         ifndef _LP64
1670                 ---> unknown ABI
1671 #         endif
1672 #         define CPP_WORDSZ 64
1673 #         define ALIGN_DOUBLE
1674             /* Requires 16 byte alignment for malloc */
1675 #         define ALIGNMENT 8
1676 #       endif
1677 #       define OS_TYPE "HPUX"   
1678         extern int __data_start[];
1679 #       define DATASTART ((ptr_t)(__data_start))
1680         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
1681         /* to this.  Note that the GC must be initialized before the    */
1682         /* first putenv call.                                           */
1683         extern char ** environ;
1684 #       define STACKBOTTOM ((ptr_t)environ)
1685 #       define HPUX_STACKBOTTOM
1686 #       define DYNAMIC_LOADING
1687 #       include <unistd.h>
1688 #       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1689         /* The following was empirically determined, and is probably    */
1690         /* not very robust.                                             */
1691         /* Note that the backing store base seems to be at a nice       */
1692         /* address minus one page.                                      */
1693 #       define BACKING_STORE_DISPLACEMENT 0x1000000
1694 #       define BACKING_STORE_ALIGNMENT 0x1000
1695         extern ptr_t GC_register_stackbottom;
1696 #       define BACKING_STORE_BASE GC_register_stackbottom
1697         /* Known to be wrong for recent HP/UX versions!!!       */
1698 #   endif
1699 #   ifdef LINUX
1700 #       define CPP_WORDSZ 64
1701 #       define ALIGN_DOUBLE
1702           /* Requires 16 byte alignment for malloc */
1703 #       define ALIGNMENT 8
1704 #       define OS_TYPE "LINUX"
1705         /* The following works on NUE and older kernels:        */
1706 /* #       define STACKBOTTOM ((ptr_t) 0xa000000000000000l)     */
1707         /* This does not work on NUE:                           */
1708 #       define LINUX_STACKBOTTOM
1709         /* We also need the base address of the register stack  */
1710         /* backing store.  This is computed in                  */
1711         /* GC_linux_register_stack_base based on the following  */
1712         /* constants:                                           */
1713 #       define BACKING_STORE_ALIGNMENT 0x100000
1714 #       define BACKING_STORE_DISPLACEMENT 0x80000000
1715         extern ptr_t GC_register_stackbottom;
1716 #       define BACKING_STORE_BASE GC_register_stackbottom
1717 #       define SEARCH_FOR_DATA_START
1718 #       ifdef __GNUC__
1719 #         define DYNAMIC_LOADING
1720 #       else
1721           /* In the Intel compiler environment, we seem to end up with  */
1722           /* statically linked executables and an undefined reference   */
1723           /* to _DYNAMIC                                                */
1724 #       endif
1725 #       define MPROTECT_VDB
1726                 /* Requires Linux 2.3.47 or later.      */
1727         extern int _end[];
1728 #       define DATAEND (_end)
1729 #       ifdef __GNUC__
1730 #         ifndef __INTEL_COMPILER
1731 #           define PREFETCH(x) \
1732               __asm__ ("        lfetch  [%0]": : "r"(x))
1733 #           define PREFETCH_FOR_WRITE(x) \
1734               __asm__ ("        lfetch.excl     [%0]": : "r"(x))
1735 #           define CLEAR_DOUBLE(x) \
1736               __asm__ ("        stf.spill       [%0]=f0": : "r"((void *)(x)))
1737 #         else
1738 #           include <ia64intrin.h>
1739 #           define PREFETCH(x) \
1740               __lfetch(__lfhint_none, (x))
1741 #           define PREFETCH_FOR_WRITE(x) \
1742               __lfetch(__lfhint_nta,  (x))
1743 #           define CLEAR_DOUBLE(x) \
1744               __stf_spill((void *)(x), 0)
1745 #         endif // __INTEL_COMPILER
1746 #       endif
1747 #   endif
1748 #   ifdef MSWIN32
1749       /* FIXME: This is a very partial guess.  There is no port, yet.   */
1750 #     define OS_TYPE "MSWIN32"
1751                 /* STACKBOTTOM and DATASTART are handled specially in   */
1752                 /* os_dep.c.                                            */
1753 #     define DATAEND  /* not needed */
1754 #     if defined(_WIN64)
1755 #       define CPP_WORDSZ 64
1756 #     else
1757 #       define CPP_WORDSZ 32   /* Is this possible?     */
1758 #     endif
1759 #     define ALIGNMENT 8
1760 #   endif
1761 # endif
1762
1763 # ifdef M88K
1764 #   define MACH_TYPE "M88K"
1765 #   define ALIGNMENT 4
1766 #   define ALIGN_DOUBLE
1767     extern int etext[];
1768 #   ifdef CX_UX
1769 #       define OS_TYPE "CX_UX"
1770 #       define DATASTART ((((word)etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1771 #   endif
1772 #   ifdef  DGUX
1773 #       define OS_TYPE "DGUX"
1774         extern ptr_t GC_SysVGetDataStart();
1775 #       define DATASTART GC_SysVGetDataStart(0x10000, etext)
1776 #   endif
1777 #   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1778 # endif
1779
1780 # ifdef S370
1781     /* If this still works, and if anyone cares, this should probably   */
1782     /* be moved to the S390 category.                                   */
1783 #   define MACH_TYPE "S370"
1784 #   define ALIGNMENT 4  /* Required by hardware */
1785 #   define USE_GENERIC_PUSH_REGS
1786 #   ifdef UTS4
1787 #       define OS_TYPE "UTS4"
1788         extern int etext[];
1789         extern int _etext[];
1790         extern int _end[];
1791         extern ptr_t GC_SysVGetDataStart();
1792 #       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
1793 #       define DATAEND (_end)
1794 #       define HEURISTIC2
1795 #   endif
1796 # endif
1797
1798 # ifdef S390
1799 #   define MACH_TYPE "S390"
1800 #   define USE_GENERIC_PUSH_REGS
1801 #   ifndef __s390x__
1802 #     define ALIGNMENT 4
1803 #     define CPP_WORDSZ 32
1804 #   else
1805 #     define ALIGNMENT 8
1806 #     define CPP_WORDSZ 64
1807 #   endif
1808 #   ifndef HBLKSIZE
1809 #     define HBLKSIZE 4096
1810 #   endif
1811 #   ifdef LINUX
1812 #       define OS_TYPE "LINUX"
1813 #       define LINUX_STACKBOTTOM
1814 #       define DYNAMIC_LOADING
1815         extern int __data_start[];
1816 #       define DATASTART ((ptr_t)(__data_start))
1817     extern int _end[];
1818 #   define DATAEND (_end)
1819 #   define CACHE_LINE_SIZE 256
1820 #   define GETPAGESIZE() 4096
1821 #   endif
1822 # endif
1823
1824 # if defined(PJ)
1825 #   define ALIGNMENT 4
1826     extern int _etext[];
1827 #   define DATASTART ((ptr_t)(_etext))
1828 #   define HEURISTIC1
1829 # endif
1830
1831 # ifdef ARM32
1832 #   define CPP_WORDSZ 32
1833 #   define MACH_TYPE "ARM32"
1834 #   define ALIGNMENT 4
1835 #   ifdef NETBSD
1836 #       define OS_TYPE "NETBSD"
1837 #       define HEURISTIC2
1838 #       ifdef __ELF__
1839 #          define DATASTART GC_data_start
1840 #          define DYNAMIC_LOADING
1841 #       else
1842            extern char etext[];
1843 #          define DATASTART ((ptr_t)(etext))
1844 #       endif
1845 #       define USE_GENERIC_PUSH_REGS
1846 #   endif
1847 #   ifdef LINUX
1848 #       define OS_TYPE "LINUX"
1849 #       define LINUX_STACKBOTTOM
1850 #       undef STACK_GRAN
1851 #       define STACK_GRAN 0x10000000
1852 #       define USE_GENERIC_PUSH_REGS
1853 #       ifdef __ELF__
1854 #            define DYNAMIC_LOADING
1855 #            include <features.h>
1856 #            if defined(__GLIBC__) && __GLIBC__ >= 2
1857 #                define SEARCH_FOR_DATA_START
1858 #            else
1859                  extern char **__environ;
1860 #                define DATASTART ((ptr_t)(&__environ))
1861                               /* hideous kludge: __environ is the first */
1862                               /* word in crt0.o, and delimits the start */
1863                               /* of the data segment, no matter which   */
1864                               /* ld options were passed through.        */
1865                               /* We could use _etext instead, but that  */
1866                               /* would include .rodata, which may       */
1867                               /* contain large read-only data tables    */
1868                               /* that we'd rather not scan.             */
1869 #            endif
1870              extern int _end[];
1871 #            define DATAEND (_end)
1872 #       else
1873              extern int etext[];
1874 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1875 #       endif
1876 #   endif
1877 #   ifdef MSWINCE
1878 #     define OS_TYPE "MSWINCE"
1879 #     define DATAEND /* not needed */
1880 #   endif
1881 #   ifdef NOSYS
1882       /* __data_start is usually defined in the target linker script.  */
1883       extern int __data_start[];
1884 #     define DATASTART (ptr_t)(__data_start)
1885 #     define USE_GENERIC_PUSH_REGS
1886       /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S  */
1887       extern void *__stack_base__;
1888 #     define STACKBOTTOM ((ptr_t) (__stack_base__))
1889 #   endif
1890 #endif
1891
1892 # ifdef CRIS
1893 #   define MACH_TYPE "CRIS"
1894 #   define CPP_WORDSZ 32
1895 #   define ALIGNMENT 1
1896 #   define OS_TYPE "LINUX"
1897 #   define DYNAMIC_LOADING
1898 #   define LINUX_STACKBOTTOM
1899 #   define USE_GENERIC_PUSH_REGS
1900 #   define SEARCH_FOR_DATA_START
1901       extern int _end[];
1902 #   define DATAEND (_end)
1903 # endif
1904
1905 # ifdef SH
1906 #   define MACH_TYPE "SH"
1907 #   define ALIGNMENT 4
1908 #   ifdef MSWINCE
1909 #     define OS_TYPE "MSWINCE"
1910 #     define DATAEND /* not needed */
1911 #   endif
1912 #   ifdef LINUX
1913 #     define OS_TYPE "LINUX"
1914 #     define LINUX_STACKBOTTOM
1915 #     define USE_GENERIC_PUSH_REGS
1916 #     define DYNAMIC_LOADING
1917 #     define SEARCH_FOR_DATA_START
1918       extern int _end[];
1919 #     define DATAEND (_end)
1920 #   endif
1921 #   ifdef NETBSD
1922 #      define OS_TYPE "NETBSD"
1923 #      define HEURISTIC2
1924 #      define DATASTART GC_data_start
1925 #       define USE_GENERIC_PUSH_REGS
1926 #      define DYNAMIC_LOADING
1927 #   endif
1928 # endif
1929  
1930 # ifdef SH4
1931 #   define MACH_TYPE "SH4"
1932 #   define OS_TYPE "MSWINCE"
1933 #   define ALIGNMENT 4
1934 #   define DATAEND /* not needed */
1935 # endif
1936
1937 # ifdef M32R
1938 #   define CPP_WORDSZ 32
1939 #   define MACH_TYPE "M32R"
1940 #   define ALIGNMENT 4
1941 #   ifdef LINUX
1942 #     define OS_TYPE "LINUX"
1943 #     define LINUX_STACKBOTTOM
1944 #     undef STACK_GRAN
1945 #     define STACK_GRAN 0x10000000
1946 #     define USE_GENERIC_PUSH_REGS
1947 #     define DYNAMIC_LOADING
1948 #     define SEARCH_FOR_DATA_START
1949       extern int _end[];
1950 #     define DATAEND (_end)
1951 #   endif
1952 # endif
1953
1954 # ifdef X86_64
1955 #   define MACH_TYPE "X86_64"
1956 #   define ALIGNMENT 8
1957 #   define CPP_WORDSZ 64
1958 #   ifndef HBLKSIZE
1959 #     define HBLKSIZE 4096
1960 #   endif
1961 #   define CACHE_LINE_SIZE 64
1962 #   define USE_GENERIC_PUSH_REGS
1963 #   ifdef LINUX
1964 #       define OS_TYPE "LINUX"
1965 #       define LINUX_STACKBOTTOM
1966 #       if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC)
1967 #           define MPROTECT_VDB
1968 #       else
1969             /* We seem to get random errors in incremental mode,        */
1970             /* possibly because Linux threads is itself a malloc client */
1971             /* and can't deal with the signals.                         */
1972 #       endif
1973 #       ifdef __ELF__
1974 #            define DYNAMIC_LOADING
1975 #            ifdef UNDEFINED    /* includes ro data */
1976                extern int _etext[];
1977 #              define DATASTART ((ptr_t)((((word) (_etext)) + 0xfff) & ~0xfff))
1978 #            endif
1979 #            include <features.h>
1980 #            define SEARCH_FOR_DATA_START
1981              extern int _end[];
1982 #            define DATAEND (_end)
1983 #       else
1984              extern int etext[];
1985 #            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1986 #       endif
1987 #       if defined(__GNUC__) && __GNUC >= 3
1988 #           define PREFETCH(x) __builtin_prefetch((x), 0, 0)
1989 #           define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
1990 #       endif
1991 #   endif
1992 #   ifdef DARWIN
1993 #     define OS_TYPE "DARWIN"
1994 #     define DARWIN_DONT_PARSE_STACK
1995 #     define DYNAMIC_LOADING
1996       /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1997          These aren't used when dyld support is enabled (it is by default) */
1998 #     define DATASTART ((ptr_t) get_etext())
1999 #     define DATAEND    ((ptr_t) get_end())
2000 #     define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
2001 #     define USE_MMAP
2002 #     define USE_MMAP_ANON
2003 #     ifdef GC_DARWIN_THREADS
2004        /* This is potentially buggy. It needs more testing. See the comments in
2005           os_dep.c.  It relies on threads to track writes. */
2006 #       define MPROTECT_VDB
2007 #     endif
2008 #     include <unistd.h>
2009 #     define GETPAGESIZE() getpagesize()
2010       /* There seems to be some issues with trylock hanging on darwin. This
2011          should be looked into some more */
2012 #     define NO_PTHREAD_TRYLOCK
2013 #   endif
2014 #   ifdef FREEBSD
2015 #       define OS_TYPE "FREEBSD"
2016 #       ifndef GC_FREEBSD_THREADS
2017 #           define MPROTECT_VDB
2018 #       endif
2019 #       ifdef __GLIBC__
2020 #           define SIG_SUSPEND          (32+6)
2021 #           define SIG_THR_RESTART      (32+5)
2022             extern int _end[];
2023 #           define DATAEND (_end)
2024 #       else
2025 #           define SIG_SUSPEND SIGUSR1
2026 #           define SIG_THR_RESTART SIGUSR2
2027 #       endif
2028 #       define FREEBSD_STACKBOTTOM
2029 #       ifdef __ELF__
2030 #           define DYNAMIC_LOADING
2031 #       endif
2032         extern char etext[];
2033         extern char * GC_FreeBSDGetDataStart();
2034 #       define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
2035 #   endif
2036 #   ifdef NETBSD
2037 #       define OS_TYPE "NETBSD"
2038 #       ifdef __ELF__
2039 #           define DYNAMIC_LOADING
2040 #       endif
2041 #       define HEURISTIC2
2042         extern char etext[];
2043 #       define SEARCH_FOR_DATA_START
2044 #   endif
2045 # endif
2046
2047 #if defined(LINUX) && defined(USE_MMAP)
2048     /* The kernel may do a somewhat better job merging mappings etc.    */
2049     /* with anonymous mappings.                                         */
2050 #   define USE_MMAP_ANON
2051 #endif
2052
2053 #if defined(LINUX) && defined(REDIRECT_MALLOC)
2054     /* Rld appears to allocate some memory with its own allocator, and  */
2055     /* some through malloc, which might be redirected.  To make this    */
2056     /* work with collectable memory, we have to scan memory allocated   */
2057     /* by rld's internal malloc.                                        */
2058 #   define USE_PROC_FOR_LIBRARIES
2059 #endif
2060     
2061 # ifndef STACK_GROWS_UP
2062 #   define STACK_GROWS_DOWN
2063 # endif
2064
2065 # ifndef CPP_WORDSZ
2066 #   define CPP_WORDSZ 32
2067 # endif
2068
2069 # ifndef OS_TYPE
2070 #   define OS_TYPE ""
2071 # endif
2072
2073 # ifndef DATAEND
2074     extern int end[];
2075 #   define DATAEND (end)
2076 # endif
2077
2078 # if defined(SVR4) && !defined(GETPAGESIZE)
2079 #    include <unistd.h>
2080 #    define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
2081 # endif
2082
2083 # ifndef GETPAGESIZE
2084 #   if defined(SUNOS5) || defined(IRIX5)
2085 #       include <unistd.h>
2086 #   endif
2087 #   define GETPAGESIZE() getpagesize()
2088 # endif
2089
2090 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2091             /* OS has SVR4 generic features.  Probably others also qualify.     */
2092 #   define SVR4
2093 # endif
2094
2095 # if defined(SUNOS5) || defined(DRSNX)
2096             /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
2097             /* loader.                                                          */
2098 #   define SUNOS5DL
2099             /* OS has SUNOS5 style signal handlers.                             */
2100 #   define SUNOS5SIGS
2101 # endif
2102
2103 # if defined(HPUX)
2104 #   define SUNOS5SIGS
2105 # endif
2106
2107 # if defined(FREEBSD) && ((__FreeBSD__ >= 4) || (__FreeBSD_kernel__ >= 4))
2108 #   define SUNOS5SIGS
2109 # endif
2110
2111 # if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2112             || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2113             || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2114             || defined(_AIX) || defined(DARWIN) || defined(OSF1)
2115 #   define UNIX_LIKE   /* Basic Unix-like system calls work.    */
2116 # endif
2117
2118 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
2119            -> bad word size
2120 # endif
2121
2122 # ifdef PCR
2123 #   undef DYNAMIC_LOADING
2124 #   undef STACKBOTTOM
2125 #   undef HEURISTIC1
2126 #   undef HEURISTIC2
2127 #   undef PROC_VDB
2128 #   undef MPROTECT_VDB
2129 #   define PCR_VDB
2130 # endif
2131
2132 # ifdef SRC_M3
2133         /* Postponed for now. */
2134 #   undef PROC_VDB
2135 #   undef MPROTECT_VDB
2136 # endif
2137
2138 # ifdef SMALL_CONFIG
2139         /* Presumably not worth the space it takes. */
2140 #   undef PROC_VDB
2141 #   undef MPROTECT_VDB
2142 # endif
2143
2144 # ifdef USE_MUNMAP
2145 #   undef MPROTECT_VDB  /* Can't deal with address space holes. */
2146 # endif
2147
2148 # ifdef PARALLEL_MARK
2149 #   undef MPROTECT_VDB  /* For now.     */
2150 # endif
2151
2152 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
2153 #   define DEFAULT_VDB
2154 # endif
2155
2156 # ifndef PREFETCH
2157 #   define PREFETCH(x)
2158 #   define NO_PREFETCH
2159 # endif
2160
2161 # ifndef PREFETCH_FOR_WRITE
2162 #   define PREFETCH_FOR_WRITE(x)
2163 #   define NO_PREFETCH_FOR_WRITE
2164 # endif
2165
2166 # ifndef CACHE_LINE_SIZE
2167 #   define CACHE_LINE_SIZE 32   /* Wild guess   */
2168 # endif
2169
2170 # if defined(LINUX) || defined(__GLIBC__)
2171 #   define REGISTER_LIBRARIES_EARLY
2172     /* We sometimes use dl_iterate_phdr, which may acquire an internal  */
2173     /* lock.  This isn't safe after the world has stopped.  So we must  */
2174     /* call GC_register_dynamic_libraries before stopping the world.    */
2175     /* For performance reasons, this may be beneficial on other         */
2176     /* platforms as well, though it should be avoided in win32.         */
2177 # endif /* LINUX */
2178
2179 # if defined(SEARCH_FOR_DATA_START)
2180     extern ptr_t GC_data_start;
2181 #   define DATASTART GC_data_start
2182 # endif
2183
2184 # ifndef CLEAR_DOUBLE
2185 #   define CLEAR_DOUBLE(x) \
2186                 ((word*)x)[0] = 0; \
2187                 ((word*)x)[1] = 0;
2188 # endif /* CLEAR_DOUBLE */
2189
2190         /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2191 # if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2192 #   define GC_SOLARIS_THREADS
2193 # endif
2194
2195 # if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2196         --> inconsistent configuration
2197 # endif
2198 # if defined(GC_LINUX_THREADS) && !defined(LINUX)
2199         --> inconsistent configuration
2200 # endif
2201 # if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
2202         --> inconsistent configuration
2203 # endif
2204 # if defined(GC_HPUX_THREADS) && !defined(HPUX)
2205         --> inconsistent configuration
2206 # endif
2207 # if defined(GC_AIX_THREADS) && !defined(_AIX)
2208         --> inconsistent configuration
2209 # endif
2210 # if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2211         --> inconsistent configuration
2212 # endif
2213
2214 # if defined(PCR) || defined(SRC_M3) || \
2215                 defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2216                 defined(GC_PTHREADS)
2217 #   define THREADS
2218 # endif
2219
2220 # if defined(HP_PA) || defined(M88K) \
2221              || defined(POWERPC) && !defined(DARWIN) \
2222              || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2223              || (defined(I386) && defined(__LCC__))
2224         /* Use setjmp based hack to mark from callee-save registers.    */
2225         /* The define should move to the individual platform            */
2226         /* descriptions.                                                */
2227 #       define USE_GENERIC_PUSH_REGS
2228 # endif
2229
2230 # if defined(MSWINCE)
2231 #   define NO_GETENV
2232 # endif
2233
2234 # if defined(SPARC)
2235 #   define ASM_CLEAR_CODE       /* Stack clearing is crucial, and we    */
2236                                 /* include assembly code to do it well. */
2237 # endif
2238
2239   /* Can we save call chain in objects for debugging?                   */
2240   /* SET NFRAMES (# of saved frames) and NARGS (#of args for each       */
2241   /* frame) to reasonable values for the platform.                      */
2242   /* Set SAVE_CALL_CHAIN if we can.  SAVE_CALL_COUNT can be specified   */
2243   /* at build time, though we feel free to adjust it slightly.          */
2244   /* Define NEED_CALLINFO if we either save the call stack or           */
2245   /* GC_ADD_CALLER is defined.                                          */
2246   /* GC_CAN_SAVE_CALL_STACKS is set in gc.h.                            */
2247
2248 #if defined(SPARC)
2249 # define CAN_SAVE_CALL_ARGS
2250 #endif
2251 #if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
2252             /* SAVE_CALL_CHAIN is supported if the code is compiled to save     */
2253             /* frame pointers by default, i.e. no -fomit-frame-pointer flag.    */
2254 # define CAN_SAVE_CALL_ARGS
2255 #endif
2256
2257 # if defined(SAVE_CALL_COUNT) && !defined(GC_ADD_CALLER) \
2258              && defined(GC_CAN_SAVE_CALL_STACKS)
2259 #   define SAVE_CALL_CHAIN 
2260 # endif
2261 # ifdef SAVE_CALL_CHAIN
2262 #   if defined(SAVE_CALL_NARGS) && defined(CAN_SAVE_CALL_ARGS)
2263 #     define NARGS SAVE_CALL_NARGS
2264 #   else
2265 #     define NARGS 0    /* Number of arguments to save for each call.   */
2266 #   endif
2267 # endif
2268 # ifdef SAVE_CALL_CHAIN
2269 #   ifndef SAVE_CALL_COUNT
2270 #     define NFRAMES 6  /* Number of frames to save. Even for           */
2271                                 /* alignment reasons.                           */
2272 #   else
2273 #     define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2274 #   endif
2275 #   define NEED_CALLINFO
2276 # endif /* SAVE_CALL_CHAIN */
2277 # ifdef GC_ADD_CALLER
2278 #   define NFRAMES 1
2279 #   define NARGS 0
2280 #   define NEED_CALLINFO
2281 # endif
2282
2283 # if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL)
2284 #   define DBG_HDRS_ALL
2285 # endif
2286
2287 # if defined(POINTER_MASK) && !defined(POINTER_SHIFT)
2288 #   define POINTER_SHIFT 0
2289 # endif
2290
2291 # if defined(POINTER_SHIFT) && !defined(POINTER_MASK)
2292 #   define POINTER_MASK ((GC_word)(-1))
2293 # endif
2294
2295 # if !defined(FIXUP_POINTER) && defined(POINTER_MASK)
2296 #   define FIXUP_POINTER(p) (p) = ((p) & (POINTER_MASK) << POINTER_SHIFT)
2297 # endif
2298
2299 # if defined(FIXUP_POINTER)
2300 #   define NEED_FIXUP_POINTER 1
2301 # else
2302 #   define NEED_FIXUP_POINTER 0
2303 #   define FIXUP_POINTER(p)
2304 # endif
2305
2306 #ifdef GC_PRIVATE_H
2307         /* This relies on some type definitions from gc_priv.h, from    */
2308         /* where it's normally included.                                */
2309         /*                                                              */
2310         /* How to get heap memory from the OS:                          */
2311         /* Note that sbrk()-like allocation is preferred, since it      */
2312         /* usually makes it possible to merge consecutively allocated   */
2313         /* chunks.  It also avoids unintented recursion with            */
2314         /* -DREDIRECT_MALLOC.                                           */
2315         /* GET_MEM() returns a HLKSIZE aligned chunk.                   */
2316         /* 0 is taken to mean failure.                                  */
2317         /* In the case os USE_MMAP, the argument must also be a         */
2318         /* physical page size.                                          */
2319         /* GET_MEM is currently not assumed to retrieve 0 filled space, */
2320         /* though we should perhaps take advantage of the case in which */
2321         /* does.                                                        */
2322         struct hblk;    /* See gc_priv.h.       */
2323 # ifdef PCR
2324             char * real_malloc();
2325 #   define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2326                                           + GC_page_size-1)
2327 # else
2328 #   ifdef OS2
2329               void * os2_alloc(size_t bytes);
2330 #     define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2331                                             + GC_page_size) \
2332                                             + GC_page_size-1)
2333 #   else
2334 #     if defined(NEXT) || defined(DOS4GW) || \
2335                  (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2336                  (defined(SUNOS5) && !defined(USE_MMAP))
2337 #       define GET_MEM(bytes) HBLKPTR((size_t) \
2338                                               calloc(1, (size_t)bytes + GC_page_size) \
2339                                               + GC_page_size-1)
2340 #     else
2341 #       ifdef MSWIN32
2342           extern ptr_t GC_win32_get_mem();
2343 #         define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2344 #       else
2345 #         ifdef MACOS
2346 #           if defined(USE_TEMPORARY_MEMORY)
2347                         extern Ptr GC_MacTemporaryNewPtr(size_t size,
2348                                                          Boolean clearMemory);
2349 #               define GET_MEM(bytes) HBLKPTR( \
2350                             GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2351                             + GC_page_size-1)
2352 #           else
2353 #                   define GET_MEM(bytes) HBLKPTR( \
2354                                 NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2355 #           endif
2356 #         else
2357 #           ifdef MSWINCE
2358               extern ptr_t GC_wince_get_mem();
2359 #             define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2360 #           else
2361 #             if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2362                         extern void *GC_amiga_get_mem(size_t size);
2363 #               define GET_MEM(bytes) HBLKPTR((size_t) \
2364                           GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2365                           + GC_page_size-1)
2366 #             else
2367                 extern ptr_t GC_unix_get_mem();
2368 #               define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2369 #             endif
2370 #           endif
2371 #         endif
2372 #       endif
2373 #     endif
2374 #   endif
2375 # endif
2376
2377 #endif /* GC_PRIVATE_H */
2378
2379 #if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2380   /* IBMs xlc compiler doesn't appear to follow the convention of       */
2381   /* defining  __STDC__ to be zero in extended mode.                    */
2382 #   define __STDC__ 0
2383 #endif
2384
2385 # endif /* GCCONFIG_H */