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