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