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