~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to include/private/gcconfig.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-19 12:19:56 UTC
  • mfrom: (1.3.2 upstream) (0.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110219121956-67rb69xlt5nud3v2
Tags: 1:7.1-5
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    /* Fake ptr_t declaration, just to avoid compilation errors.        */
31
31
    /* This avoids many instances if "ifndef GC_PRIVATE_H" below.       */
32
32
    typedef struct GC_undefined_struct * ptr_t;
 
33
#   include <stddef.h>  /* For size_t etc. */
33
34
# endif
34
35
 
35
36
/* Machine dependent parameters.  Some tuning parameters can be found   */
56
57
 
57
58
/* And one for FreeBSD: */
58
59
# if (defined(__FreeBSD__) || defined(__DragonFly__) || \
59
 
        defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
 
60
      defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
60
61
#    define FREEBSD
61
62
# endif
62
63
 
69
70
#    endif
70
71
# endif
71
72
# if defined(sun) && defined(mc68000)
72
 
#    define M68K
73
 
#    define SUNOS4
74
 
#    define mach_type_known
 
73
#    error SUNOS4 no longer supported
75
74
# endif
76
75
# if defined(hp9000s300)
77
 
#    define M68K
78
 
#    define HP
79
 
#    define mach_type_known
 
76
#    error M68K based HP machines no longer supported.
80
77
# endif
81
78
# if defined(OPENBSD) && defined(m68k)
82
79
#    define M68K
124
121
#      if defined(ultrix) || defined(__ultrix)
125
122
#        define ULTRIX
126
123
#      else
127
 
#        if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
128
 
            || defined(__SYSTYPE_SVR4__)
129
 
#          define IRIX5   /* or IRIX 6.X */
130
 
#        else
131
 
#          define RISCOS  /* or IRIX 4.X */
132
 
#        endif
 
124
#        define IRIX5   /* or IRIX 6.X */
133
125
#      endif
134
126
#    endif /* !LINUX */
135
127
#    if defined(__NetBSD__) && defined(__MIPSEL__)
151
143
# endif
152
144
# if defined(sun) && (defined(i386) || defined(__i386__))
153
145
#    define I386
154
 
#    define SUNOS5
 
146
#    define SOLARIS
155
147
#    define mach_type_known
156
148
# endif
157
149
# if defined(sun) && defined(__amd64)
165
157
#    define mach_type_known
166
158
# endif
167
159
# if defined(ibm032)
168
 
#   define RT
169
 
#   define mach_type_known
 
160
#   error IBM PC/RT no longer supported.
170
161
# endif
171
162
# if defined(sun) && (defined(sparc) || defined(__sparc))
172
163
#   define SPARC
173
164
    /* Test for SunOS 5.x */
174
165
#     include <errno.h>
175
 
#     ifdef ECHRNG
176
 
#       define SUNOS5
177
 
#     else
178
 
#       define SUNOS4
179
 
#     endif
 
166
#     define SOLARIS
180
167
#   define mach_type_known
181
168
# endif
182
169
# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
187
174
#   define mach_type_known
188
175
# endif
189
176
# if defined(_IBMR2)
190
 
#   define RS6000
 
177
#   define POWERPC
 
178
#   define AIX
191
179
#   define mach_type_known
192
180
# endif
193
181
# if defined(__NetBSD__) && defined(__sparc__)
205
193
#   define mach_type_known
206
194
# endif
207
195
# if defined(_AUX_SOURCE)
208
 
#   define M68K
209
 
#   define SYSV
210
 
#   define mach_type_known
 
196
#   error A/UX no longer supported
211
197
# endif
212
198
# if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
213
199
     || defined(hppa) || defined(__hppa__)
217
203
#   endif
218
204
#   define mach_type_known
219
205
# endif
220
 
# if defined(__ia64) && defined(_HPUX_SOURCE)
 
206
# if defined(__ia64) && (defined(_HPUX_SOURCE) || defined(__HP_aCC))
221
207
#   define IA64
222
208
#   ifndef HPUX
223
209
#     define HPUX
272
258
#    define ARM32
273
259
#    define mach_type_known
274
260
# endif
 
261
# if defined(LINUX) && defined(__avr32__)
 
262
#    define AVR32
 
263
#    define mach_type_known
 
264
# endif
275
265
# if defined(LINUX) && defined(__sh__)
276
266
#    define SH
277
267
#    define mach_type_known
309
299
#   if defined(__ppc__)  || defined(__ppc64__)
310
300
#    define POWERPC
311
301
#    define mach_type_known
312
 
#   endif
313
 
#   if defined(__i386__)
 
302
#   elif defined(__x86_64__)
 
303
#    define X86_64
 
304
#    define mach_type_known
 
305
#   elif defined(__i386__)
314
306
#    define I386
315
307
#    define mach_type_known
316
308
#   endif
349
341
# if defined(FREEBSD) && defined(__sparc__)
350
342
#    define SPARC
351
343
#    define mach_type_known
352
 
#endif
 
344
# endif
353
345
# if defined(bsdi) && (defined(i386) || defined(__i386__))
354
346
#    define I386
355
347
#    define BSDI
386
378
# else
387
379
#   if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
388
380
        || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
389
 
#     define I386
390
 
#     define MSWIN32    /* or Win32s */
 
381
#     if defined(__LP64__) || defined(_WIN64)
 
382
#       define X86_64
 
383
#     else
 
384
#       define I386
 
385
#     endif
 
386
#     define MSWIN32    /* or Win64 */
391
387
#     define mach_type_known
392
388
#   endif
393
389
#   if defined(_MSC_VER) && defined(_M_IA64)
424
420
#   define mach_type_known
425
421
# endif
426
422
# if defined(__pj__)
427
 
#   define PJ
428
 
#   define mach_type_known
 
423
#   error PicoJava no longer supported
 
424
    /* The implementation had problems, and I haven't heard of users    */
 
425
    /* in ages.  If you want it resurrected, let me know.               */
429
426
# endif
430
427
# if defined(__embedded__) && defined(PPC)
431
428
#   define POWERPC
473
470
/* Or manually define the machine type here.  A machine type is         */
474
471
/* characterized by the architecture.  Some                             */
475
472
/* machine types are further subdivided by OS.                          */
476
 
/* the macros ULTRIX, RISCOS, and BSD to distinguish.                   */
477
 
/* Note that SGI IRIX is treated identically to RISCOS.                 */
 
473
/* Macros such as LINUX, FREEBSD, etc. distinguish them.                */
478
474
/* SYSV on an M68K actually means A/UX.                                 */
479
475
/* The distinction in these cases is usually the stack starting address */
480
476
# ifndef mach_type_known
481
 
        --> unknown machine type
 
477
#   error "The collector has not been ported to this machine/OS combination."
482
478
# endif
483
479
                    /* Mapping is: M68K       ==> Motorola 680X0        */
484
 
                    /*             (SUNOS4,HP,NEXT, and SYSV (A/UX),    */
 
480
                    /*             (NEXT, and SYSV (A/UX),              */
485
481
                    /*             MACOS and AMIGA variants)            */
486
482
                    /*             I386       ==> Intel 386             */
487
483
                    /*              (SEQUENT, OS2, SCO, LINUX, NETBSD,  */
488
484
                    /*               FREEBSD, THREE86BSD, MSWIN32,      */
489
 
                    /*               BSDI,SUNOS5, NEXT, other variants) */
 
485
                    /*               BSDI,SOLARIS, NEXT, other variants)        */
490
486
                    /*             NS32K      ==> Encore Multimax       */
491
 
                    /*             MIPS       ==> R2000 through R14K    */
 
487
                    /*             MIPS       ==> R2000 through R14K    */
492
488
                    /*                  (many variants)                 */
493
489
                    /*             VAX        ==> DEC VAX               */
494
490
                    /*                  (BSD, ULTRIX variants)          */
495
 
                    /*             RS6000     ==> IBM RS/6000 AIX3.X    */
496
 
                    /*             RT         ==> IBM PC/RT             */
497
491
                    /*             HP_PA      ==> HP9000/700 & /800     */
498
492
                    /*                            HP/UX, LINUX          */
499
493
                    /*             SPARC      ==> SPARC v7/v8/v9        */
500
 
                    /*                  (SUNOS4, SUNOS5, LINUX,         */
501
 
                    /*                   DRSNX variants)                */
 
494
                    /*                  (SOLARIS, LINUX, DRSNX variants)        */
502
495
                    /*             ALPHA      ==> DEC Alpha             */
503
496
                    /*                  (OSF1 and LINUX variants)       */
504
497
                    /*             M88K       ==> Motorola 88XX0        */
516
509
                    /*             X86_64     ==> AMD x86-64            */
517
510
                    /*             POWERPC    ==> IBM/Apple PowerPC     */
518
511
                    /*                  (MACOS(<=9),DARWIN(incl.MACOSX),*/
519
 
                    /*                   LINUX, NETBSD, NOSYS variants) */
 
512
                    /*                   LINUX, NETBSD, AIX, NOSYS      */
 
513
                    /*                   variants)                      */
520
514
                    /*                  Handles 32 and 64-bit variants. */
521
 
                    /*                  AIX should be handled here, but */
522
 
                    /*                  that's called an RS6000.        */
523
515
                    /*             CRIS       ==> Axis Etrax            */
524
516
                    /*             M32R       ==> Renesas M32R          */
525
517
 
557
549
 * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
558
550
 * without any special options.
559
551
 *
560
 
 * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
561
 
 * the pointer size.
562
 
 *
563
552
 * STACKBOTTOM is the cool end of the stack, which is usually the
564
553
 * highest address in the stack.
565
554
 * Under PCR or OS/2, we have other ways of finding thread stacks.
573
562
 * If STACKBOTTOM is defined, then it's value will be used directly as the
574
563
 * stack base.  If LINUX_STACKBOTTOM is defined, then it will be determined
575
564
 * with a method appropriate for most Linux systems.  Currently we look
576
 
 * first for __libc_stack_end, and if that fails read it from /proc.
 
565
 * first for __libc_stack_end (currently only id USE_LIBC_PRIVATES is
 
566
 * defined), and if that fails read it from /proc.  (If USE_LIBC_PRIVATES
 
567
 * is not defined and NO_PROC_STAT is defined, we revert to HEURISTIC2.)
577
568
 * If either of the last two macros are defined, then STACKBOTTOM is computed
578
569
 * during collector startup using one of the following two heuristics:
579
570
 * HEURISTIC1:  Take an address inside GC_init's frame, and round it up to
625
616
 * Each architecture may also define the style of virtual dirty bit
626
617
 * implementation to be used:
627
618
 *   MPROTECT_VDB: Write protect the heap and catch faults.
 
619
 *   GWW_VDB: Use win32 GetWriteWatch primitive.
628
620
 *   PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
629
621
 *
 
622
 * The first and second one may be combined, in which case a runtime
 
623
 * selection will be made, based on GetWriteWatch availability.
 
624
 *
630
625
 * An architecture may define DYNAMIC_LOADING if dynamic_load.c
631
626
 * defined GC_register_dynamic_libraries() for the architecture.
632
627
 *
644
639
 */
645
640
 
646
641
/* If we are using a recent version of gcc, we can use __builtin_unwind_init()
647
 
 * to push the relevant registers onto the stack.  This generally makes
648
 
 * USE_GENERIC_PUSH_REGS the preferred approach for marking from registers.
 
642
 * to push the relevant registers onto the stack.
649
643
 */
650
644
# if defined(__GNUC__) && ((__GNUC__ >= 3) || \
651
645
                           (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
652
 
                       && !defined(__INTEL_COMPILER) \
653
 
                       && !defined(__PATHCC__)
 
646
                       && !defined(__INTEL_COMPILER) && !defined(__PATHCC__)
654
647
#   define HAVE_BUILTIN_UNWIND_INIT
655
648
# endif
656
649
 
668
661
          extern char etext[];
669
662
#         define DATASTART ((ptr_t)(etext))
670
663
#       endif
671
 
#       define USE_GENERIC_PUSH_REGS
672
664
#   endif
673
665
#   ifdef NETBSD
674
666
#       define OS_TYPE "NETBSD"
680
672
          extern char etext[];
681
673
#         define DATASTART ((ptr_t)(etext))
682
674
#       endif
683
 
#       define USE_GENERIC_PUSH_REGS
684
675
#   endif
685
676
#   ifdef LINUX
686
677
#       define OS_TYPE "LINUX"
687
678
#       define LINUX_STACKBOTTOM
688
 
#       define USE_GENERIC_PUSH_REGS
689
 
                /* We never got around to the assembly version. */
690
679
#       define MPROTECT_VDB
691
680
#       ifdef __ELF__
692
681
#            define DYNAMIC_LOADING
712
701
#            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
713
702
#       endif
714
703
#   endif
715
 
#   ifdef SUNOS4
716
 
#       define OS_TYPE "SUNOS4"
717
 
        extern char etext[];
718
 
#       define DATASTART ((ptr_t)((((word) (etext)) + 0x1ffff) & ~0x1ffff))
719
 
#       define HEURISTIC1       /* differs      */
720
 
#       define DYNAMIC_LOADING
721
 
#   endif
722
 
#   ifdef HP
723
 
#       define OS_TYPE "HP"
724
 
        extern char etext[];
725
 
#       define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
726
 
#       define STACKBOTTOM ((ptr_t) 0xffeffffc)
727
 
                              /* empirically determined.  seems to work. */
728
 
#       include <unistd.h>
729
 
#       define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
730
 
#   endif
731
 
#   ifdef SYSV
732
 
#       define OS_TYPE "SYSV"
733
 
        extern etext[];
734
 
#       define DATASTART ((ptr_t)((((word) (etext)) + 0x3fffff) \
735
 
                                   & ~0x3fffff) \
736
 
                                  +((word)etext & 0x1fff))
