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