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