737
 
        /* This only works for shared-text binaries with magic number 0413.
738
 
           The other sorts of SysV binaries put the data at the end of the text,
739
 
           in which case the default of etext would work.  Unfortunately,
740
 
           handling both would require having the magic-number available.
741
 
                                -- Parag
742
 
           */
743
 
#       define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
744
 
                        /* The stack starts at the top of memory, but   */
745
 
                        /* 0x0 cannot be used as setjump_test complains */
746
 
                        /* that the stack direction is incorrect.  Two  */
747
 
                        /* bytes down from 0x0 should be safe enough.   */
748
 
                        /*              --Parag                         */
749
 
#       include <sys/mmu.h>
750
 
#       define GETPAGESIZE() PAGESIZE   /* Is this still right? */
751
 
#   endif
752
704
#   ifdef AMIGA
753
705
#       define OS_TYPE "AMIGA"
754
706
                /* STACKBOTTOM and DATASTART handled specially  */
806
758
#     define DATAEND (_end)
807
759
#   endif
808
760
#   ifdef DARWIN
809
 
#     ifdef __ppc64__
 
761
#     define OS_TYPE "DARWIN"
 
762
#     define DYNAMIC_LOADING
 
763
#     if defined(__ppc64__)
810
764
#       define ALIGNMENT 8
811
765
#       define CPP_WORDSZ 64
 
766
#       define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
 
767
#       define CACHE_LINE_SIZE 64
 
768
#       ifndef HBLKSIZE
 
769
#         define HBLKSIZE 4096
 
770
#       endif
812
771
#     else
813
772
#       define ALIGNMENT 4
 
773
#       define STACKBOTTOM ((ptr_t) 0xc0000000)
814
774
#     endif
815
 
#     define OS_TYPE "DARWIN"
816
 
#     define DYNAMIC_LOADING
817
775
      /* XXX: see get_end(3), get_etext() and get_end() should not be used.
818
 
         These aren't used when dyld support is enabled (it is by default) */
 
