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