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