776
         These aren't used when dyld support is enabled (it is by default) */
819
777
#     define DATASTART ((ptr_t) get_etext())
820
778
#     define DATAEND    ((ptr_t) get_end())
821
 
#     define STACKBOTTOM ((ptr_t) 0xc0000000)
822
779
#     define USE_MMAP
823
780
#     define USE_MMAP_ANON
824
 
#     define USE_ASM_PUSH_REGS
825
 
      /* This is potentially buggy. It needs more testing. See the comments in
826
 
         os_dep.c.  It relies on threads to track writes. */
827
781
#     ifdef GC_DARWIN_THREADS
828
 
/* #       define MPROTECT_VDB -- diabled for now.  May work for some apps. */
 
782
#       define MPROTECT_VDB
829
783
#     endif
830
784
#     include <unistd.h>
831
785
#     define GETPAGESIZE() getpagesize()
837
791
          __asm__ __volatile__ ("dcbtst 0,%0" : : "r" ((const void *) (x)))
838
792
#     endif
839
793
      /* There seems to be some issues with trylock hanging on darwin. This
840
 
         should be looked into some more */
 
794
         should be looked into some more */
841
795
#     define NO_PTHREAD_TRYLOCK
842
796
#   endif
843
797
#   ifdef FREEBSD
864
818
#     define DATASTART GC_data_start
865
819
#     define DYNAMIC_LOADING
866
820
#   endif
 
821
#   ifdef AIX
 
822
#     define OS_TYPE "AIX"
 
823
#     undef ALIGNMENT /* in case it's defined   */
 
824
#     ifdef IA64
 
825
#       undef IA64
 
826
          /* DOB: some AIX installs stupidly define IA64 in */
 
827
          /* /usr/include/sys/systemcfg.h                   */
 
828
#     endif
 
829
#     ifdef __64BIT__
 
830
#       define ALIGNMENT 8
 
831
#       define CPP_WORDSZ 64
 
832
#       define STACKBOTTOM ((ptr_t)0x1000000000000000)
 
833
#     else
 
834
#       define ALIGNMENT 4
 
835
#       define CPP_WORDSZ 32
 
836
#       define STACKBOTTOM ((ptr_t)((ulong)&errno))
 
837
#     endif
 
838
#     define USE_MMAP
 
839
#     define USE_MMAP_ANON
 
840
        /* From AIX linker man page:
 
841
        _text Specifies the first location of the program.
 
842
        _etext Specifies the first location after the program.
 
843
        _data Specifies the first location of the data.
 
844
        _edata Specifies the first location after the initialized data
 
845
        _end or end Specifies the first location after all data.
 
846
        */
 
847
      extern int _data[], _end[];
 
848
#     define DATASTART ((ptr_t)((ulong)_data))
 
849
#     define DATAEND ((ptr_t)((ulong)_end))
 
850
      extern int errno;
 
851
#     define DYNAMIC_LOADING
 
852
        /* For really old versions of AIX, this may have to be removed. */
 
853
#   endif
 
854
 
867
855
#   ifdef NOSYS
868
856
#     define ALIGNMENT 4
869
857
#     define OS_TYPE "NOSYS"
893
881
#   endif
894
882
# endif
895
883
 
896
 
# ifdef RT
897
 
#   define MACH_TYPE "RT"
898
 
#   define ALIGNMENT 4
899
 
#   define DATASTART ((ptr_t) 0x10000000)
900
 
#   define STACKBOTTOM ((ptr_t) 0x1fffd800)
901
 
# endif
902
 
 
903
884
# ifdef SPARC
904
885
#   define MACH_TYPE "SPARC"
905
886
#   if defined(__arch64__) || defined(__sparcv9)
910
891
#     define ALIGNMENT 4        /* Required by hardware */
911
892
#     define CPP_WORDSZ 32
912
893
#   endif
913
 
#   define ALIGN_DOUBLE
914
 
#   ifdef SUNOS5
915
 
#       define OS_TYPE "SUNOS5"
 
894
    /* Don't define USE_ASM_PUSH_REGS.  We do use an asm helper, but    */
 
895
    /* not to push the registers on the mark stack.                     */
 
896
#   ifdef SOLARIS
 
897
#       define OS_TYPE "SOLARIS"
916
898
        extern int _etext[];
917
899
        extern int _end[];
918
 
        extern ptr_t GC_SysVGetDataStart();
919
 
#       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
 
900
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
 
901
#       define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
920
902
#       define DATAEND (_end)
921
903
#       if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
922
904
#           define USE_MMAP
949
931
                /* Solaris 5.4 installation.  Weird.                      */
950
932
#       define DYNAMIC_LOADING
951
933
#   endif
952
 
#   ifdef SUNOS4
953
 
#       define OS_TYPE "SUNOS4"
954
 
        /* [If you have a weak stomach, don't read this.]               */
955
 
        /* We would like to use:                                        */
956
 
/* #       define DATASTART ((ptr_t)((((word) (etext)) + 0x1fff) & ~0x1fff)) */
957
 
        /* This fails occasionally, due to an ancient, but very         */
958
 
        /* persistent ld bug.  etext is set 32 bytes too high.          */
959
 
        /* We instead read the text segment size from the a.out         */
960
 
        /* header, which happens to be mapped into our address space    */
961
 
        /* at the start of the text segment.  The detective work here   */
962
 
        /* was done by Robert Ehrlich, Manuel Serrano, and Bernard      */
963
 
        /* Serpette of INRIA.                                           */
964
 
        /* This assumes ZMAGIC, i.e. demand-loadable executables.       */
965
 
#       define TEXTSTART 0x2000
966
 
#       define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
967
 
#       define MPROTECT_VDB
968
 
#       define HEURISTIC1
969
 
#       define DYNAMIC_LOADING
970
 
#   endif
971
934
#   ifdef DRSNX
972
935
#       define OS_TYPE "DRSNX"
973
 
        extern ptr_t GC_SysVGetDataStart();
 
936
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
974
937
        extern int etext[];
975
 
#       define DATASTART GC_SysVGetDataStart(0x10000, etext)
 
938
#       define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
976
939
#       define MPROTECT_VDB
977
940
#       define STACKBOTTOM ((ptr_t) 0xdfff0000)
978
941
#       define DYNAMIC_LOADING
988
951
      extern int _etext[];
989
952
#     define DATAEND (_end)
990
953
#     define SVR4
991
 
      extern ptr_t GC_SysVGetDataStart();
 
954
      extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
992
955
#     ifdef __arch64__
993
 
#       define DATASTART GC_SysVGetDataStart(0x100000, _etext)
 
956
#       define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext)
994
957
#     else
995
 
#       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
 
958
#       define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
996
959
#     endif
997
960
#     define LINUX_STACKBOTTOM
998
961
#   endif
1035
998
# ifdef I386
1036
999
#   define MACH_TYPE "I386"
1037
1000
#   if defined(__LP64__) || defined(_WIN64)
1038
 
#     define CPP_WORDSZ 64
1039
 
#     define ALIGNMENT 8
 
1001
#     error This should be handled as X86_64
1040
1002
#   else
1041
1003
#     define CPP_WORDSZ 32
1042
1004
#     define ALIGNMENT 4
1045
1007
                        /* Borland.                                     */
1046
1008
                        /* Ivan Demakov: For Watcom the option is -zp4. */
1047
1009
#   endif
1048
 
#   ifndef SMALL_CONFIG
1049
 
#     define ALIGN_DOUBLE /* Not strictly necessary, but may give speed   */
1050
 
                          /* improvement on Pentiums.                     */
1051
 
#   endif
1052
 
#   ifdef HAVE_BUILTIN_UNWIND_INIT
1053
 
#       define USE_GENERIC_PUSH_REGS
1054
 
#   endif
1055
1010
#   ifdef SEQUENT
1056
1011
#       define OS_TYPE "SEQUENT"
1057
1012
        extern int etext[];
