comparison gc/include/private/gcconfig.h @ 51488:5de98dce4bd1

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