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