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