1065
1020
      extern int etext[];
1066
1021
#     define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
1067
1022
#   endif
1068
 
#   ifdef SUNOS5
1069
 
#       define OS_TYPE "SUNOS5"
 
1023
#   ifdef SOLARIS
 
1024
#       define OS_TYPE "SOLARIS"
1070
1025
        extern int _etext[], _end[];
1071
 
        extern ptr_t GC_SysVGetDataStart();
1072
 
#       define DATASTART GC_SysVGetDataStart(0x1000, _etext)
 
1026
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
 
1027
#       define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)_etext)
1073
1028
#       define DATAEND (_end)
1074
1029
/*      # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7,      */
1075
1030
/*      but reportedly breaks under 2.8.  It appears that the stack     */
1116
1071
#   ifdef DGUX
1117
1072
#       define OS_TYPE "DGUX"
1118
1073
        extern int _etext, _end;
1119
 
        extern ptr_t GC_SysVGetDataStart();
1120
 
#       define DATASTART GC_SysVGetDataStart(0x1000, &_etext)
 
1074
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
 
1075
#       define DATASTART GC_SysVGetDataStart(0x1000, (ptr_t)(&_etext))
1121
1076
#       define DATAEND (&_end)
1122
1077
#       define STACK_GROWS_DOWN
1123
1078
#       define HEURISTIC2
1136
1091
#   endif /* DGUX */
1137
1092
 
1138
1093
#   ifdef LINUX
1139
 
#       ifndef __GNUC__
1140
 
          /* The Intel compiler doesn't like inline assembly */
1141
 
#         define USE_GENERIC_PUSH_REGS
1142
 
#       endif
1143
1094
#       define OS_TYPE "LINUX"
1144
1095
#       define LINUX_STACKBOTTOM
1145
1096
#       if 0
1225
1176
                /* os_dep.c. OS2 actually has the right                 */
1226
1177
                /* system call!                                         */
1227
1178
#       define DATAEND  /* not needed */
1228
 
#       define USE_GENERIC_PUSH_REGS
1229
1179
#   endif
1230
1180
#   ifdef MSWIN32
1231
1181
#       define OS_TYPE "MSWIN32"
1232
1182
                /* STACKBOTTOM and DATASTART are handled specially in   */
1233
1183
                /* os_dep.c.                                            */
1234
 
#       ifndef __WATCOMC__
 
1184
#       if !defined(__WATCOMC__)
1235
1185
#         define MPROTECT_VDB
 
1186
          /* We also avoided doing this in the past with GC_WIN32_THREADS */
 
1187
          /* Hopefully that's fixed.                                      */
 
1188
#       endif
 
1189
#       if _MSC_VER >= 1300  /* .NET, i.e. > VisualStudio 6     */
 
1190
#         define GWW_VDB
1236
1191
#       endif
1237
1192
#       define DATAEND  /* not needed */
1238
1193
#   endif
1274
1229
#           define DYNAMIC_LOADING
1275
1230
#       endif
1276
1231
        extern char etext[];
1277
 
        extern char * GC_FreeBSDGetDataStart();
1278
 
#       define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
 
1232
        extern char * GC_FreeBSDGetDataStart(size_t, ptr_t);
 
1233
#       define DATASTART GC_FreeBSDGetDataStart(0x1000, (ptr_t)etext)
1279
1234
#   endif
1280
1235
#   ifdef NETBSD
1281
1236
#       define OS_TYPE "NETBSD"
1320
1275
#     define OS_TYPE "HURD"
1321
1276
#     define STACK_GROWS_DOWN
1322
1277
#     define HEURISTIC2
1323
 
      extern int  __data_start[];
1324
 
#     define DATASTART ( (ptr_t) (__data_start))
1325
 
      extern int   _end[];
1326
 
#     define DATAEND ( (ptr_t) (_end))
 
1278
#     define SIG_SUSPEND SIGUSR1
 
1279
#     define SIG_THR_RESTART SIGUSR2
 
1280
#     define SEARCH_FOR_DATA_START
 
1281
      extern int _end[];
 
1282
#     define DATAEND ((ptr_t) (_end))
1327
1283
/* #     define MPROTECT_VDB  Not quite working yet? */
1328
1284
#     define DYNAMIC_LOADING
1329
1285
#   endif
1332
1288
#     define DARWIN_DONT_PARSE_STACK
1333
1289
#     define DYNAMIC_LOADING
1334
1290
      /* XXX: see get_end(3), get_etext() and get_end() should not be used.
1335
 
        These aren't used when dyld support is enabled (it is by default) */
 
1291
         These aren't used when dyld support is enabled (it is by default) */
1336
1292
#     define DATASTART ((ptr_t) get_etext())
1337
1293
#     define DATAEND    ((ptr_t) get_end())
1338
1294
#     define STACKBOTTOM ((ptr_t) 0xc0000000)
1339
1295
#     define USE_MMAP
1340
1296
#     define USE_MMAP_ANON
1341
 
#     define USE_ASM_PUSH_REGS
1342
 
      /* This is potentially buggy. It needs more testing. See the comments in
1343
 
        os_dep.c.  It relies on threads to track writes. */
1344
1297
#     ifdef GC_DARWIN_THREADS
1345
 
/* #       define MPROTECT_VDB -- disabled for now.  May work for some apps. */
 
1298
#       define MPROTECT_VDB
1346
1299
#     endif
1347
1300
#     include <unistd.h>
1348
1301
#     define GETPAGESIZE() getpagesize()
1349
1302
      /* There seems to be some issues with trylock hanging on darwin. This
1350
 
         should be looked into some more */
 
1303
         should be looked into some more */
1351
1304
#      define NO_PTHREAD_TRYLOCK
1352
1305
#   endif /* DARWIN */
1353
1306
# endif
1375
1328
#     define DATAEND (_end)
1376
1329
      extern int __data_start[];
1377
1330
#     define DATASTART ((ptr_t)(__data_start))
1378
 
#     define ALIGNMENT 4
1379
 
#     define USE_GENERIC_PUSH_REGS
 
1331
#     ifdef _MIPS_SZPTR
 
1332
#       define CPP_WORDSZ _MIPS_SZPTR
 
1333
#       define ALIGNMENT (_MIPS_SZPTR/8)
 
1334
#     else
 
1335
#       define ALIGNMENT 4
 
1336
#     endif
1380
1337
#     if __GLIBC__ == 2 && __GLIBC_MINOR__ >= 2 || __GLIBC__ > 2
1381
1338
#        define LINUX_STACKBOTTOM
1382
1339
#     else
1404
1361
#        define ALIGNMENT 4
1405
1362
#      endif
1406
1363
#      define OS_TYPE "EWS4800"
1407
 
#      define USE_GENERIC_PUSH_REGS 1
1408
1364
#   endif
1409
1365
#   ifdef ULTRIX
1410
1366
#       define HEURISTIC2
1414
1370
#       define OS_TYPE "ULTRIX"
1415
1371
#       define ALIGNMENT 4
1416
1372
#   endif
1417
 
#   ifdef RISCOS
1418
 
#       define HEURISTIC2
1419
 
#       define DATASTART (ptr_t)0x10000000
1420
 
#       define OS_TYPE "RISCOS"
1421
 
#       define ALIGNMENT 4  /* Required by hardware */
1422
 
#   endif
1423
1373
#   ifdef IRIX5
1424
1374
#       define HEURISTIC2
1425
1375
        extern int _fdata[];
1440
1390
#       ifdef _MIPS_SZPTR
1441
1391
#         define CPP_WORDSZ _MIPS_SZPTR
1442
1392
#         define ALIGNMENT (_MIPS_SZPTR/8)
1443
 
#         if CPP_WORDSZ != 64
1444
 
#           define ALIGN_DOUBLE
1445
 
#         endif
1446
1393
#       else
1447
1394
#         define ALIGNMENT 4
1448
 
