OSDN Git Service

* alpha_mach_dep.s: Mark call-saved FP registers.
[pf3gnuchains/gcc-fork.git] / boehm-gc / include / private / gcconfig.h
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.
5  * Copyright (c) 2000 by Hewlett-Packard Company.  All rights reserved.
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  
17 #ifndef GCCONFIG_H
18
19 # define GCCONFIG_H
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
31 /* And one for NetBSD: */
32 # if defined(__NetBSD__)
33 #    define NETBSD
34 # endif
35
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
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
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
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
94 #    endif
95 #    define mach_type_known
96 # endif
97 # if defined(sequent) && (defined(i386) || defined(__i386__))
98 #    define I386
99 #    define SEQUENT
100 #    define mach_type_known
101 # endif
102 # if defined(sun) && (defined(i386) || defined(__i386__))
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) \
128      && !defined(__OpenBSD__) && !(__NetBSD__)
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
137 # if defined(__NetBSD__) && defined(__sparc__)
138 #   define SPARC
139 #   define mach_type_known
140 # endif
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
156 # if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
157      || defined(hppa) || defined(__hppa__)
158 #   define HP_PA
159 #   ifndef LINUX
160 #     define HPUX
161 #   endif
162 #   define mach_type_known
163 # endif
164 # if defined(__BEOS__) && defined(_X86_)
165 #    define I386
166 #    define BEOS
167 #    define mach_type_known
168 # endif
169 # if defined(LINUX) && (defined(i386) || defined(__i386__))
170 #    define I386
171 #    define mach_type_known
172 # endif
173 # if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
174 #    define IA64
175 #    define mach_type_known
176 # endif
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
185 # if defined(LINUX) && (defined(sparc) || defined(__sparc__))
186 #    define SPARC
187 #    define mach_type_known
188 # endif
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
197 # if defined(__alpha) || defined(__alpha__)
198 #   define ALPHA
199 #   if !defined(LINUX) && !defined(NETBSD)
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
221 # if defined(macosx) || \
222      defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
223 #    define MACOSX
224 #    define POWERPC
225 #    define mach_type_known
226 # endif
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
232 # if defined(NeXT) && defined(mc68000)
233 #   define M68K
234 #   define NEXT
235 #   define mach_type_known
236 # endif
237 # if defined(NeXT) && (defined(i386) || defined(__i386__))
238 #   define I386
239 #   define NEXT
240 #   define mach_type_known
241 # endif
242 # if defined(__OpenBSD__) && (defined(i386) || defined(__i386__))
243 #   define I386
244 #   define OPENBSD
245 #   define mach_type_known
246 # endif
247 # if defined(__FreeBSD__) && (defined(i386) || defined(__i386__))
248 #   define I386
249 #   define FREEBSD
250 #   define mach_type_known
251 # endif
252 # if defined(__NetBSD__) && (defined(i386) || defined(__i386__))
253 #   define I386
254 #   define mach_type_known
255 # endif
256 # if defined(bsdi) && (defined(i386) || defined(__i386__))
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
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
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
309 # if defined(__MINGW32__)
310 #   define I386
311 #   define MSWIN32
312 #   define mach_type_known
313 # endif
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
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
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
349 # if defined(__s390__) && defined(LINUX)
350 #    define S370
351 #    define mach_type_known
352 # endif
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     */
381                     /*                            HP/UX, LINUX                  */
382                     /*             SPARC      ==> SPARC v7/v8/v9        */
383                     /*                  (SUNOS4, SUNOS5, LINUX,         */
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             */
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)               */
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  *
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  *
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.
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.
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
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))
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.             */
537 #            endif /* !GLIBC2 */
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
624 #     define DYNAMIC_LOADING
625 #     undef STACK_GRAN
626 #     define STACK_GRAN 0x10000000
627         /* Stack usually starts at 0x80000000 */
628 #     define LINUX_DATA_START
629       extern int _end;
630 #     define DATAEND (&_end)
631 #   endif
632 #   ifdef MACOSX
633       /* There are reasons to suspect this may not be reliable.         */
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 */
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
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"
689 #   if defined(__arch64__) || defined(__sparcv9)
690 #     define ALIGNMENT 8
691 #   else
692 #     define ALIGNMENT 4        /* Required by hardware */
693 #   endif
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
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 #         define HEURISTIC2
722 #       endif
723 #       include <unistd.h>
724 #       define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
725                 /* getpagesize() appeared to be missing from at least one */
726                 /* Solaris 5.4 installation.  Weird.                      */
727 #       define DYNAMIC_LOADING
728 #   endif
729 #   ifdef SUNOS4
730 #       define OS_TYPE "SUNOS4"
731         /* [If you have a weak stomach, don't read this.]               */
732         /* We would like to use:                                        */
733 /* #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
734         /* This fails occasionally, due to an ancient, but very         */
735         /* persistent ld bug.  &etext is set 32 bytes too high.         */
736         /* We instead read the text segment size from the a.out         */
737         /* header, which happens to be mapped into our address space    */
738         /* at the start of the text segment.  The detective work here   */
739         /* was done by Robert Ehrlich, Manuel Serrano, and Bernard      */
740         /* Serpette of INRIA.                                           */
741         /* This assumes ZMAGIC, i.e. demand-loadable executables.       */
742 #       define TEXTSTART 0x2000
743 #       define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
744 #       define MPROTECT_VDB
745 #       define HEURISTIC1
746 #       define DYNAMIC_LOADING
747 #   endif
748 #   ifdef DRSNX
749 #       define CPP_WORDSZ 32
750 #       define OS_TYPE "DRSNX"
751         extern char * GC_SysVGetDataStart();
752         extern int etext;
753 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
754 #       define MPROTECT_VDB
755 #       define STACKBOTTOM ((ptr_t) 0xdfff0000)
756 #       define DYNAMIC_LOADING
757 #   endif
758 #   ifdef LINUX
759 #     define OS_TYPE "LINUX"
760 #     ifdef __ELF__
761 #       define DYNAMIC_LOADING
762 #     else
763           Linux Sparc/a.out not supported
764 #     endif
765       extern int _end;
766       extern int _etext;
767 #     define DATAEND (&_end)
768 #     define SVR4
769 #     ifdef __arch64__
770 #       define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
771 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
772 #       define CPP_WORDSZ 64
773 #     else
774 #       define STACKBOTTOM ((ptr_t) 0xf0000000)
775 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
776 #     endif
777 #   endif
778 #   ifdef OPENBSD
779 #     define OS_TYPE "OPENBSD"
780 #     define STACKBOTTOM ((ptr_t) 0xf8000000)
781       extern int etext;
782 #     define DATASTART ((ptr_t)(&etext))
783 #   endif
784 #   ifdef NETBSD
785 #     define OS_TYPE "NETBSD"
786 #     define HEURISTIC2
787 #     ifdef __ELF__
788 #       define DATASTART GC_data_start
789 #       define DYNAMIC_LOADING
790 #     else
791         extern char etext;
792 #       define DATASTART ((ptr_t)(&etext))
793 #     endif
794 #   endif
795 # endif
796
797 # ifdef I386
798 #   define MACH_TYPE "I386"
799 #   define ALIGNMENT 4  /* Appears to hold for all "32 bit" compilers   */
800                         /* except Borland.  The -a4 option fixes        */
801                         /* Borland.                                     */
802                         /* Ivan Demakov: For Watcom the option is -zp4. */
803 #   ifndef SMALL_CONFIG
804 #     define ALIGN_DOUBLE /* Not strictly necessary, but may give speed   */
805                           /* improvement on Pentiums.                     */
806 #   endif
807 #   ifdef SEQUENT
808 #       define OS_TYPE "SEQUENT"
809         extern int etext;
810 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
811 #       define STACKBOTTOM ((ptr_t) 0x3ffff000) 
812 #   endif
813 #   ifdef BEOS
814 #     define OS_TYPE "BEOS"
815 #     include <OS.h>
816 #     define GETPAGESIZE() B_PAGE_SIZE
817       extern int etext;
818 #     define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
819 #   endif
820 #   ifdef SUNOS5
821 #       define OS_TYPE "SUNOS5"
822         extern int etext, _start;
823         extern char * GC_SysVGetDataStart();
824 #       define DATASTART GC_SysVGetDataStart(0x1000, &etext)
825 /*      # define STACKBOTTOM ((ptr_t)(&_start)) worked through 2.7,     */
826 /*      but reportedly breaks under 2.8.  It appears that the stack     */
827 /*      base is a property of the executable, so this should not break  */
828 /*      old executables.                                                */
829 /*      HEURISTIC2 probably works, but this appears to be preferable.   */
830 #       include <sys/vmparam.h>
831 #       define STACKBOTTOM USRSTACK
832 /** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
833 /*#     define PROC_VDB*/
834 #       define DYNAMIC_LOADING
835 #       ifndef USE_MMAP
836 #           define USE_MMAP
837 #       endif
838 #       ifdef USE_MMAP
839 #         define HEAP_START (ptr_t)0x40000000
840 #       else
841 #         define HEAP_START DATAEND
842 #       endif
843 #   endif
844 #   ifdef SCO
845 #       define OS_TYPE "SCO"
846         extern int etext;
847 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
848                                   & ~0x3fffff) \
849                                  +((word)&etext & 0xfff))
850 #       define STACKBOTTOM ((ptr_t) 0x7ffffffc)
851 #   endif
852 #   ifdef SCO_ELF
853 #       define OS_TYPE "SCO_ELF"
854         extern int etext;
855 #       define DATASTART ((ptr_t)(&etext))
856 #       define STACKBOTTOM ((ptr_t) 0x08048000)
857 #       define DYNAMIC_LOADING
858 #       define ELF_CLASS ELFCLASS32
859 #   endif
860 #   ifdef LINUX
861 #       define OS_TYPE "LINUX"
862 #       define LINUX_STACKBOTTOM
863 #       if 0
864 #         define HEURISTIC1
865 #         undef STACK_GRAN
866 #         define STACK_GRAN 0x10000000
867           /* STACKBOTTOM is usually 0xc0000000, but this changes with   */
868           /* different kernel configurations.  In particular, systems   */
869           /* with 2GB physical memory will usually move the user        */
870           /* address space limit, and hence initial SP to 0x80000000.   */
871 #       endif
872 #       if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC)
873 #           define MPROTECT_VDB
874 #       else
875             /* We seem to get random errors in incremental mode,        */
876             /* possibly because Linux threads is itself a malloc client */
877             /* and can't deal with the signals.                         */
878 #       endif
879 #       ifdef __ELF__
880 #            define DYNAMIC_LOADING
881 #            ifdef UNDEFINED    /* includes ro data */
882                extern int _etext;
883 #              define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
884 #            endif
885 #            include <features.h>
886 #            if defined(__GLIBC__) && __GLIBC__ >= 2
887 #                define LINUX_DATA_START
888 #            else
889                  extern char **__environ;
890 #                define DATASTART ((ptr_t)(&__environ))
891                               /* hideous kludge: __environ is the first */
892                               /* word in crt0.o, and delimits the start */
893                               /* of the data segment, no matter which   */
894                               /* ld options were passed through.        */
895                               /* We could use _etext instead, but that  */
896                               /* would include .rodata, which may       */
897                               /* contain large read-only data tables    */
898                               /* that we'd rather not scan.             */
899 #            endif
900              extern int _end;
901 #            define DATAEND (&_end)
902 #       else
903              extern int etext;
904 #            define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
905 #       endif
906 #       ifdef USE_I686_PREFETCH
907 #         define PREFETCH(x) \
908             __asm__ __volatile__ ("     prefetchnta     %0": : "m"(*(char *)(x)))
909             /* Empirically prefetcht0 is much more effective at reducing        */
910             /* cache miss stalls for the targetted load instructions.  But it   */
911             /* seems to interfere enough with other cache traffic that the net  */
912             /* result is worse than prefetchnta.                                */
913 #         if 0 
914             /* Using prefetches for write seems to have a slight negative       */
915             /* impact on performance, at least for a PIII/500.                  */
916 #           define PREFETCH_FOR_WRITE(x) \
917               __asm__ __volatile__ ("   prefetcht0      %0": : "m"(*(char *)(x)))
918 #         endif
919 #       endif
920 #       ifdef USE_3DNOW_PREFETCH
921 #         define PREFETCH(x) \
922             __asm__ __volatile__ ("     prefetch        %0": : "m"(*(char *)(x)))
923 #         define PREFETCH_FOR_WRITE(x) \
924             __asm__ __volatile__ ("     prefetchw       %0": : "m"(*(char *)(x)))
925 #       endif
926 #   endif
927 #   ifdef CYGWIN32
928 #       define OS_TYPE "CYGWIN32"
929           extern int _data_start__;
930           extern int _data_end__;
931           extern int _bss_start__;
932           extern int _bss_end__;
933         /* For binutils 2.9.1, we have                  */
934         /*      DATASTART   = _data_start__             */
935         /*      DATAEND     = _bss_end__                */
936         /* whereas for some earlier versions it was     */
937         /*      DATASTART   = _bss_start__              */
938         /*      DATAEND     = _data_end__               */
939         /* To get it right for both, we take the        */
940         /* minumum/maximum of the two.                  */
941 #       define MAX(x,y) ((x) > (y) ? (x) : (y))
942 #       define MIN(x,y) ((x) < (y) ? (x) : (y))
943 #       define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
944 #       define DATAEND   ((ptr_t) MAX(&_data_end__, &_bss_end__))
945 #       undef STACK_GRAN
946 #       define STACK_GRAN 0x10000
947 #       define HEURISTIC1
948 #   endif
949 #   ifdef OS2
950 #       define OS_TYPE "OS2"
951                 /* STACKBOTTOM and DATASTART are handled specially in   */
952                 /* os_dep.c. OS2 actually has the right                 */
953                 /* system call!                                         */
954 #       define DATAEND  /* not needed */
955 #       define USE_GENERIC_PUSH_REGS
956 #   endif
957 #   ifdef MSWIN32
958 #       define OS_TYPE "MSWIN32"
959                 /* STACKBOTTOM and DATASTART are handled specially in   */
960                 /* os_dep.c.                                            */
961 #       ifndef __WATCOMC__
962 #         define MPROTECT_VDB
963 #       endif
964 #       define DATAEND  /* not needed */
965 #   endif
966 #   ifdef MSWINCE
967 #       define OS_TYPE "MSWINCE"
968 #       define DATAEND  /* not needed */
969 #   endif
970 #   ifdef DJGPP
971 #       define OS_TYPE "DJGPP"
972 #       include "stubinfo.h"
973         extern int etext;
974         extern int _stklen;
975         extern int __djgpp_stack_limit;
976 #       define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
977 /* #       define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
978                                                      + _stklen)) */
979 #       define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
980                 /* This may not be right.  */
981 #   endif
982 #   ifdef OPENBSD
983 #       define OS_TYPE "OPENBSD"
984 #   endif
985 #   ifdef FREEBSD
986 #       define OS_TYPE "FREEBSD"
987 #       define MPROTECT_VDB
988 #       define FREEBSD_STACKBOTTOM
989 #   endif
990 #   ifdef NETBSD
991 #       define OS_TYPE "NETBSD"
992 #   endif
993 #   ifdef THREE86BSD
994 #       define OS_TYPE "THREE86BSD"
995 #   endif
996 #   ifdef BSDI
997 #       define OS_TYPE "BSDI"
998 #   endif
999 #   if defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1000         || defined(THREE86BSD) || defined(BSDI)
1001 #       define HEURISTIC2
1002         extern char etext;
1003 #       define DATASTART ((ptr_t)(&etext))
1004 #   endif
1005 #   ifdef NEXT
1006 #       define OS_TYPE "NEXT"
1007 #       define DATASTART ((ptr_t) get_etext())
1008 #       define STACKBOTTOM ((ptr_t)0xc0000000)
1009 #       define DATAEND  /* not needed */
1010 #   endif
1011 #   ifdef DOS4GW
1012 #     define OS_TYPE "DOS4GW"
1013       extern long __nullarea;
1014       extern char _end;
1015       extern char *_STACKTOP;
1016       /* Depending on calling conventions Watcom C either precedes
1017          or does not precedes with undescore names of C-variables.
1018          Make sure startup code variables always have the same names.  */
1019       #pragma aux __nullarea "*";
1020       #pragma aux _end "*";
1021 #     define STACKBOTTOM ((ptr_t) _STACKTOP)
1022                          /* confused? me too. */
1023 #     define DATASTART ((ptr_t) &__nullarea)
1024 #     define DATAEND ((ptr_t) &_end)
1025 #   endif
1026 # endif
1027
1028 # ifdef NS32K
1029 #   define MACH_TYPE "NS32K"
1030 #   define ALIGNMENT 4
1031     extern char **environ;
1032 #   define DATASTART ((ptr_t)(&environ))
1033                               /* hideous kludge: environ is the first   */
1034                               /* word in crt0.o, and delimits the start */
1035                               /* of the data segment, no matter which   */
1036                               /* ld options were passed through.        */
1037 #   define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
1038 # endif
1039
1040 # ifdef MIPS
1041 #   define MACH_TYPE "MIPS"
1042 /* #   define STACKBOTTOM ((ptr_t)0x7fff8000)  sometimes also works.  */
1043 #   ifdef LINUX
1044       /* This was developed for a linuxce style platform.  Probably     */
1045       /* needs to be tweaked for workstation class machines.            */
1046 #     define OS_TYPE "LINUX"
1047       extern int __data_start;
1048 #     define DATASTART ((ptr_t)(&__data_start))
1049 #     define ALIGNMENT 4
1050 #     define USE_GENERIC_PUSH_REGS 1
1051 #     define STACKBOTTOM 0x80000000
1052         /* In many cases, this should probably use LINUX_STACKBOTTOM    */
1053         /* instead. But some kernel versions seem to give the wrong     */
1054         /* value from /proc.                                            */
1055 #   endif /* Linux */
1056 #   ifdef ULTRIX
1057 #       define HEURISTIC2
1058 #       define DATASTART (ptr_t)0x10000000
1059                               /* Could probably be slightly higher since */
1060                               /* startup code allocates lots of stuff.   */
1061 #       define OS_TYPE "ULTRIX"
1062 #       define ALIGNMENT 4
1063 #   endif
1064 #   ifdef RISCOS
1065 #       define HEURISTIC2
1066 #       define DATASTART (ptr_t)0x10000000
1067 #       define OS_TYPE "RISCOS"
1068 #       define ALIGNMENT 4  /* Required by hardware */
1069 #   endif
1070 #   ifdef IRIX5
1071 #       define HEURISTIC2
1072         extern int _fdata;
1073 #       define DATASTART ((ptr_t)(&_fdata))
1074 #       ifdef USE_MMAP
1075 #         define HEAP_START (ptr_t)0x30000000
1076 #       else
1077 #         define HEAP_START DATASTART
1078 #       endif
1079                               /* Lowest plausible heap address.         */
1080                               /* In the MMAP case, we map there.        */
1081                               /* In either case it is used to identify  */
1082                               /* heap sections so they're not           */
1083                               /* considered as roots.                   */
1084 #       define OS_TYPE "IRIX5"
1085 #       define MPROTECT_VDB
1086 #       ifdef _MIPS_SZPTR
1087 #         define CPP_WORDSZ _MIPS_SZPTR
1088 #         define ALIGNMENT (_MIPS_SZPTR/8)
1089 #         if CPP_WORDSZ != 64
1090 #           define ALIGN_DOUBLE
1091 #         endif
1092 #       else
1093 #         define ALIGNMENT 4
1094 #         define ALIGN_DOUBLE
1095 #       endif
1096 #       define DYNAMIC_LOADING
1097 #   endif
1098 #   ifdef MSWINCE
1099 #       define OS_TYPE "MSWINCE"
1100 #       define ALIGNMENT 4
1101 #       define DATAEND /* not needed */
1102 #   endif
1103 #   if defined(NETBSD)
1104       /* This also checked for __MIPSEL__ .  Why?  NETBSD recognition   */
1105       /* should be handled at the top of the file.                      */
1106 #     define ALIGNMENT 4
1107 #     define OS_TYPE "NETBSD"
1108 #     define HEURISTIC2
1109 #     define USE_GENERIC_PUSH_REGS 1
1110 #     ifdef __ELF__
1111         extern int etext;
1112 #       define DATASTART GC_data_start
1113 #       define NEED_FIND_LIMIT
1114 #       define DYNAMIC_LOADING
1115 #     else
1116 #       define DATASTART ((ptr_t) 0x10000000)
1117 #       define STACKBOTTOM ((ptr_t) 0x7ffff000)
1118 #     endif /* _ELF_ */
1119 #  endif
1120 # endif
1121
1122 # ifdef RS6000
1123 #   define MACH_TYPE "RS6000"
1124 #   define ALIGNMENT 4
1125 #   define DATASTART ((ptr_t)0x20000000)
1126     extern int errno;
1127 #   define STACKBOTTOM ((ptr_t)((ulong)&errno))
1128 #   define DYNAMIC_LOADING
1129         /* For really old versions of AIX, this may have to be removed. */
1130 # endif
1131
1132 # ifdef HP_PA
1133 #   define MACH_TYPE "HP_PA"
1134 #   define OS_TYPE "HPUX"
1135 #   ifdef __LP64__
1136 #     define CPP_WORDSZ 64
1137 #     define ALIGNMENT 8
1138 #   else
1139 #     define CPP_WORDSZ 32
1140 #     define ALIGNMENT 4
1141 #     define ALIGN_DOUBLE
1142 #   endif
1143 #   if !defined(GC_HPUX_THREADS) && !defined(HPUX_THREADS) \
1144        && !defined(GC_LINUX_THREADS) && !defined(LINUX_THREADS)
1145 #     ifndef LINUX /* For now. */
1146 #       define MPROTECT_VDB
1147 #     endif
1148 #   else
1149 #     define GENERIC_COMPARE_AND_SWAP
1150         /* No compare-and-swap instruction.  Use pthread mutexes        */
1151         /* when we absolutely have to.                                  */
1152 #     ifdef PARALLEL_MARK
1153 #       define USE_MARK_BYTES
1154                 /* Minimize compare-and-swap usage.             */
1155 #     endif
1156 #   endif
1157 #   define STACK_GROWS_UP
1158 #   ifdef HPUX
1159       extern int __data_start;
1160 #     define DATASTART ((ptr_t)(&__data_start))
1161 #     if 0
1162         /* The following appears to work for 7xx systems running HP/UX  */
1163         /* 9.xx Furthermore, it might result in much faster             */
1164         /* collections than HEURISTIC2, which may involve scanning      */
1165         /* segments that directly precede the stack.  It is not the     */
1166         /* default, since it may not work on older machine/OS           */
1167         /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
1168         /* this.)                                                       */
1169 #       define STACKBOTTOM ((ptr_t) 0x7b033000)  /* from /etc/conf/h/param.h */
1170 #     else
1171         /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2       */
1172         /* to this.  Note that the GC must be initialized before the    */
1173         /* first putenv call.                                           */
1174         extern char ** environ;
1175 #       define STACKBOTTOM ((ptr_t)environ)
1176 #     endif
1177 #     define DYNAMIC_LOADING
1178 #     include <unistd.h>
1179 #     define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
1180 #     ifndef __GNUC__
1181 #       define PREFETCH(x)  { \
1182                               register long addr = (long)(x); \
1183                               (void) _asm ("LDW", 0, 0, addr, 0); \
1184                             }
1185 #     endif
1186 #   endif /* HPUX */
1187 #   ifdef LINUX
1188 #     define OS_TYPE "LINUX"
1189 #     define LINUX_STACKBOTTOM
1190 #     define DYNAMIC_LOADING
1191 #     define LINUX_DATA_START
1192       extern int _end;
1193 #     define DATAEND (&_end)
1194 #   endif /* LINUX */
1195 # endif /* HP_PA */
1196
1197 # ifdef ALPHA
1198 #   define MACH_TYPE "ALPHA"
1199 #   define ALIGNMENT 8
1200 #   ifdef NETBSD
1201 #       define OS_TYPE "NETBSD"
1202 #       define HEURISTIC2
1203 #       define DATASTART GC_data_start
1204 #       define ELFCLASS32 32
1205 #       define ELFCLASS64 64
1206 #       define ELF_CLASS ELFCLASS64
1207 #       define CPP_WORDSZ 64
1208 #       define DYNAMIC_LOADING
1209 #   endif
1210 #   ifdef OSF1
1211 #       define OS_TYPE "OSF1"
1212 #       define DATASTART ((ptr_t) 0x140000000)
1213         extern int _end;
1214 #       define DATAEND ((ptr_t) &_end)
1215         extern char ** environ;
1216         /* round up from the value of environ to the nearest page boundary */
1217         /* Probably breaks if putenv is called before collector            */
1218         /* initialization.                                                 */
1219 #       define STACKBOTTOM ((ptr_t)(((word)(environ) | (getpagesize()-1))+1))
1220 /* #    define HEURISTIC2 */
1221         /* Normally HEURISTIC2 is too conervative, since                */
1222         /* the text segment immediately follows the stack.              */
1223         /* Hence we give an upper pound.                                */
1224         /* This is currently unused, since we disabled HEURISTIC2       */
1225         extern int __start;
1226 #       define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
1227 #       define CPP_WORDSZ 64
1228 #       define MPROTECT_VDB
1229 #       define DYNAMIC_LOADING
1230 #   endif
1231 #   ifdef LINUX
1232 #       define OS_TYPE "LINUX"
1233 #       define CPP_WORDSZ 64
1234 #       define STACKBOTTOM ((ptr_t) 0x120000000)
1235 #       ifdef __ELF__
1236 #         define SEARCH_FOR_DATA_START
1237 #         define DATASTART GC_data_start
1238 #         define DYNAMIC_LOADING
1239 #       else
1240 #           define DATASTART ((ptr_t) 0x140000000)
1241 #       endif
1242         extern int _end;
1243 #       define DATAEND (&_end)
1244 #       define MPROTECT_VDB
1245                 /* Has only been superficially tested.  May not */
1246                 /* work on all versions.                        */
1247 #   endif
1248 # endif
1249
1250 # ifdef IA64
1251 #   define MACH_TYPE "IA64"
1252 #   define ALIGN_DOUBLE
1253         /* Requires 16 byte alignment for malloc */
1254 #   define ALIGNMENT 8
1255 #   define USE_GENERIC_PUSH_REGS
1256         /* We need to get preserved registers in addition to register   */
1257         /* windows.   That's easiest to do with setjmp.                 */
1258 #   ifdef PARALLEL_MARK
1259 #       define USE_MARK_BYTES
1260             /* Compare-and-exchange is too expensive to use for         */
1261             /* setting mark bits.                                       */
1262 #   endif
1263 #   ifdef HPUX
1264         --> needs work
1265 #   endif
1266 #   ifdef LINUX
1267 #       define OS_TYPE "LINUX"
1268 #       define CPP_WORDSZ 64
1269         /* The following works on NUE and older kernels:        */
1270 /* #       define STACKBOTTOM ((ptr_t) 0xa000000000000000l)     */
1271         /* This does not work on NUE:                           */
1272 #       define LINUX_STACKBOTTOM
1273         /* We also need the base address of the register stack  */
1274         /* backing store.  This is computed in                  */
1275         /* GC_linux_register_stack_base based on the following  */
1276         /* constants:                                           */
1277 #       define BACKING_STORE_ALIGNMENT 0x100000
1278 #       define BACKING_STORE_DISPLACEMENT 0x80000000
1279         extern char * GC_register_stackbottom;
1280 #       define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom)
1281 #       define SEARCH_FOR_DATA_START
1282 #       define DATASTART GC_data_start
1283 #       define DYNAMIC_LOADING
1284 #       define MPROTECT_VDB
1285                 /* Requires Linux 2.3.47 or later.      */
1286         extern int _end;
1287 #       define DATAEND (&_end)
1288 #       ifdef __GNUC__
1289 #         define PREFETCH(x) \
1290             __asm__ ("  lfetch  [%0]": : "r"((void *)(x)))
1291 #         define PREFETCH_FOR_WRITE(x) \
1292             __asm__ ("  lfetch.excl     [%0]": : "r"((void *)(x)))
1293 #         define CLEAR_DOUBLE(x) \
1294             __asm__ ("  stf.spill       [%0]=f0": : "r"((void *)(x)))
1295 #       endif
1296 #   endif
1297 # endif
1298
1299 # ifdef M88K
1300 #   define MACH_TYPE "M88K"
1301 #   define ALIGNMENT 4
1302 #   define ALIGN_DOUBLE
1303     extern int etext;
1304 #   ifdef CX_UX
1305 #       define OS_TYPE "CX_UX"
1306 #       define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
1307 #   endif
1308 #   ifdef  DGUX
1309 #       define OS_TYPE "DGUX"
1310         extern char * GC_SysVGetDataStart();
1311 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
1312 #   endif
1313 #   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1314 # endif
1315
1316 # ifdef S370
1317 #   define MACH_TYPE "S370"
1318 #   define ALIGNMENT 4  /* Required by hardware */
1319 #   define USE_GENERIC_PUSH_REGS
1320 #   ifdef UTS4
1321 #       define OS_TYPE "UTS4"
1322         extern int etext;
1323         extern int _etext;
1324         extern int _end;
1325         extern char * GC_SysVGetDataStart();
1326 #       define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
1327 #       define DATAEND (&_end)
1328 #       define HEURISTIC2
1329 #   endif
1330 #   ifdef LINUX
1331 #       define OS_TYPE "LINUX"
1332 #       define HEURISTIC1
1333 #       define DYNAMIC_LOADING
1334         extern int __data_start;
1335 #       define DATASTART ((ptr_t)(&__data_start))
1336 #   endif
1337 # endif
1338
1339 # if defined(PJ)
1340 #   define ALIGNMENT 4
1341     extern int _etext;
1342 #   define DATASTART ((ptr_t)(&_etext))
1343 #   define HEURISTIC1
1344 # endif
1345
1346 # ifdef ARM32
1347 #   define CPP_WORDSZ 32
1348 #   define MACH_TYPE "ARM32"
1349 #   define ALIGNMENT 4
1350 #   ifdef NETBSD
1351 #       define OS_TYPE "NETBSD"
1352 #       define HEURISTIC2
1353         extern char etext;
1354 #       define DATASTART ((ptr_t)(&etext))
1355 #       define USE_GENERIC_PUSH_REGS
1356 #   endif
1357 #   ifdef LINUX
1358 #       define OS_TYPE "LINUX"
1359 #       define HEURISTIC1
1360 #       undef STACK_GRAN
1361 #       define STACK_GRAN 0x10000000
1362 #       define USE_GENERIC_PUSH_REGS
1363 #       ifdef __ELF__
1364 #            define DYNAMIC_LOADING
1365 #            include <features.h>
1366 #            if defined(__GLIBC__) && __GLIBC__ >= 2
1367 #                define LINUX_DATA_START
1368 #            else
1369                  extern char **__environ;
1370 #                define DATASTART ((ptr_t)(&__environ))
1371                               /* hideous kludge: __environ is the first */
1372                               /* word in crt0.o, and delimits the start */
1373                               /* of the data segment, no matter which   */
1374                               /* ld options were passed through.        */
1375                               /* We could use _etext instead, but that  */
1376                               /* would include .rodata, which may       */
1377                               /* contain large read-only data tables    */
1378                               /* that we'd rather not scan.             */
1379 #            endif
1380              extern int _end;
1381 #            define DATAEND (&_end)
1382 #       else
1383              extern int etext;
1384 #            define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
1385 #       endif
1386 #   endif
1387 #   ifdef MSWINCE
1388 #     define OS_TYPE "MSWINCE"
1389 #     define DATAEND /* not needed */
1390 #   endif
1391 #endif
1392
1393 # ifdef SH
1394 #   define MACH_TYPE "SH"
1395 #   define ALIGNMENT 4
1396 #   ifdef MSWINCE
1397 #     define OS_TYPE "MSWINCE"
1398 #     define DATAEND /* not needed */
1399 #   endif
1400 #   ifdef LINUX
1401 #     define OS_TYPE "LINUX"
1402 #     define STACKBOTTOM ((ptr_t) 0x7c000000)
1403 #     define USE_GENERIC_PUSH_REGS
1404 #     define DYNAMIC_LOADING
1405 #     define LINUX_DATA_START
1406       extern int _end;
1407 #     define DATAEND (&_end)
1408 #   endif
1409 # endif
1410  
1411 # ifdef SH4
1412 #   define MACH_TYPE "SH4"
1413 #   define OS_TYPE "MSWINCE"
1414 #   define ALIGNMENT 4
1415 #   define DATAEND /* not needed */
1416 # endif
1417
1418 #ifdef LINUX_DATA_START
1419     /* Some Linux distributions arrange to define __data_start.  Some   */
1420     /* define data_start as a weak symbol.  The latter is technically   */
1421     /* broken, since the user program may define data_start, in which   */
1422     /* case we lose.  Nonetheless, we try both, prefering __data_start. */
1423     /* We assume gcc.   */
1424 #   pragma weak __data_start
1425     extern int __data_start;
1426 #   pragma weak data_start
1427     extern int data_start;
1428 #   define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
1429 #endif
1430
1431 #if defined(LINUX) && defined(REDIRECT_MALLOC)
1432     /* Rld appears to allocate some memory with its own allocator, and  */
1433     /* some through malloc, which might be redirected.  To make this    */
1434     /* work with collectable memory, we have to scan memory allocated   */
1435     /* by rld's internal malloc.                                        */
1436 #   define USE_PROC_FOR_LIBRARIES
1437 #endif
1438     
1439 # ifndef STACK_GROWS_UP
1440 #   define STACK_GROWS_DOWN
1441 # endif
1442
1443 # ifndef CPP_WORDSZ
1444 #   define CPP_WORDSZ 32
1445 # endif
1446
1447 # ifndef OS_TYPE
1448 #   define OS_TYPE ""
1449 # endif
1450
1451 # ifndef DATAEND
1452     extern int end;
1453 #   define DATAEND (&end)
1454 # endif
1455
1456 # if defined(SVR4) && !defined(GETPAGESIZE)
1457 #    include <unistd.h>
1458 #    define GETPAGESIZE()  sysconf(_SC_PAGESIZE)
1459 # endif
1460
1461 # ifndef GETPAGESIZE
1462 #   if defined(SUNOS5) || defined(IRIX5)
1463 #       include <unistd.h>
1464 #   endif
1465 #   define GETPAGESIZE() getpagesize()
1466 # endif
1467
1468 # if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
1469     /* OS has SVR4 generic features.  Probably others also qualify.     */
1470 #   define SVR4
1471 # endif
1472
1473 # if defined(SUNOS5) || defined(DRSNX)
1474     /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
1475     /* loader.                                                          */
1476 #   define SUNOS5DL
1477     /* OS has SUNOS5 style signal handlers.                             */
1478 #   define SUNOS5SIGS
1479 # endif
1480
1481 # if defined(HPUX)
1482 #   define SUNOS5SIGS
1483 # endif
1484
1485 # if defined(SVR4) || defined(LINUX) || defined(IRIX) || defined(HPUX) \
1486     || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
1487     || defined(BSD) || defined(AIX) || defined(MACOSX) || defined(OSF1)
1488 #   define UNIX_LIKE   /* Basic Unix-like system calls work.    */
1489 # endif
1490
1491 # if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
1492    -> bad word size
1493 # endif
1494
1495 # ifdef PCR
1496 #   undef DYNAMIC_LOADING
1497 #   undef STACKBOTTOM
1498 #   undef HEURISTIC1
1499 #   undef HEURISTIC2
1500 #   undef PROC_VDB
1501 #   undef MPROTECT_VDB
1502 #   define PCR_VDB
1503 # endif
1504
1505 # ifdef SRC_M3
1506 /* Postponed for now. */
1507 #   undef PROC_VDB
1508 #   undef MPROTECT_VDB
1509 # endif
1510
1511 # ifdef SMALL_CONFIG
1512 /* Presumably not worth the space it takes. */
1513 #   undef PROC_VDB
1514 #   undef MPROTECT_VDB
1515 # endif
1516
1517 # ifdef USE_MUNMAP
1518 #   undef MPROTECT_VDB  /* Can't deal with address space holes. */
1519 # endif
1520
1521 # ifdef PARALLEL_MARK
1522 #   undef MPROTECT_VDB  /* For now.     */
1523 # endif
1524
1525 # if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
1526 #   define DEFAULT_VDB
1527 # endif
1528
1529 # ifndef PREFETCH
1530 #   define PREFETCH(x)
1531 #   define NO_PREFETCH
1532 # endif
1533
1534 # ifndef PREFETCH_FOR_WRITE
1535 #   define PREFETCH_FOR_WRITE(x)
1536 #   define NO_PREFETCH_FOR_WRITE
1537 # endif
1538
1539 # ifndef CACHE_LINE_SIZE
1540 #   define CACHE_LINE_SIZE 32   /* Wild guess   */
1541 # endif
1542
1543 # ifndef CLEAR_DOUBLE
1544 #   define CLEAR_DOUBLE(x) \
1545         ((word*)x)[0] = 0; \
1546         ((word*)x)[1] = 0;
1547 # endif /* CLEAR_DOUBLE */
1548
1549 /* Internally to the collector we test only the XXX_THREADS macros      */
1550 /* not the GC_XXX_THREADS versions.  Here we make sure the latter       */
1551 /* are treated as equivalent.                                           */
1552 #if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_THREADS)
1553 #   define _SOLARIS_THREADS
1554 #endif
1555 #if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS)
1556 #   define _SOLARIS_PTHREADS
1557 #endif
1558 #if defined(GC_IRIX_THREADS) && !defined(IRIX_THREADS)
1559 #   define IRIX_THREADS
1560 #endif
1561 #if defined(GC_LINUX_THREADS) && !defined(LINUX_THREADS)
1562 #   define LINUX_THREADS
1563 #endif
1564 #if defined(GC_WIN32_THREADS) && !defined(WIN32_THREADS)
1565 #   define WIN32_THREADS
1566 #endif
1567 #if defined(GC_HPUX_THREADS) && !defined(HPUX_THREADS)
1568 #   define HPUX_THREADS
1569 #endif
1570 #if defined(GC_OSF1_THREADS) && !defined(OSF1_THREADS)
1571 #   define OSF1_THREADS
1572 #endif
1573
1574 /* Internally we use SOLARIS_THREADS to test for either old or pthreads. */
1575 # if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
1576 #   define SOLARIS_THREADS
1577 # endif
1578 # if defined(IRIX_THREADS) && !defined(IRIX5)
1579 --> inconsistent configuration
1580 # endif
1581 # if defined(LINUX_THREADS) && !defined(LINUX)
1582 --> inconsistent configuration
1583 # endif
1584 # if defined(SOLARIS_THREADS) && !defined(SUNOS5)
1585 --> inconsistent configuration
1586 # endif
1587 # if defined(HPUX_THREADS) && !defined(HPUX)
1588 --> inconsistent configuration
1589 # endif
1590 # if defined(PCR) || defined(SRC_M3) || \
1591         defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
1592         defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
1593         defined(HPUX_THREADS) || defined(OSF1_THREADS)
1594 #   define THREADS
1595 # endif
1596
1597 # if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
1598      || defined(LINT) || defined(MSWINCE) \
1599      || (defined(I386) && defined(__LCC__))
1600         /* Use setjmp based hack to mark from callee-save registers.    */
1601         /* The define should move to the individual platform            */
1602         /* descriptions.                                                */
1603 #       define USE_GENERIC_PUSH_REGS
1604 # endif
1605 # if defined(I386) && defined(LINUX)
1606     /* SAVE_CALL_CHAIN is supported if the code is compiled to save     */
1607     /* frame pointers by default, i.e. no -fomit-frame-pointer flag.    */
1608 # ifdef SAVE_CALL_COUNT
1609 #   define SAVE_CALL_CHAIN 
1610 # endif
1611 # endif
1612 # if defined(SPARC)
1613 #   define SAVE_CALL_CHAIN
1614 #   define ASM_CLEAR_CODE       /* Stack clearing is crucial, and we    */
1615                                 /* include assembly code to do it well. */
1616 # endif
1617
1618 # endif /* GCCONFIG_H */