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