#         define ALIGN_DOUBLE
1449
1395
#       endif
1450
1396
#       define DYNAMIC_LOADING
1451
1397
#   endif
1458
1404
#     define OS_TYPE "NETBSD"
1459
1405
#     define ALIGNMENT 4
1460
1406
#     define HEURISTIC2
1461
 
#     define USE_GENERIC_PUSH_REGS
1462
1407
#     ifdef __ELF__
1463
1408
        extern int etext[];
1464
1409
#       define DATASTART GC_data_start
1474
1419
#    define OS_TYPE "NONSTOP"
1475
1420
#    define ALIGNMENT 4
1476
1421
#    define DATASTART ((ptr_t) 0x08000000)
1477
 
     extern int _end[];
1478
 
#    define DATAEND (_end)
 
1422
     extern char **environ;
 
1423
#    define DATAEND ((ptr_t)(environ - 0x10))
1479
1424
#    define STACKBOTTOM ((ptr_t) 0x4fffffff)
1480
 
#    define USE_GENERIC_PUSH_REGS
1481
 
#   endif
1482
 
# endif
1483
 
 
1484
 
# ifdef RS6000
1485
 
#   define MACH_TYPE "RS6000"
1486
 
#   ifdef ALIGNMENT
1487
 
#     undef ALIGNMENT
1488
 
#   endif
1489
 
#   ifdef IA64
1490
 
#     undef IA64 /* DOB: some AIX installs stupidly define IA64 in /usr/include/sys/systemcfg.h */
1491
 
#   endif
1492
 
#   ifdef __64BIT__
1493
 
#     define ALIGNMENT 8
1494
 
#     define CPP_WORDSZ 64
1495
 
#     define STACKBOTTOM ((ptr_t)0x1000000000000000)
1496
 
#   else
1497
 
#     define ALIGNMENT 4
1498
 
#     define CPP_WORDSZ 32
1499
 
#     define STACKBOTTOM ((ptr_t)((ulong)&errno))
1500
 
#   endif
1501
 
#   define USE_MMAP
1502
 
#   define USE_MMAP_ANON
1503
 
 /* From AIX linker man page:
1504
 
 _text Specifies the first location of the program.
1505
 
 _etext Specifies the first location after the program.
1506
 
 _data Specifies the first location of the data.
1507
 
 _edata Specifies the first location after the initialized data
1508
 
 _end or end Specifies the first location after all data.
1509
 
 */
1510
 
    extern int _data[], _end[];
1511
 
#   define DATASTART ((ptr_t)((ulong)_data))
1512
 
#   define DATAEND ((ptr_t)((ulong)_end))
1513
 
    extern int errno;
1514
 
#   define USE_GENERIC_PUSH_REGS
1515
 
#   define DYNAMIC_LOADING
1516
 
        /* For really old versions of AIX, this may have to be removed. */
 
1425
#   endif
1517
1426
# endif
1518
1427
 
1519
1428
# ifdef HP_PA
1524
1433
#   else
1525
1434
#     define CPP_WORDSZ 32
1526
1435
#     define ALIGNMENT 4
1527
 
#     define ALIGN_DOUBLE
1528
1436
#   endif
1529
1437
#   if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS)
1530
1438
#     ifndef LINUX /* For now. */
1531
1439
#       define MPROTECT_VDB
1532
1440
#     endif
1533
1441
#   else
1534
 
#     define GENERIC_COMPARE_AND_SWAP
1535
 
        /* No compare-and-swap instruction.  Use pthread mutexes        */
1536
 
        /* when we absolutely have to.                                  */
1537
1442
#     ifdef PARALLEL_MARK
1538
1443
#       define USE_MARK_BYTES
1539
1444
                /* Minimize compare-and-swap usage.             */
1584
1489
#   define MACH_TYPE "ALPHA"
1585
1490
#   define ALIGNMENT 8
1586
1491
#   define CPP_WORDSZ 64
1587
 
#   ifndef LINUX
1588
 
#     define USE_GENERIC_PUSH_REGS
1589
 
      /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
1590
 
      /* fp registers in some cases when the target is a 21264.  The assembly */
1591
 
      /* code doesn't handle that yet, and version dependencies make that a   */
1592
 
      /* bit tricky.  Do the easy thing for now.                                    */
1593
 
#   endif
1594
1492
#   ifdef NETBSD
1595
1493
#       define OS_TYPE "NETBSD"
1596
1494
#       define HEURISTIC2
1673
1571
 
1674
1572
# ifdef IA64
1675
1573
#   define MACH_TYPE "IA64"
1676
 
#   define USE_GENERIC_PUSH_REGS
1677
 
        /* We need to get preserved registers in addition to register   */
1678
 
        /* windows.   That's easiest to do with setjmp.                 */
1679
 
#   ifdef PARALLEL_MARK
1680
 
#       define USE_MARK_BYTES
1681
 
            /* Compare-and-exchange is too expensive to use for         */
1682
 
            /* setting mark bits.                                       */
1683
 
#   endif
1684
1574
#   ifdef HPUX
1685
1575
#       ifdef _ILP32
1686
1576
#         define CPP_WORDSZ 32
1687
 
#         define ALIGN_DOUBLE
1688
1577
            /* Requires 8 byte alignment for malloc */
1689
1578
#         define ALIGNMENT 4
1690
1579
#       else
1692
1581
                ---> unknown ABI
1693
1582
#         endif
1694
1583
#         define CPP_WORDSZ 64
1695
 
#         define ALIGN_DOUBLE
1696
1584
            /* Requires 16 byte alignment for malloc */
1697
1585
#         define ALIGNMENT 8
1698
1586
#       endif
1720
1608
#   endif
1721
1609
#   ifdef LINUX
1722
1610
#       define CPP_WORDSZ 64
1723
 
#       define ALIGN_DOUBLE
1724
 
          /* Requires 16 byte alignment for malloc */
1725
1611
#       define ALIGNMENT 8
1726
1612
#       define OS_TYPE "LINUX"
1727
1613
        /* The following works on NUE and older kernels:        */
1779
1665
#       define CPP_WORDSZ 32   /* Is this possible?     */
1780
1666
#     endif
1781
1667
#     define ALIGNMENT 8
 
1668
#     define STRTOULL _strtoui64
1782
1669
#   endif
1783
1670
# endif
1784
1671
 
1785
1672
# ifdef M88K
1786
1673
#   define MACH_TYPE "M88K"
1787
1674
#   define ALIGNMENT 4
1788
 
#   define ALIGN_DOUBLE
1789
1675
    extern int etext[];
1790
1676
#   ifdef CX_UX
1791
1677
#       define OS_TYPE "CX_UX"
1793
1679
#   endif
1794
1680
#   ifdef  DGUX
1795
1681
#       define OS_TYPE "DGUX"
1796
 
        extern ptr_t GC_SysVGetDataStart();
1797
 
#       define DATASTART GC_SysVGetDataStart(0x10000, etext)
 
1682
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
 
1683
#       define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)etext)
1798
1684
#   endif
1799
1685
#   define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
1800
1686
# endif
1804
1690
    /* be moved to the S390 category.                                   */
1805
1691
#   define MACH_TYPE "S370"
1806
1692
#   define ALIGNMENT 4  /* Required by hardware */
1807
 
#   define USE_GENERIC_PUSH_REGS
1808
1693
#   ifdef UTS4
1809
1694
#       define OS_TYPE "UTS4"
1810
1695
        extern int etext[];
1811
1696
        extern int _etext[];
1812
1697
        extern int _end[];
1813
 
        extern ptr_t GC_SysVGetDataStart();
1814
 
#       define DATASTART GC_SysVGetDataStart(0x10000, _etext)
 
1698
        extern ptr_t GC_SysVGetDataStart(size_t, ptr_t);
 
1699
#       define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext)
1815
1700
#       define DATAEND (_end)
1816
1701
#       define HEURISTIC2
1817
1702
#   endif
1819
1704
 
