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