OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [boehm-gc/] [include/] [private/] [gcconfig.h] - Blame information for rev 729

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.