1820
1705
# ifdef S390
1821
1706
#   define MACH_TYPE "S390"
1822
 
#   define USE_GENERIC_PUSH_REGS
1823
1707
#   ifndef __s390x__
1824
 
#     define ALIGNMENT 4
1825
 
#     define CPP_WORDSZ 32
 
1708
#   define ALIGNMENT 4
 
1709
#   define CPP_WORDSZ 32
1826
1710
#   else
1827
 
#     define ALIGNMENT 8
1828
 
#     define CPP_WORDSZ 64
1829
 
#   endif
 
1711
#   define ALIGNMENT 8
 
1712
#   define CPP_WORDSZ 64
1830
1713
#   ifndef HBLKSIZE
1831
1714
#     define HBLKSIZE 4096
1832
1715
#   endif
 
1716
#   endif
1833
1717
#   ifdef LINUX
1834
1718
#       define OS_TYPE "LINUX"
1835
1719
#       define LINUX_STACKBOTTOM
1843
1727
#   endif
1844
1728
# endif
1845
1729
 
1846
 
# if defined(PJ)
1847
 
#   define ALIGNMENT 4
1848
 
    extern int _etext[];
1849
 
#   define DATASTART ((ptr_t)(_etext))
1850
 
#   define HEURISTIC1
1851
 
# endif
1852
 
 
1853
1730
# ifdef ARM32
1854
1731
#   define CPP_WORDSZ 32
1855
1732
#   define MACH_TYPE "ARM32"
1864
1741
           extern char etext[];
1865
1742
#          define DATASTART ((ptr_t)(etext))
1866
1743
#       endif
1867
 
#       define USE_GENERIC_PUSH_REGS
1868
1744
#   endif
1869
1745
#   ifdef LINUX
1870
1746
#       define OS_TYPE "LINUX"
1871
1747
#       define LINUX_STACKBOTTOM
1872
1748
#       undef STACK_GRAN
1873
1749
#       define STACK_GRAN 0x10000000
1874
 
#       define USE_GENERIC_PUSH_REGS
1875
1750
#       ifdef __ELF__
1876
1751
#            define DYNAMIC_LOADING
1877
1752
#            include <features.h>
1904
1779
      /* __data_start is usually defined in the target linker script.  */
1905
1780
      extern int __data_start[];
1906
1781
#     define DATASTART (ptr_t)(__data_start)
1907
 
#     define USE_GENERIC_PUSH_REGS
1908
1782
      /* __stack_base__ is set in newlib/libc/sys/arm/crt0.S  */
1909
1783
      extern void *__stack_base__;
1910
1784
#     define STACKBOTTOM ((ptr_t) (__stack_base__))
1911
1785
#   endif
1912
1786
#endif
1913
1787
 
 
1788
# ifdef AVR32
 
1789
#   define MACH_TYPE "AVR32"
 
1790
#   define CPP_WORDSZ 32
 
1791
#   define ALIGNMENT 4
 
1792
#   define OS_TYPE "LINUX"
 
1793
#   define DYNAMIC_LOADING
 
1794
#   define LINUX_STACKBOTTOM
 
1795
#   define USE_GENERIC_PUSH_REGS
 
1796
#   define SEARCH_FOR_DATA_START
 
1797
      extern int _end[];
 
1798
#   define DATAEND (_end)
 
1799
# endif
 
1800
 
1914
1801
# ifdef CRIS
1915
1802
#   define MACH_TYPE "CRIS"
1916
1803
#   define CPP_WORDSZ 32
1918
1805
#   define OS_TYPE "LINUX"
1919
1806
#   define DYNAMIC_LOADING
1920
1807
#   define LINUX_STACKBOTTOM
1921
 
#   define USE_GENERIC_PUSH_REGS
1922
1808
#   define SEARCH_FOR_DATA_START
1923
1809
      extern int _end[];
1924
1810
#   define DATAEND (_end)
1934
1820
#   ifdef LINUX
1935
1821
#     define OS_TYPE "LINUX"
1936
1822
#     define LINUX_STACKBOTTOM
1937
 
#     define USE_GENERIC_PUSH_REGS
1938
1823
#     define DYNAMIC_LOADING
1939
1824
#     define SEARCH_FOR_DATA_START
1940
1825
      extern int _end[];
1944
1829
#      define OS_TYPE "NETBSD"
1945
1830
#      define HEURISTIC2
1946
1831
#      define DATASTART GC_data_start
1947
 
#      define USE_GENERIC_PUSH_REGS
1948
1832
#      define DYNAMIC_LOADING
1949
1833
#   endif
1950
1834
# endif
1965
1849
#     define LINUX_STACKBOTTOM
1966
1850
#     undef STACK_GRAN
1967
1851
#     define STACK_GRAN 0x10000000
1968
 
#     define USE_GENERIC_PUSH_REGS
1969
1852
#     define DYNAMIC_LOADING
1970
1853
#     define SEARCH_FOR_DATA_START
1971
1854
      extern int _end[];
1981
1864
#     define HBLKSIZE 4096
1982
1865
#   endif
1983
1866
#   define CACHE_LINE_SIZE 64
1984
 
#   define USE_GENERIC_PUSH_REGS
1985
1867
#   ifdef LINUX
1986
1868
#       define OS_TYPE "LINUX"
1987
1869
#       define LINUX_STACKBOTTOM
2006
1888
             extern int etext[];
2007
1889
#            define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff))
2008
1890
#       endif
2009
 
#       if defined(__GNUC__) && __GNUC >= 3
 
1891
#       if defined(__GNUC__) && __GNUC__ >= 3
2010
1892
#           define PREFETCH(x) __builtin_prefetch((x), 0, 0)
2011
1893
#           define PREFETCH_FOR_WRITE(x) __builtin_prefetch((x), 1)
2012
1894
#       endif
2013
1895
#   endif
 
1896
#   ifdef DARWIN
 
1897
#     define OS_TYPE "DARWIN"
 
1898
#     define DARWIN_DONT_PARSE_STACK
 
1899
#     define DYNAMIC_LOADING
 
1900
      /* XXX: see get_end(3), get_etext() and get_end() should not be used.
 
1901
         These aren't used when dyld support is enabled (it is by default) */
 
1902
#     define DATASTART ((ptr_t) get_etext())
 
1903
#     define DATAEND    ((ptr_t) get_end())
 
1904
#     define STACKBOTTOM ((ptr_t) 0x7fff5fc00000)
 
1905
#     define USE_MMAP
 
1906
#     define USE_MMAP_ANON
 
1907
#     ifdef GC_DARWIN_THREADS
 
1908
#       define MPROTECT_VDB
 
1909
#     endif
 
1910
#     include <unistd.h>
 
1911
#     define GETPAGESIZE() getpagesize()
 
1912
      /* There seems to be some issues with trylock hanging on darwin. This
 
1913
         should be looked into some more */
 
1914
#     define NO_PTHREAD_TRYLOCK
 
1915
#   endif
2014
1916
#   ifdef FREEBSD
2015
1917
#       define OS_TYPE "FREEBSD"
2016
1918
#       ifndef GC_FREEBSD_THREADS
2083
1985
#         define HEAP_START DATAEND
2084
1986
#       endif
2085
1987
#   endif
 
1988
#   ifdef MSWIN32
 
1989
#       define OS_TYPE "MSWIN32"
 
1990
                /* STACKBOTTOM and DATASTART are handled specially in   */
 
1991
                /* os_dep.c.                                            */
 
1992
#       if !defined(__WATCOMC__)
 
1993
#         define MPROTECT_VDB
 
1994
          /* We also avoided doing this in the past with GC_WIN32_THREADS */
 
1995
          /* Hopefully that's fixed.                                      */
 
1996
#       endif
 
1997
#       if _MSC_VER >= 1300  /* .NET, i.e. > VisualStudio 6     */
 
1998
#         define GWW_VDB
 
1999
#       endif
 
2000
#       define DATAEND  /* not needed */
 
