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