~ubuntu-branches/ubuntu/hardy/uim/hardy

« back to all changes in this revision

Viewing changes to sigscheme/libgcroots/include/private/gcconfig.h

  • Committer: Bazaar Package Importer
  • Author(s): Masahito Omote
  • Date: 2007-04-21 03:46:09 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070421034609-gpcurkutp8vaysqj
Tags: 1:1.4.1-3
* Switch to dh_gtkmodules for the gtk 2.10 transition (Closes:
  #419318)
  - debian/control: Add ${misc:Depends} and remove libgtk2.0-bin on
    uim-gtk2.0.
  - debian/uim-gtk2.0.post{inst,rm}: Removed.

Show diffs side-by-side

added added

removed removed

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