2001
#   endif
2086
2002
# endif
2087
2003
 
 
2004
#if defined(LINUX_STACKBOTTOM) && defined(NO_PROC_STAT) \
 
2005
    && !defined(USE_LIBC_PRIVATES)
 
2006
    /* This combination will fail, since we have no way to get  */
 
2007
    /* the stack base.  Use HEURISTIC2 instead.                 */
 
2008
#   undef LINUX_STACKBOTTOM
 
2009
#   define HEURISTIC2
 
2010
    /* This may still fail on some architectures like IA64.     */
 
2011
    /* We tried ...                                             */
 
2012
#endif
 
2013
 
2088
2014
#if defined(LINUX) && defined(USE_MMAP)
2089
2015
    /* The kernel may do a somewhat better job merging mappings etc.    */
2090
2016
    /* with anonymous mappings.                                         */
2091
2017
#   define USE_MMAP_ANON
2092
2018
#endif
2093
2019
 
2094
 
#if defined(LINUX) && defined(REDIRECT_MALLOC)
2095
 
    /* Rld appears to allocate some memory with its own allocator, and  */
2096
 
    /* some through malloc, which might be redirected.  To make this    */
2097
 
    /* work with collectable memory, we have to scan memory allocated   */
2098
 
    /* by rld's internal malloc.                                        */
 
2020
#if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC)
 
2021
    /* Nptl allocates thread stacks with mmap, which is fine.  But it   */
 
2022
    /* keeps a cache of thread stacks.  Thread stacks contain the       */
 
2023
    /* thread control blocks.  These in turn contain a pointer to       */
 
2024
    /* (sizeof (void *) from the beginning of) the dtv for thread-local */
 
2025
    /* storage, which is calloc allocated.  If we don't scan the cached */
 
2026
    /* thread stacks, we appear to lose the dtv.  This tends to         */
 
2027
    /* result in something that looks like a bogus dtv count, which     */
 
2028
    /* tends to result in a memset call on a block that is way too      */
 
2029
    /* large.  Sometimes we're lucky and the process just dies ...      */
 
2030
    /* There seems to be a similar issue with some other memory         */
 
2031
    /* allocated by the dynamic loader.                                 */
 
2032
    /* This should be avoidable by either:                              */
 
2033
    /* - Defining USE_PROC_FOR_LIBRARIES here.                          */
 
2034
    /*   That performs very poorly, precisely because we end up         */
 
2035
    /*   scanning cached stacks.                                        */
 
2036
    /* - Have calloc look at its callers.                               */
 
2037
    /*   In spite of the fact that it is gross and disgusting.          */
 
2038
    /* In fact neither seems to suffice, probably in part because       */
 
2039
    /* even with USE_PROC_FOR_LIBRARIES, we don't scan parts of stack   */
 
2040
    /* segments that appear to be out of bounds.  Thus we actually      */
 
2041
    /* do both, which seems to yield the best results.                  */
 
2042
 
2099
2043
#   define USE_PROC_FOR_LIBRARIES
2100
2044
#endif
2101
 
    
 
2045
 
2102
2046
# ifndef STACK_GROWS_UP
2103
2047
#   define STACK_GROWS_DOWN
2104
2048
# endif
2122
2066
# endif
2123
2067
 
2124
2068
# ifndef GETPAGESIZE
2125
 
#   if defined(SUNOS5) || defined(IRIX5)
 
2069
#   if defined(SOLARIS) || defined(IRIX5) || defined(LINUX) \
 
2070
       || defined(NETBSD) || defined(FREEBSD) || defined(HPUX)
2126
2071
#       include <unistd.h>
2127
2072
#   endif
2128
2073
#   define GETPAGESIZE() getpagesize()
2129
2074
# endif
2130
2075
 
2131
 
# if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
2132
 
            /* OS has SVR4 generic features.  Probably others also qualify.     */
 
2076
# if defined(SOLARIS) || defined(DRSNX) || defined(UTS4)
 
2077
            /* OS has SVR4 generic features.            */
 
2078
            /* Probably others also qualify.            */
2133
2079
#   define SVR4
2134
2080
# endif
2135
2081
 
2136
 
# if defined(SUNOS5) || defined(DRSNX)
2137
 
            /* OS has SUNOS5 style semi-undocumented interface to dynamic       */
2138
 
            /* loader.                                                          */
2139
 
#   define SUNOS5DL
2140
 
            /* OS has SUNOS5 style signal handlers.                             */
 
2082
# if defined(SOLARIS) || defined(DRSNX)
 
2083
            /* OS has SOLARIS style semi-undocumented interface */
 
2084
            /* to dynamic loader.                               */
 
2085
#   define SOLARISDL
 
2086
            /* OS has SOLARIS style signal handlers.            */
2141
2087
#   define SUNOS5SIGS
2142
2088
# endif
2143
2089
 
2157
2103
 
2158
2104
# if defined(SVR4) || defined(LINUX) || defined(IRIX5) || defined(HPUX) \
2159
2105
            || defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \
2160
 
            || defined(DGUX) || defined(BSD) || defined(SUNOS4) \
2161
 
            || defined(_AIX) || defined(DARWIN) || defined(OSF1)
 
2106
            || defined(DGUX) || defined(BSD) \
 
2107
            || defined(AIX) || defined(DARWIN) || defined(OSF1) \
 
2108
            || defined(HURD)
2162
2109
#   define UNIX_LIKE   /* Basic Unix-like system calls work.    */
2163
2110
# endif
2164
2111
 
2176
2123
#   define PCR_VDB
2177
2124
# endif
2178
2125
 
2179
 
# ifdef SRC_M3
2180
 
        /* Postponed for now. */
2181
 
#   undef PROC_VDB
2182
 
#   undef MPROTECT_VDB
2183
 
# endif
2184
 
 
2185
2126
# ifdef SMALL_CONFIG
2186
2127
        /* Presumably not worth the space it takes. */
2187
2128
#   undef PROC_VDB
2196
2137
#   undef MPROTECT_VDB  /* For now.     */
2197
2138
# endif
2198
2139
 
2199
 
# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
 
2140
# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB) \
 
2141
    && !defined(GWW_VDB)
2200
2142
#   define DEFAULT_VDB
2201
2143
# endif
2202
2144
 
2214
2156
#   define CACHE_LINE_SIZE 32   /* Wild guess   */
2215
2157
# endif
2216
2158
 
2217
 
# if defined(LINUX) || defined(__GLIBC__)
 
2159
# if defined(LINUX) || defined(HURD) || defined(__GLIBC__)
2218
2160
#   define REGISTER_LIBRARIES_EARLY
2219
2161
    /* We sometimes use dl_iterate_phdr, which may acquire an internal  */
2220
2162
    /* lock.  This isn't safe after the world has stopped.  So we must  */
2234
2176
                ((word*)x)[1] = 0;
2235
2177
# endif /* CLEAR_DOUBLE */
2236
2178
 
2237
 
        /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
2238
 
# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
2239
 
#   define GC_SOLARIS_THREADS
 
2179
# if defined(GC_LINUX_THREADS) && defined(REDIRECT_MALLOC) \
 
2180
     && !defined(INCLUDE_LINUX_THREAD_DESCR)
 
2181
    /* Will not work, since libc and the dynamic loader use thread      */
 
2182
    /* locals, sometimes as the only reference.                         */
 
2183
#   define INCLUDE_LINUX_THREAD_DESCR
2240
2184
# endif
2241
2185
 
2242
2186
# if defined(GC_IRIX_THREADS) && !defined(IRIX5)
2248
2192
# if defined(GC_NETBSD_THREADS) && !defined(NETBSD)
2249
2193
        --> inconsistent configuration
2250
2194
# endif
2251
 
# if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5)
 
2195
# if defined(GC_FREEBSD_THREADS) && !defined(FREEBSD)
 
2196
        --> inconsistent configuration
 
2197
# endif
 
2198
# if defined(GC_SOLARIS_THREADS) && !defined(SOLARIS)
2252
2199
        --> inconsistent configuration
