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