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