2253
2200
# endif
2254
2201
# if defined(GC_HPUX_THREADS) && !defined(HPUX)
2257
2204
# if defined(GC_AIX_THREADS) && !defined(_AIX)
2258
2205
        --> inconsistent configuration
2259
2206
# endif
 
2207
# if defined(GC_GNU_THREADS) && !defined(HURD)
 
2208
        --> inconsistent configuration
 
2209
# endif
2260
2210
# if defined(GC_WIN32_THREADS) && !defined(MSWIN32) && !defined(CYGWIN32)
2261
2211
        --> inconsistent configuration
2262
2212
# endif
2263
2213
 
2264
 
# if defined(PCR) || defined(SRC_M3) || \
2265
 
                defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \
2266
 
                defined(GC_PTHREADS)
 
2214
# if defined(PCR) || defined(GC_WIN32_THREADS) || defined(GC_PTHREADS)
2267
2215
#   define THREADS
2268
2216
# endif
2269
2217
 
2270
 
# if defined(HP_PA) || defined(M88K) \
2271
 
             || defined(POWERPC) && !defined(DARWIN) \
2272
 
             || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
2273
 
             || (defined(I386) && defined(__LCC__))
2274
 
        /* Use setjmp based hack to mark from callee-save registers.    */
2275
 
        /* The define should move to the individual platform            */
2276
 
        /* descriptions.                                                */
2277
 
#       define USE_GENERIC_PUSH_REGS
 
2218
# if !defined(USE_MARK_BITS) && !defined(USE_MARK_BYTES)
 
2219
#   if defined(THREADS) && defined(PARALLEL_MARK)
 
2220
#     define USE_MARK_BYTES
 
2221
#   else
 
2222
#     define USE_MARK_BITS
 
2223
#   endif
2278
2224
# endif
2279
2225
 
2280
2226
# if defined(MSWINCE)
2318
2264
# ifdef SAVE_CALL_CHAIN
2319
2265
#   ifndef SAVE_CALL_COUNT
2320
2266
#     define NFRAMES 6  /* Number of frames to save. Even for           */
2321
 
                                /* alignment reasons.                           */
 
2267
                        /* alignment reasons.                           */
2322
2268
#   else
2323
2269
#     define NFRAMES ((SAVE_CALL_COUNT + 1) & ~1)
2324
2270
#   endif
2353
2299
#   define FIXUP_POINTER(p)
2354
2300
# endif
2355
2301
 
 
2302
# if !defined(MARK_BIT_PER_GRANULE) && !defined(MARK_BIT_PER_OBJ)
 
2303
#   define MARK_BIT_PER_GRANULE /* Usually faster */
 
2304
# endif
 
2305
 
 
2306
/* Some static sanity tests.    */
 
2307
# if defined(MARK_BIT_PER_GRANULE) && defined(MARK_BIT_PER_OBJ)
 
2308
#   error Define only one of MARK_BIT_PER_GRANULE and MARK_BIT_PER_OBJ.
 
2309
# endif
 
2310
 
 
2311
# if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
 
2312
#   error "Only one of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
 
2313
# endif
 
2314
# if !defined(STACK_GROWS_UP) && !defined(STACK_GROWS_DOWN)
 
2315
#   error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd."
 
2316
# endif
 
2317
 
 
2318
# if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX)
 
2319
#   error "REDIRECT_MALLOC with THREADS works at most on Linux."
 
2320
# endif
 
2321
 
2356
2322
#ifdef GC_PRIVATE_H
2357
2323
        /* This relies on some type definitions from gc_priv.h, from    */
2358
2324
        /* where it's normally included.                                */
2370
2336
        /* though we should perhaps take advantage of the case in which */
2371
2337
        /* does.                                                        */
2372
2338
        struct hblk;    /* See gc_priv.h.       */
2373
 
# ifdef PCR
2374
 
            char * real_malloc();
 
2339
# if defined(PCR)
 
2340
    char * real_malloc();
2375
2341
#   define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
2376
2342
                                          + GC_page_size-1)
2377
 
# else
2378
 
#   ifdef OS2
2379
 
              void * os2_alloc(size_t bytes);
2380
 
#     define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
 
2343
# elif defined(OS2)
 
2344
    void * os2_alloc(size_t bytes);
 
2345
#   define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
2381
2346
                                            + GC_page_size) \
2382
2347
                                            + GC_page_size-1)
2383
 
#   else
2384
 
#     if defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) || \
 
2348
# elif defined(NEXT) || defined(DOS4GW) || defined(NONSTOP) || \
2385
2349
                 (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \
2386
 
                 (defined(SUNOS5) && !defined(USE_MMAP))
2387
 
#       define GET_MEM(bytes) HBLKPTR((size_t) \
2388
 
                                              calloc(1, (size_t)bytes + GC_page_size) \
2389
 
                                              + GC_page_size-1)
2390
 
#     else
2391
 
#       ifdef MSWIN32
2392
 
          extern ptr_t GC_win32_get_mem();
2393
 
#         define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
2394
 
#       else
2395
 
#         ifdef MACOS
2396
 
#           if defined(USE_TEMPORARY_MEMORY)
2397
 
                        extern Ptr GC_MacTemporaryNewPtr(size_t size,
2398
 
                                                         Boolean clearMemory);
2399
 
#               define GET_MEM(bytes) HBLKPTR( \
 
2350
                 (defined(SOLARIS) && !defined(USE_MMAP))
 
2351
#   define GET_MEM(bytes) HBLKPTR((size_t) calloc(1, (size_t)bytes + GC_page_size) \
 
2352
                                                     + GC_page_size-1)
 
2353
# elif defined(MSWIN32)
 
2354
    extern ptr_t GC_win32_get_mem();
 
2355
#   define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
 
2356
# elif defined(MACOS)
 
2357
#   if defined(USE_TEMPORARY_MEMORY)
 
2358
      extern Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory);
 
2359
#     define GET_MEM(bytes) HBLKPTR( \
2400
2360
                            GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
2401
2361
                            + GC_page_size-1)
2402
 
#           else
2403
 
#                   define GET_MEM(bytes) HBLKPTR( \
 
2362
#   else
 
2363
#     define GET_MEM(bytes) HBLKPTR( \
2404
2364
                                NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
2405
 
#           endif
2406
 
#         else
2407
 
#           ifdef MSWINCE
2408
 
              extern ptr_t GC_wince_get_mem();
2409
 
#             define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
2410
 
#           else
2411
 
#             if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
2412
 
                        extern void *GC_amiga_get_mem(size_t size);
2413
 
#               define GET_MEM(bytes) HBLKPTR((size_t) \
 
2365
#   endif
 
2366
# elif defined(MSWINCE)
 
2367
    extern ptr_t GC_wince_get_mem();
 
2368
#   define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
 
2369
# elif defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
 
2370
    extern void *GC_amiga_get_mem(size_t size);
 
2371
#   define GET_MEM(bytes) HBLKPTR((size_t) \
2414
2372
                          GC_amiga_get_mem((size_t)bytes + GC_page_size) \
2415
2373
                          + GC_page_size-1)
2416
 
#             else
2417
 
                extern ptr_t GC_unix_get_mem();
2418
 
#               define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2419
 
#             endif
2420
 
#           endif
2421
 
#         endif
2422
 
#       endif
2423
 
#     endif
2424
 
#   endif
 
2374
# else
 
2375
    extern ptr_t GC_unix_get_mem();
 
2376
#   define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
2425
2377
# endif
2426
2378
 
2427
2379
#endif /* GC_PRIVATE_H */
2428
2380
 
2429
 
#if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
2430
 
  /* IBMs xlc compiler doesn't appear to follow the convention of       */
2431
 
  /* defining  __STDC__ to be zero in extended mode.                    */
2432
 
#   define __STDC__ 0
2433
 
#endif
2434
 
 
2435
2381
# endif /* GCCONFIG_H */