summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile156
-rw-r--r--Makefile.dj199
-rw-r--r--NT_MAKEFILE12
-rw-r--r--NT_THREADS_MAKEFILE426
-rw-r--r--OS2_MAKEFILE10
-rw-r--r--README110
-rw-r--r--README.MacOSX19
-rw-r--r--README.hp10
-rw-r--r--README.linux77
-rw-r--r--README.sgi2
-rw-r--r--README.solaris28
-rw-r--r--allchblk.c15
-rw-r--r--alloc.c25
-rw-r--r--blacklst.c12
-rw-r--r--checksums.c2
-rw-r--r--cord/cord.h327
-rw-r--r--cord/cordtest.c1
-rw-r--r--cord/ec.h70
-rw-r--r--cord/gc.h804
-rw-r--r--cord/private/cord_pos.h118
-rw-r--r--dbg_mlc.c164
-rw-r--r--dyn_load.c254
-rw-r--r--finalize.c64
-rw-r--r--gc.h804
-rw-r--r--gc.mak426
-rw-r--r--gc_alloc.h380
-rw-r--r--gc_cpp.h310
-rw-r--r--gc_hdrs.h303
-rw-r--r--gc_priv.h1884
-rw-r--r--gc_private.h1
-rw-r--r--gc_typed.h93
-rw-r--r--gcconfig.h1327
-rw-r--r--gcj_mlc.c27
-rw-r--r--headers.c4
-rw-r--r--hpux_irix_threads.c8
-rw-r--r--if_mach.c4
-rw-r--r--if_not_there.c4
-rw-r--r--include/backptr.h63
-rw-r--r--include/gc.h131
-rw-r--r--include/gc_alloc.h3
-rw-r--r--include/gc_backptr.h (renamed from backptr.h)4
-rw-r--r--include/gc_copy_descr.h26
-rw-r--r--include/gc_cpp.h8
-rw-r--r--include/gc_gcj.h19
-rw-r--r--include/gc_inl.h6
-rw-r--r--include/gc_local_alloc.h86
-rwxr-xr-xinclude/gc_nursery.h90
-rw-r--r--include/new_gc_alloc.h3
-rw-r--r--include/private/dbg_mlc.h (renamed from dbg_mlc.h)14
-rw-r--r--include/private/gc_locks.h445
-rw-r--r--include/private/gc_mark.h (renamed from gc_mark.h)124
-rw-r--r--include/private/gc_priv.h1171
-rw-r--r--include/private/gcconfig.h161
-rw-r--r--include/private/solaris_threads.h (renamed from solaris_threads.h)0
-rw-r--r--include/private/specific.h81
-rw-r--r--linux_threads.c725
-rw-r--r--mach_dep.c35
-rw-r--r--malloc.c121
-rw-r--r--mallocx.c216
-rw-r--r--mark.c494
-rw-r--r--mark_rts.c58
-rw-r--r--misc.c217
-rw-r--r--new_hblk.c115
-rw-r--r--nursery.c312
-rw-r--r--obj_map.c3
-rwxr-xr-x[-rw-r--r--]os_dep.c549
-rw-r--r--pcr_interface.c3
-rw-r--r--powerpc_macosx_mach_dep.s66
-rw-r--r--ptr_chck.c8
-rw-r--r--reclaim.c311
-rw-r--r--setjmp_t.c3
-rw-r--r--solaris_pthreads.c6
-rw-r--r--solaris_threads.c10
-rw-r--r--specific.c103
-rw-r--r--stubborn.c6
-rw-r--r--test.c416
-rw-r--r--test_cpp.cc16
-rw-r--r--threadlibs.c13
-rw-r--r--typd_mlc.c54
-rw-r--r--version.h6
-rw-r--r--weakpointer.h221
-rwxr-xr-xwin32_threads.c479
82 files changed, 6065 insertions, 9396 deletions
diff --git a/Makefile b/Makefile
index 4287a21d..796ae117 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
# Primary targets:
# gc.a - builds basic library
-# libgc.a - builds library for use with g++ "-fgc-keyword" extension
# c++ - adds C++ interface to library
# cords - adds cords (heavyweight strings) to library
# test - prints porting information, then builds basic version of gc.a,
@@ -9,7 +8,6 @@
# cord/de - builds dumb editor based on cords.
ABI_FLAG=
CC=cc $(ABI_FLAG)
-HOSTCC=$(CC)
CXX=g++ $(ABI_FLAG)
AS=as $(ABI_FLAG)
# The above doesn't work with gas, which doesn't run cpp.
@@ -17,7 +15,19 @@ AS=as $(ABI_FLAG)
# Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64)
# if you use something other than the default ABI on your machine.
-CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT
+# Redefining srcdir allows object code for the nonPCR version of the collector
+# to be generated in different directories.
+srcdir= .
+VPATH= $(srcdir)
+
+CFLAGS= -O -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INTERIOR_POINTERS -DSILENT
+
+# HOSTCC and HOSTCFLAGS are used to build executables that will be run as
+# part of the build process, i.e. on the build machine. These will usually
+# be the same as CC and CFLAGS, except in a cross-compilation environment.
+# Note that HOSTCFLAGS should include any -D flags that affect thread support.
+HOSTCC=$(CC)
+HOSTCFLAGS=$(CFLAGS)
# For dynamic library builds, it may be necessary to add flags to generate
# PIC code, e.g. -fPIC on Linux.
@@ -29,16 +39,17 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
# This causes the collector to assume that all inaccessible
# objects should have been explicitly deallocated, and reports exceptions.
# Finalization and the test program are not usable in this mode.
-# -DSOLARIS_THREADS enables support for Solaris (thr_) threads.
-# (Clients should also define SOLARIS_THREADS and then include
+# -DGC_SOLARIS_THREADS enables support for Solaris (thr_) threads.
+# (Clients should also define GC_SOLARIS_THREADS and then include
# gc.h before performing thr_ or dl* or GC_ operations.)
# Must also define -D_REENTRANT.
-# -D_SOLARIS_PTHREADS enables support for Solaris pthreads.
+# -DGC_SOLARIS_PTHREADS enables support for Solaris pthreads.
# Define SOLARIS_THREADS as well.
-# -DIRIX_THREADS enables support for Irix pthreads. See README.irix.
-# -DHPUX_THREADS enables support for HP/UX 11 pthreads.
-# Also requires -D_REENTRANT. See README.hp.
-# -DLINUX_THREADS enables support for Xavier Leroy's Linux threads.
+# -DGC_IRIX_THREADS enables support for Irix pthreads. See README.irix.
+# -DGC_HPUX_THREADS enables support for HP/UX 11 pthreads.
+# Not currently reliable.
+# Also requires -D_REENTRANT. See README.hp.
+# -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads.
# see README.linux. -D_REENTRANT may also be required.
# -DALL_INTERIOR_POINTERS allows all pointers to the interior
# of objects to be recognized. (See gc_priv.h for consequences.)
@@ -119,11 +130,23 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
# for objects allocated with the debugging allocator. If all objects
# through GC_MALLOC with GC_DEBUG defined, this allows the client
# to determine how particular or randomly chosen objects are reachable
-# for debugging/profiling purposes. The backptr.h interface is
+# for debugging/profiling purposes. The gc_backptr.h interface is
# implemented only if this is defined.
# -DGC_ASSERTIONS Enable some internal GC assertion checking. Currently
# this facility is only used in a few places. It is intended primarily
# for debugging of the garbage collector itself, but could also
+# -DDBG_HDRS_ALL Make sure that all objects have debug headers. Increases
+# the reliability (from 99.9999% to 100%) of some of the debugging
+# code (especially KEEP_BACK_PTRS). Makes -DSHORT_DBG_HDRS possible.
+# Assumes that all client allocation is done through debugging
+# allocators.
+# -DSHORT_DBG_HDRS Assume that all objects have debug headers. Shorten
+# the headers to minimize object size, at the expense of checking for
+# writes past the end of an object. This is intended for environments
+# in which most client code is written in a "safe" language, such as
+# Scheme or Java. Assumes that all client allocation is done using
+# the GC_debug_ functions (or through the macros that expand to these.
+# (Also eliminates the field for the requested object size.)
# occasionally be useful for debugging of client code. Slows down the
# collector somewhat, but not drastically.
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
@@ -143,66 +166,64 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DNO_EXECUTE_PERMISSION -DALL_INT
# -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style
# prefetch instructions. Same restrictions as USE_I686_PREFETCH.
# UNTESTED!!
-# -DUSE_LD_WRAP in combination with the gld flags listed in README.linux
+# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux
# causes the collector some system and pthread calls in a more transparent
# fashion than the usual macro-based approach. Requires GNU ld, and
# currently probably works only with Linux.
+# -DTHREAD_LOCAL_ALLOC defines GC_local_malloc(), GC_local_malloc_atomic()
+# and GC_local_gcj_malloc(). Needed for gc_gcj.h interface. These allocate
+# in a way that usually does not involve acquisition of a global lock.
+# Currently requires -DGC_LINUX_THREADS, but should be easy to port to
+# other pthreads environments. Recommended for multiprocessors.
+# -DPARALLEL_MARK allows the marker to run in multiple threads. Recommended
+# for multiprocessors. Currently requires Linux on X86 or IA64, though
+# support for other Posix platforms should be fairly easy to add,
+# if the thread implementation is otherwise supported.
#
-
-LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \
- -DREDIRECT_MALLOC=GC_malloc_uncollectable \
- -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS
-# Flags for building libgc.a -- the last two are required.
-
CXXFLAGS= $(CFLAGS)
AR= ar
RANLIB= ranlib
-# Redefining srcdir allows object code for the nonPCR version of the collector
-# to be generated in different directories. In this case, the destination directory
-# should contain a copy of the original include directory.
-srcdir = .
-VPATH = $(srcdir)
-
-OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o hpux_irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o
+OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o hpux_irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o
-CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c hpux_irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c
+CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c hpux_irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c
-CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
+CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \
- sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \
- gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \
- threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \
- gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \
+ sparc_mach_dep.s include/gc.h include/gc_typed.h \
+ include/private/gc_hdrs.h include/private/gc_priv.h \
+ include/private/gcconfig.h include/private/gc_mark.h \
+ include/gc_inl.h include/gc_inline.h gc.man \
+ threadlibs.c if_mach.c if_not_there.c gc_cpp.cc include/gc_cpp.h \
+ include/weakpointer.h include/private/gc_locks.h \
+ gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
- solaris_threads.h backptr.h hpux_test_and_clear.s include/gc_gcj.h \
- dbg_mlc.h $(CORD_SRCS)
+ include/private/solaris_threads.h include/gc_backptr.h \
+ hpux_test_and_clear.s include/gc_gcj.h \
+ include/gc_local_alloc.h include/private/dbg_mlc.h \
+ include/private/specific.h powerpc_macosx_mach_dep.s \
+ include/leak_detector.h $(CORD_SRCS)
OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \
README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \
SCoptions.amiga README.amiga README.win32 cord/README \
- cord/gc.h include/gc.h include/gc_typed.h include/cord.h \
- include/ec.h include/private/cord_pos.h include/private/gcconfig.h \
- include/private/gc_hdrs.h include/private/gc_priv.h \
- include/gc_cpp.h README.rs6000 include/backptr.h \
- include/weakpointer.h README.QUICK callprocs pc_excludes \
+ README.rs6000 README.QUICK callprocs pc_excludes \
barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \
MacOS.c EMX_MAKEFILE makefile.depend README.debugging \
- include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \
+ Mac_files/datastart.c Mac_files/dataend.c \
Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \
win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \
- README.alpha README.linux version.h Makefile.DLLs \
- WCC_MAKEFILE nursery.c include/gc_nursery.h include/gc_copy_descr.h \
- include/leak_detector.h
+ README.alpha README.linux README.MacOSX version.h Makefile.DLLs \
+ WCC_MAKEFILE
-CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \
- $(srcdir)/cord/private/cord_pos.h
+CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
+ $(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
UTILS= if_mach if_not_there threadlibs
@@ -214,7 +235,7 @@ CURSES= -lcurses -ltermlib
# the SHELL environment variable.
SHELL= /bin/sh
-SPECIALCFLAGS =
+SPECIALCFLAGS = -I$(srcdir)/include
# Alternative flags to the C compiler for mach_dep.c.
# Mach_dep.c often doesn't like optimization, and it's
# not time-critical anyway.
@@ -222,17 +243,29 @@ SPECIALCFLAGS =
all: gc.a gctest
-pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS)
+pcr: PCR-Makefile include/private/gc_private.h include/private/gc_hdrs.h \
+include/private/gc_locks.h include/gc.h include/private/gcconfig.h \
+mach_dep.o $(SRCS)
make -f PCR-Makefile depend
make -f PCR-Makefile
-$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \
- $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile
+$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: \
+ $(srcdir)/include/private/gc_priv.h \
+ $(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
+ $(srcdir)/include/gc.h \
+ $(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
+ Makefile
# The dependency on Makefile is needed. Changing
# options such as -DSILENT affects the size of GC_arrays,
# invalidating all .o files that rely on gc_priv.h
-mark.o typd_mlc.o finalize.o: $(srcdir)/gc_mark.h
+mark.o typd_mlc.o finalize.o: $(srcdir)/include/private/gc_mark.h
+
+specific.o linux_threads.o: $(srcdir)/include/private/specific.h
+
+solaris_threads.o solaris_pthreads.o: $(srcdir)/include/private/solaris_threads.h
+
+dbg_mlc.o gcj_mlc.o: $(srcdir)/include/private/dbg_mlc.h
base_lib gc.a: $(OBJS) dyn_load.o $(UTILS)
echo > base_lib
@@ -254,16 +287,16 @@ cords: $(CORD_OBJS) cord/cordtest $(UTILS)
./if_not_there dont_ar_3 $(AR) ru gc.a $(CORD_OBJS)
./if_not_there dont_ar_3 $(RANLIB) gc.a || cat /dev/null
-gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile
+gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
-test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \
+test_cpp: $(srcdir)/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
base_lib $(UTILS)
rm -f test_cpp
./if_mach HP_PA HPUX $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld `./threadlibs`
./if_not_there test_cpp $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a `./threadlibs`
-c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp
+c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp
rm -f dont_ar_4
./if_mach SPARC SUNOS5 touch dont_ar_4
./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o
@@ -310,12 +343,14 @@ liblinuxgc.so: $(OBJS) dyn_load.o
# gcc -shared -Wl,-soname=libgc.so.0 -o libgc.so.0 $(LIBOBJS) dyn_load.lo
# touch liblinuxgc.so
-mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS)
+mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s \
+ $(srcdir)/rs6000_mach_dep.s $(srcdir)/powerpc_macosx_mach_dep.s $(UTILS)
rm -f mach_dep.o
./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s
./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
+ ./if_mach POWERPC MACOSX $(AS) -o mach_dep.o $(srcdir)/powerpc_macosx_mach_dep.s
# ./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s
# alpha_mach_dep.s assumes that pointers are not saved in fp registers.
# Gcc on a 21264 can spill pointers to fp registers. Oops.
@@ -360,20 +395,21 @@ cord/de: $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(UTILS)
./if_mach SPARC DRSNX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -lucb `./threadlibs`
./if_mach HP_PA HPUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) -ldld `./threadlibs`
./if_mach RS6000 "" $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
+ ./if_mach POWERPC MACOSX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a
./if_mach I386 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
./if_mach IA64 LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses `./threadlibs`
./if_mach M68K AMIGA $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
./if_not_there cord/de $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES) `./threadlibs`
-if_mach: $(srcdir)/if_mach.c $(srcdir)/gcconfig.h
- $(HOSTCC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c
+if_mach: $(srcdir)/if_mach.c $(srcdir)/include/private/gcconfig.h
+ $(HOSTCC) $(HOSTCFLAGS) -o if_mach $(srcdir)/if_mach.c
-threadlibs: $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile
- $(HOSTCC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c
+threadlibs: $(srcdir)/threadlibs.c $(srcdir)/include/private/gcconfig.h Makefile
+ $(HOSTCC) $(HOSTCFLAGS) -o threadlibs $(srcdir)/threadlibs.c
if_not_there: $(srcdir)/if_not_there.c
- $(HOSTCC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c
+ $(HOSTCC) $(HOSTCFLAGS) -o if_not_there $(srcdir)/if_not_there.c
clean:
rm -f gc.a *.o gctest gctest_dyn_link test_cpp \
@@ -390,7 +426,7 @@ gctest: test.o gc.a $(UTILS)
# If an optimized setjmp_test generates a segmentation fault,
# odds are your compiler is broken. Gctest may still work.
# Try compiling setjmp_t.c unoptimized.
-setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/gc.h $(UTILS)
+setjmp_test: $(srcdir)/setjmp_t.c $(srcdir)/include/gc.h $(UTILS)
$(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c
test: KandRtest cord/cordtest
@@ -445,6 +481,8 @@ gctest_dyn_link: test.o libgc.so
gctest_irix_dyn_link: test.o libirixgc.so
$(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc
+# The following appear to be dead, especially since libgc_globals.h
+# is apparently lost.
test_dll.o: test.c libgc_globals.h
$(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o
diff --git a/Makefile.dj b/Makefile.dj
index 54f77db9..19d1bdbe 100644
--- a/Makefile.dj
+++ b/Makefile.dj
@@ -1,3 +1,7 @@
+# This Makefile is intended only for DJGPP use.
+# It is mainly a copy of the main Makefile, but tends to get out of sync
+# with it. A merge would probably be appropriate.
+
# Primary targets:
# gc.a - builds basic library
# libgc.a - builds library for use with g++ "-fgc-keyword" extension
@@ -20,29 +24,18 @@ AS=gcc -c -x assembler-with-cpp $(ABI_FLAG)
CXXLD=gxx $(ABI_FLAG)
EXE_SUFFIX=.exe
-CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT
+srcdir= .
+VPATH= $(srcdir)
-# For dynamic library builds, it may be necessary to add flags to generate
-# PIC code, e.g. -fPIC on Linux.
+CFLAGS= -O -I$(srcdir)/include -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT
# Setjmp_test may yield overly optimistic results when compiled
# without optimization.
# -DSILENT disables statistics printing, and improves performance.
-# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
-# altered stubborn objects, at substantial performance cost.
-# Use only for incremental collector debugging.
-# -DFIND_LEAK causes the collector to assume that all inaccessible
+# -DFIND_LEAK causes GC_find_leak to be initially set.
+# This causes the collector to assume that all inaccessible
# objects should have been explicitly deallocated, and reports exceptions.
# Finalization and the test program are not usable in this mode.
-# -DSOLARIS_THREADS enables support for Solaris (thr_) threads.
-# (Clients should also define SOLARIS_THREADS and then include
-# gc.h before performing thr_ or dl* or GC_ operations.)
-# Must also define -D_REENTRANT.
-# -D_SOLARIS_PTHREADS enables support for Solaris pthreads.
-# Define SOLARIS_THREADS as well.
-# -DIRIX_THREADS enables support for Irix pthreads. See README.irix.
-# -DLINUX_THREADS enables support for Xavier Leroy's Linux threads.
-# see README.linux. -D_REENTRANT may also be required.
# -DALL_INTERIOR_POINTERS allows all pointers to the interior
# of objects to be recognized. (See gc_priv.h for consequences.)
# -DSMALL_CONFIG tries to tune the collector for small heap sizes,
@@ -62,6 +55,8 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
# implementations, and it sometimes has a significant performance
# impact. However, it is dangerous for many not-quite-ANSI C
# programs that call things like printf in asynchronous signal handlers.
+# This is on by default. Turning it off has not been extensively tested with
+# compilers that reorder stores. It should have been.
# -DNO_EXECUTE_PERMISSION may cause some or all of the heap to not
# have execute permission, i.e. it may be impossible to execute
# code from the heap. Currently this only affects the incremental
@@ -89,9 +84,12 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
# finalize.c). Objects reachable from finalizable objects will be marked
# in a sepearte postpass, and hence their memory won't be reclaimed.
# Not recommended unless you are implementing a language that specifies
-# these semantics.
+# these semantics. Since 5.0, determines only only the initial value
+# of GC_java_finalization variable.
# -DFINALIZE_ON_DEMAND causes finalizers to be run only in response
# to explicit GC_invoke_finalizers() calls.
+# In 5.0 this became runtime adjustable, and this only determines the
+# initial value of GC_finalize_on_demand.
# -DATOMIC_UNCOLLECTABLE includes code for GC_malloc_atomic_uncollectable.
# This is useful if either the vendor malloc implementation is poor,
# or if REDIRECT_MALLOC is used.
@@ -100,76 +98,100 @@ CFLAGS= -O -DATOMIC_UNCOLLECTABLE -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXEC
# kind of object. For the incremental collector it makes sense to match
# the most likely page size. Otherwise large values result in more
# fragmentation, but generally better performance for large heaps.
-# -DUSE_MMAP use MMAP instead of sbrk to get new memory.
-# Works for Solaris and Irix.
-# -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than
-# GC_scratch_alloc() to get stack memory.
# -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever
# the garbage collector detects a value that looks almost, but not quite,
# like a pointer, print both the address containing the value, and the
# value of the near-bogus-pointer. Can be used to identifiy regions of
# memory that are likely to contribute misidentified pointers.
-# -DOLD_BLOCK_ALLOC Use the old, possibly faster, large block
-# allocation strategy. The new strategy tries harder to minimize
-# fragmentation, sometimes at the expense of spending more time in the
-# large block allocator and/or collecting more frequently.
-# If you expect the allocator to promtly use an explicitly expanded
-# heap, this is highly recommended.
-#
-
-
+# -DKEEP_BACK_PTRS Add code to save back pointers in debugging headers
+# for objects allocated with the debugging allocator. If all objects
+# through GC_MALLOC with GC_DEBUG defined, this allows the client
+# to determine how particular or randomly chosen objects are reachable
+# for debugging/profiling purposes. The gc_backptr.h interface is
+# implemented only if this is defined.
+# -DGC_ASSERTIONS Enable some internal GC assertion checking. Currently
+# this facility is only used in a few places. It is intended primarily
+# for debugging of the garbage collector itself, but could also
+# -DDBG_HDRS_ALL Make sure that all objects have debug headers. Increases
+# the reliability (from 99.9999% to 100%) of some of the debugging
+# code (especially KEEP_BACK_PTRS). Makes -DSHORT_DBG_HDRS possible.
+# Assumes that all client allocation is done through debugging
+# allocators.
+# -DSHORT_DBG_HDRS Assume that all objects have debug headers. Shorten
+# the headers to minimize object size, at the expense of checking for
+# writes past the end of an object. This is intended for environments
+# in which most client code is written in a "safe" language, such as
+# Scheme or Java. Assumes that all client allocation is done using
+# the GC_debug_ functions (or through the macros that expand to these.
+# (Also eliminates the field for the requested object size.)
+# occasionally be useful for debugging of client code. Slows down the
+# collector somewhat, but not drastically.
+# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
+# altered stubborn objects, at substantial performance cost.
+# Use only for debugging of the incremental collector.
+# -DGC_GCJ_SUPPORT includes support for gcj (and possibly other systems
+# that include a pointer to a type descriptor in each allocated object).
+# Building this way requires an ANSI C compiler.
+# -DUSE_I686_PREFETCH causes the collector to issue Pentium III style
+# prefetch instructions. No effect except on X86 Linux platforms.
+# Assumes a very recent gcc-compatible compiler and assembler.
+# (Gas prefetcht0 support was added around May 1999.)
+# Empirically the code appears to still run correctly on Pentium II
+# processors, though with no performance benefit. May not run on other
+# X86 processors? In some cases this improves performance by
+# 15% or so.
+# -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style
+# prefetch instructions. Same restrictions as USE_I686_PREFETCH.
+# UNTESTED!!
+# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux
+# causes the collector some system and pthread calls in a more transparent
+# fashion than the usual macro-based approach. Requires GNU ld, and
+# currently probably works only with Linux.
-LIBGC_CFLAGS= -O -DNO_SIGNALS -DSILENT \
- -DREDIRECT_MALLOC=GC_malloc_uncollectable \
- -DDONT_ADD_BYTE_AT_END -DALL_INTERIOR_POINTERS
-# Flags for building libgc.a -- the last two are required.
CXXFLAGS= $(CFLAGS) -DOPERATOR_NEW_ARRAY
AR= ar
RANLIB= ranlib
-# Redefining srcdir allows object code for the nonPCR version of the collector
-# to be generated in different directories. In this case, the destination directory
-# should contain a copy of the original include directory.
-srcdir = .
-VPATH = $(srcdir)
-
-OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o
+OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o hpux_irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o
-CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c
+CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c hpux_irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c
-CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c cord/cord.h cord/ec.h cord/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
+CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC cord/SCOPTIONS.amiga cord/SMakefile.amiga
CORD_OBJS= cord/cordbscs.o cord/cordxtra.o cord/cordprnt.o
SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \
- sparc_mach_dep.s gc.h gc_typed.h gc_hdrs.h gc_priv.h gc_private.h \
- gcconfig.h gc_mark.h include/gc_inl.h include/gc_inline.h gc.man \
- threadlibs.c if_mach.c if_not_there.c gc_cpp.cc gc_cpp.h weakpointer.h \
- gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h gc_alloc.h \
+ sparc_mach_dep.s include/gc.h include/gc_typed.h \
+ include/private/gc_hdrs.h include/private/gc_priv.h \
+ include/private/gcconfig.h include/private/gc_mark.h \
+ include/gc_inl.h include/gc_inline.h gc.man \
+ threadlibs.c if_mach.c if_not_there.c gc_cpp.cc include/gc_cpp.h \
+ include/weakpointer.h include/private/gc_locks.h \
+ gcc_support.c mips_ultrix_mach_dep.s include/gc_alloc.h \
include/new_gc_alloc.h include/javaxfc.h sparc_sunos4_mach_dep.s \
- solaris_threads.h $(CORD_SRCS)
+ include/private/solaris_threads.h include/gc_backptr.h \
+ hpux_test_and_clear.s include/gc_gcj.h \
+ include/gc_local_alloc.h include/private/dbg_mlc.h \
+ include/private/specific.h powerpc_macosx_mach_dep.s \
+ include/leak_detector.h $(CORD_SRCS)
OTHER_FILES= Makefile PCR-Makefile OS2_MAKEFILE NT_MAKEFILE BCC_MAKEFILE \
README test.c test_cpp.cc setjmp_t.c SMakefile.amiga \
SCoptions.amiga README.amiga README.win32 cord/README \
- cord/gc.h include/gc.h include/gc_typed.h include/cord.h \
- include/ec.h include/private/cord_pos.h include/private/gcconfig.h \
- include/private/gc_hdrs.h include/private/gc_priv.h \
- include/gc_cpp.h README.rs6000 \
- include/weakpointer.h README.QUICK callprocs pc_excludes \
+ README.rs6000 README.QUICK callprocs pc_excludes \
barrett_diagram README.OS2 README.Mac MacProjects.sit.hqx \
MacOS.c EMX_MAKEFILE makefile.depend README.debugging \
- include/gc_cpp.h Mac_files/datastart.c Mac_files/dataend.c \
+ Mac_files/datastart.c Mac_files/dataend.c \
Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
add_gc_prefix.c README.solaris2 README.sgi README.hp README.uts \
win32_threads.c NT_THREADS_MAKEFILE gc.mak README.dj Makefile.dj \
- README.alpha README.linux version.h Makefile.DLLs \
- WCC_MAKEFILE
+ README.alpha README.linux README.MacOSX version.h Makefile.DLLs \
+ WCC_MAKEFILE nursery.c include/gc_nursery.h include/gc_copy_descr.h
-CORD_INCLUDE_FILES= $(srcdir)/gc.h $(srcdir)/cord/cord.h $(srcdir)/cord/ec.h \
- $(srcdir)/cord/private/cord_pos.h
+CORD_INCLUDE_FILES= $(srcdir)/include/gc.h $(srcdir)/include/cord.h \
+ $(srcdir)/include/ec.h $(srcdir)/include/private/cord_pos.h
UTILS= if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
@@ -189,12 +211,12 @@ SPECIALCFLAGS =
all: gc.a gctest$(EXE_SUFFIX)
-pcr: PCR-Makefile gc_private.h gc_hdrs.h gc.h gcconfig.h mach_dep.o $(SRCS)
- make -f PCR-Makefile depend
- make -f PCR-Makefile
-
-$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: $(srcdir)/gc_priv.h $(srcdir)/gc_hdrs.h $(srcdir)/gc.h \
- $(srcdir)/gcconfig.h $(srcdir)/gc_typed.h Makefile
+$(OBJS) test.o dyn_load.o dyn_load_sunos53.o: \
+ $(srcdir)/include/private/gc_priv.h \
+ $(srcdir)/include/private/gc_hdrs.h $(srcdir)/include/private/gc_locks.h \
+ $(srcdir)/include/gc.h \
+ $(srcdir)/include/private/gcconfig.h $(srcdir)/include/gc_typed.h \
+ Makefile
# The dependency on Makefile is needed. Changing
# options such as -DSILENT affects the size of GC_arrays,
# invalidating all .o files that rely on gc_priv.h
@@ -217,17 +239,17 @@ cords: $(CORD_OBJS) cord/cordtest$(EXE_SUFFIX) $(UTILS)
./if_not_there on_sparc_sunos5_3 $(AR) ru gc.a $(CORD_OBJS)
-./if_not_there on_sparc_sunos5_3 $(RANLIB) gc.a
-gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/gc_cpp.h $(srcdir)/gc.h Makefile
+gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h Makefile
$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
-test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/gc_cpp.h gc_cpp.o $(srcdir)/gc.h \
+test_cpp$(EXE_SUFFIX): $(srcdir)/test_cpp.cc $(srcdir)/include/gc_cpp.h gc_cpp.o $(srcdir)/include/gc.h \
base_lib $(UTILS)
rm -f test_cpp test_cpp$(EXE_SUFFIX)
./if_mach HP_PA "" $(CXX) $(CXXFLAGS) -o test_cpp $(srcdir)/test_cpp.cc gc_cpp.o gc.a -ldld
./if_not_there test_cpp$(EXE_SUFFIX) $(CXXLD) $(CXXFLAGS) -o test_cpp$(EXE_SUFFIX) $(srcdir)/test_cpp.cc gc_cpp.o gc.a
rm -f test_cpp
-c++: gc_cpp.o $(srcdir)/gc_cpp.h test_cpp$(EXE_SUFFIX)
+c++: gc_cpp.o $(srcdir)/include/gc_cpp.h test_cpp$(EXE_SUFFIX)
rm -f on_sparc_sunos5_4
./if_mach SPARC SUNOS5 touch on_sparc_sunos5_4
./if_mach SPARC SUNOS5 $(AR) rus gc.a gc_cpp.o
@@ -259,12 +281,14 @@ liblinuxgc.so: $(OBJS) dyn_load.o
gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o -lo
ln liblinuxgc.so libgc.so
-mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s $(srcdir)/rs6000_mach_dep.s $(UTILS)
+mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ultrix_mach_dep.s \
+ $(srcdir)/rs6000_mach_dep.s $(srcdir)/powerpc_macosx_mach_dep.s $(UTILS)
rm -f mach_dep.o
./if_mach MIPS IRIX5 $(AS) -o mach_dep.o $(srcdir)/mips_sgi_mach_dep.s
./if_mach MIPS RISCOS $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach MIPS ULTRIX $(AS) -o mach_dep.o $(srcdir)/mips_ultrix_mach_dep.s
./if_mach RS6000 "" $(AS) -o mach_dep.o $(srcdir)/rs6000_mach_dep.s
+ ./if_mach POWERPC MACOSX $(AS) -o mach_dep.o $(srcdir)/powerpc_macosx_mach_dep.s
./if_mach ALPHA "" $(AS) -o mach_dep.o $(srcdir)/alpha_mach_dep.s
./if_mach SPARC SUNOS5 $(AS) -o mach_dep.o $(srcdir)/sparc_mach_dep.s
./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s
@@ -312,20 +336,17 @@ cord/de$(EXE_SUFFIX): $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $
./if_mach ALPHA LINUX $(CC) $(CFLAGS) -o cord/de $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a -lcurses
./if_not_there cord/de$(EXE_SUFFIX) $(CC) $(CFLAGS) -o cord/de$(EXE_SUFFIX) $(srcdir)/cord/de.c cord/cordbscs.o cord/cordxtra.o gc.a $(CURSES)
-if_mach$(EXE_SUFFIX): $(srcdir)/if_mach.c $(srcdir)/gcconfig.h
+if_mach$(EXE_SUFFIX): $(srcdir)/if_mach.c $(srcdir)/include/private/gcconfig.h
rm -f if_mach if_mach$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o if_mach $(srcdir)/if_mach.c
- rm -f if_mach
-threadlibs$(EXE_SUFFIX): $(srcdir)/threadlibs.c $(srcdir)/gcconfig.h Makefile
+threadlibs$(EXE_SUFFIX): $(srcdir)/threadlibs.c $(srcdir)include/private/gcconfig.h Makefile
rm -f threadlibs threadlibs$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o threadlibs $(srcdir)/threadlibs.c
- rm -f threadlibs
if_not_there$(EXE_SUFFIX): $(srcdir)/if_not_there.c
rm -f if_not_there if_not_there$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o if_not_there $(srcdir)/if_not_there.c
- rm -f if_not_there
# Clean removes *.o several times,
# because as the first one doesn't seem to get them all!
@@ -352,7 +373,7 @@ gctest$(EXE_SUFFIX): test.o gc.a if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
# If an optimized setjmp_test generates a segmentation fault,
# odds are your compiler is broken. Gctest may still work.
# Try compiling setjmp_t.c unoptimized.
-setjmp_test$(EXE_SUFFIX): $(srcdir)/setjmp_t.c $(srcdir)/gc.h \
+setjmp_test$(EXE_SUFFIX): $(srcdir)/setjmp_t.c $(srcdir)/include/gc.h \
if_mach$(EXE_SUFFIX) if_not_there$(EXE_SUFFIX)
rm -f setjmp_test$(EXE_SUFFIX)
$(CC) $(CFLAGS) -o setjmp_test $(srcdir)/setjmp_t.c
@@ -377,21 +398,6 @@ gc.tar: $(SRCS) $(OTHER_FILES) add_gc_prefix
pc_gc.tar: $(SRCS) $(OTHER_FILES)
tar cvfX pc_gc.tar pc_excludes $(SRCS) $(OTHER_FILES)
-floppy: pc_gc.tar
- -mmd a:/cord
- -mmd a:/cord/private
- -mmd a:/include
- -mmd a:/include/private
- mkdir /tmp/pc_gc
- cat pc_gc.tar | (cd /tmp/pc_gc; tar xvf -)
- -mcopy -tmn /tmp/pc_gc/* a:
- -mcopy -tmn /tmp/pc_gc/cord/* a:/cord
- -mcopy -mn /tmp/pc_gc/cord/de_win.ICO a:/cord
- -mcopy -tmn /tmp/pc_gc/cord/private/* a:/cord/private
- -mcopy -tmn /tmp/pc_gc/include/* a:/include
- -mcopy -tmn /tmp/pc_gc/include/private/* a:/include/private
- rm -r /tmp/pc_gc
-
gc.tar.Z: gc.tar
compress gc.tar
@@ -408,9 +414,6 @@ ABSDIR = `pwd`
gctest_dyn_link: test.o libgc.so
$(CC) -L$(ABSDIR) -R$(ABSDIR) -o gctest_dyn_link test.o -lgc -ldl -lthread
-gctest_irix_dyn_link: test.o libirixgc.so
- $(CC) -L$(ABSDIR) -o gctest_irix_dyn_link test.o -lirixgc
-
test_dll.o: test.c libgc_globals.h
$(CC) $(CFLAGS) -DGC_USE_DLL -c test.c -o test_dll.o
@@ -422,15 +425,3 @@ SYM_PREFIX-libgc=GC
# Uncomment the following line to build a GNU win32 DLL
# include Makefile.DLLs
-reserved_namespace: $(SRCS)
- for file in $(SRCS) test.c test_cpp.cc; do \
- sed s/GC_/_GC_/g < $$file > tmp; \
- cp tmp $$file; \
- done
-
-user_namespace: $(SRCS)
- for file in $(SRCS) test.c test_cpp.cc; do \
- sed s/_GC_/GC_/g < $$file > tmp; \
- cp tmp $$file; \
- done
-
diff --git a/NT_MAKEFILE b/NT_MAKEFILE
index a642262a..842b33ed 100644
--- a/NT_MAKEFILE
+++ b/NT_MAKEFILE
@@ -10,12 +10,12 @@ OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_r
all: gctest.exe cord\de.exe test_cpp.exe
.c.obj:
- $(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
+ $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DSILENT -DALL_INTERIOR_POINTERS -D__STDC__ $*.c /Fo$*.obj
.cpp.obj:
- $(cc) $(cdebug) $(cflags) $(cvars) -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
+ $(cc) $(cdebug) $(cflags) $(cvars) -Iinclude -DSILENT -DALL_INTERIOR_POINTERS $*.CPP /Fo$*.obj
-$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
+$(OBJS) test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_mark.h
gc.lib: $(OBJS)
lib /MACHINE:i386 /out:gc.lib $(OBJS)
@@ -32,7 +32,7 @@ gctest.exe: test.obj gc.lib
cord\de_win.rbj: cord\de_win.res
cvtres -$(CPU) cord\de_win.res -o cord\de_win.rbj
-cord\de.obj cord\de_win.obj: cord\cord.h cord\private\cord_pos.h cord\de_win.h cord\de_cmds.h
+cord\de.obj cord\de_win.obj: include\cord.h include\private\cord_pos.h cord\de_win.h cord\de_cmds.h
cord\de_win.res: cord\de_win.rc cord\de_win.h cord\de_cmds.h
$(rc) $(rcvars) -r -fo cord\de_win.res $(cvars) cord\de_win.rc
@@ -41,7 +41,7 @@ cord\de_win.res: cord\de_win.rc cord\de_win.h cord\de_cmds.h
cord\de.exe: cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib
$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:cord\de.exe cord\cordbscs.obj cord\cordxtra.obj cord\de.obj cord\de_win.obj cord\de_win.rbj gc.lib $(guilibs)
-gc_cpp.obj: gc_cpp.h gc.h
+gc_cpp.obj: include\gc_cpp.h include\gc.h
gc_cpp.cpp: gc_cpp.cc
copy gc_cpp.cc gc_cpp.cpp
@@ -52,7 +52,7 @@ test_cpp.cpp: test_cpp.cc
# This generates the C++ test executable. The executable expects
# a single numeric argument, which is the number of iterations.
# The output appears in the file "gc.log".
-test_cpp.exe: test_cpp.obj gc_cpp.h gc.h gc.lib
+test_cpp.exe: test_cpp.obj include\gc_cpp.h include\gc.h gc.lib
$(link) -debug:full -debugtype:cv $(guiflags) -stack:16384 -out:test_cpp.exe test_cpp.obj gc.lib $(guilibs)
diff --git a/NT_THREADS_MAKEFILE b/NT_THREADS_MAKEFILE
index 0fd22b70..08478f03 100644
--- a/NT_THREADS_MAKEFILE
+++ b/NT_THREADS_MAKEFILE
@@ -111,8 +111,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
+# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
"WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
@@ -289,8 +289,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
/D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\
/Fd"$(INTDIR)/" /c
@@ -418,8 +418,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
+# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
"ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\gctest\Release/
@@ -505,7 +505,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
/D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\gctest\Debug/
@@ -596,7 +596,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
"ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\cord\Release/
CPP_SBRS=.\.
@@ -688,7 +688,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D\
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /I include /D "_DEBUG" /D "WIN32" /D\
"_WINDOWS" /D "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\cord\Debug/
@@ -768,10 +768,10 @@ SOURCE=.\reclaim.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_RECLA=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_RECLA=\
@@ -788,10 +788,10 @@ NODEP_CPP_RECLA=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_RECLA=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_RECLA=\
@@ -816,10 +816,10 @@ SOURCE=.\os_dep.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_OS_DE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -840,10 +840,10 @@ NODEP_CPP_OS_DE=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_OS_DE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -872,10 +872,10 @@ SOURCE=.\misc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MISC_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MISC_=\
@@ -893,10 +893,10 @@ NODEP_CPP_MISC_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MISC_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MISC_=\
@@ -922,10 +922,10 @@ SOURCE=.\mark_rts.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MARK_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_=\
@@ -942,10 +942,10 @@ NODEP_CPP_MARK_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MARK_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_=\
@@ -970,10 +970,10 @@ SOURCE=.\mach_dep.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MACH_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MACH_=\
@@ -990,10 +990,10 @@ NODEP_CPP_MACH_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MACH_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MACH_=\
@@ -1018,10 +1018,10 @@ SOURCE=.\headers.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_HEADE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_HEADE=\
@@ -1038,10 +1038,10 @@ NODEP_CPP_HEADE=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_HEADE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_HEADE=\
@@ -1066,10 +1066,10 @@ SOURCE=.\alloc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_ALLOC=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLOC=\
@@ -1086,10 +1086,10 @@ NODEP_CPP_ALLOC=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_ALLOC=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLOC=\
@@ -1114,10 +1114,10 @@ SOURCE=.\allchblk.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_ALLCH=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLCH=\
@@ -1134,10 +1134,10 @@ NODEP_CPP_ALLCH=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_ALLCH=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLCH=\
@@ -1162,10 +1162,10 @@ SOURCE=.\stubborn.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_STUBB=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_STUBB=\
@@ -1182,10 +1182,10 @@ NODEP_CPP_STUBB=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_STUBB=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_STUBB=\
@@ -1210,10 +1210,10 @@ SOURCE=.\obj_map.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_OBJ_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_OBJ_M=\
@@ -1230,10 +1230,10 @@ NODEP_CPP_OBJ_M=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_OBJ_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_OBJ_M=\
@@ -1258,10 +1258,10 @@ SOURCE=.\new_hblk.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_NEW_H=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_NEW_H=\
@@ -1278,10 +1278,10 @@ NODEP_CPP_NEW_H=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_NEW_H=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_NEW_H=\
@@ -1306,11 +1306,11 @@ SOURCE=.\mark.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MARK_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_C=\
@@ -1327,11 +1327,11 @@ NODEP_CPP_MARK_C=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MARK_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_C=\
@@ -1356,10 +1356,10 @@ SOURCE=.\malloc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MALLO=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLO=\
@@ -1376,10 +1376,10 @@ NODEP_CPP_MALLO=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MALLO=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLO=\
@@ -1404,10 +1404,10 @@ SOURCE=.\mallocx.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MALLX=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLX=\
@@ -1424,10 +1424,10 @@ NODEP_CPP_MALLX=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MALLX=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLX=\
@@ -1452,11 +1452,11 @@ SOURCE=.\finalize.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_FINAL=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_FINAL=\
@@ -1473,11 +1473,11 @@ NODEP_CPP_FINAL=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_FINAL=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_FINAL=\
@@ -1502,10 +1502,10 @@ SOURCE=.\dbg_mlc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_DBG_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_DBG_M=\
@@ -1522,10 +1522,10 @@ NODEP_CPP_DBG_M=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_DBG_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_DBG_M=\
@@ -1550,10 +1550,10 @@ SOURCE=.\blacklst.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_BLACK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_BLACK=\
@@ -1570,10 +1570,10 @@ NODEP_CPP_BLACK=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_BLACK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_BLACK=\
@@ -1598,12 +1598,12 @@ SOURCE=.\typd_mlc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_TYPD_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TYPD_=\
@@ -1620,12 +1620,12 @@ NODEP_CPP_TYPD_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_TYPD_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TYPD_=\
@@ -1650,11 +1650,11 @@ SOURCE=.\ptr_chck.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_PTR_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_PTR_C=\
@@ -1671,11 +1671,11 @@ NODEP_CPP_PTR_C=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_PTR_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_PTR_C=\
@@ -1700,10 +1700,10 @@ SOURCE=.\dyn_load.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_DYN_L=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -1723,10 +1723,10 @@ NODEP_CPP_DYN_L=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_DYN_L=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -1754,10 +1754,10 @@ SOURCE=.\win32_threads.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_WIN32=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_WIN32=\
@@ -1774,10 +1774,10 @@ NODEP_CPP_WIN32=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_WIN32=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_WIN32=\
@@ -1802,10 +1802,10 @@ SOURCE=.\checksums.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_CHECK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_CHECK=\
@@ -1822,10 +1822,10 @@ NODEP_CPP_CHECK=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_CHECK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_CHECK=\
@@ -1878,11 +1878,11 @@ NODEP_CPP_CHECK=\
SOURCE=.\test.c
DEP_CPP_TEST_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TEST_=\
@@ -1944,13 +1944,13 @@ NODEP_CPP_TEST_=\
SOURCE=.\cord\de_win.c
DEP_CPP_DE_WI=\
- ".\cord\cord.h"\
+ ".\include\cord.h"\
".\cord\de_cmds.h"\
".\cord\de_win.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_DE_WI=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -1975,13 +1975,13 @@ NODEP_CPP_DE_WI=\
SOURCE=.\cord\de.c
DEP_CPP_DE_C2e=\
- ".\cord\cord.h"\
+ ".\include\cord.h"\
".\cord\de_cmds.h"\
".\cord\de_win.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_DE_C2e=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -2006,12 +2006,12 @@ NODEP_CPP_DE_C2e=\
SOURCE=.\cord\cordxtra.c
DEP_CPP_CORDX=\
- ".\cord\cord.h"\
- ".\cord\ec.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\cord.h"\
+ ".\include\ec.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_CORDX=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -2036,11 +2036,11 @@ NODEP_CPP_CORDX=\
SOURCE=.\cord\cordbscs.c
DEP_CPP_CORDB=\
- ".\cord\cord.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\cord.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_CORDB=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
diff --git a/OS2_MAKEFILE b/OS2_MAKEFILE
index 7b816218..690598d6 100644
--- a/OS2_MAKEFILE
+++ b/OS2_MAKEFILE
@@ -17,7 +17,7 @@ CFLAGS= /O /Q /DSILENT /DSMALL_CONFIG /DALL_INTERIOR_POINTERS
all: $(OBJS) gctest.exe cord\cordtest.exe
-$(OBJS) test.obj: gc_priv.h gc_hdrs.h gc.h
+$(OBJS) test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h
## ERASE THE LIB FIRST - if it is already there then this command will fail
## (make sure its there or erase will fail!)
@@ -32,14 +32,14 @@ mach_dep.obj: mach_dep.c
gctest.exe: test.obj gc.lib
$(CC) $(CFLAGS) /B"/STACK:524288" /Fegctest test.obj gc.lib
-cord\cordbscs.obj: cord\cordbscs.c cord\cord.h cord\private\cord_pos.h
+cord\cordbscs.obj: cord\cordbscs.c include\cord.h include\private\cord_pos.h
$(CC) $(CFLAGS) /C /Focord\cordbscs cord\cordbscs.c
-cord\cordxtra.obj: cord\cordxtra.c cord\cord.h cord\private\cord_pos.h cord\ec.h
+cord\cordxtra.obj: cord\cordxtra.c include\cord.h include\private\cord_pos.h include\ec.h
$(CC) $(CFLAGS) /C /Focord\cordxtra cord\cordxtra.c
-cord\cordprnt.obj: cord\cordprnt.c cord\cord.h cord\private\cord_pos.h cord\ec.h
+cord\cordprnt.obj: cord\cordprnt.c include\cord.h include\private\cord_pos.h include\ec.h
$(CC) $(CFLAGS) /C /Focord\cordprnt cord\cordprnt.c
-cord\cordtest.exe: cord\cordtest.c cord\cord.h cord\private\cord_pos.h cord\ec.h $(CORDOBJS) gc.lib
+cord\cordtest.exe: cord\cordtest.c include\cord.h include\private\cord_pos.h include\ec.h $(CORDOBJS) gc.lib
$(CC) $(CFLAGS) /B"/STACK:65536" /Fecord\cordtest cord\cordtest.c gc.lib $(CORDOBJS)
diff --git a/README b/README
index d2743163..2ab1f7ea 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ Permission to modify the code and to distribute modified code is granted,
provided the above notices are retained, and a notice that the code was
modified is included with the above copyright notice.
-This is version 5.3 of a conservative garbage collector for C and C++.
+This is version 6.0alpha3 of a conservative garbage collector for C and C++.
You might find a more recent version of this at
@@ -31,12 +31,12 @@ Some other contributors:
More recent contributors are mentioned in the modification history at the
end of this file. My apologies for any omissions.
-The SPARC specific code was contributed by Mark Weiser
-(weiser@parc.xerox.com). The Encore Multimax modifications were supplied by
+The SPARC specific code was contributed by Mark Weiser.
+The Encore Multimax modifications were supplied by
Kevin Kenny (kenny@m.cs.uiuc.edu). The adaptation to the RT is largely due
-to Vernon Lee (scorpion@rice.edu), on machines made available by IBM.
+to Vernon Lee, on machines made available by IBM.
Much of the HP specific code and a number of good suggestions for improving the
-generic code are due to Walter Underwood (wunder@hp-ses.sde.hp.com).
+generic code are due to Walter Underwood.
Robert Brazile (brazile@diamond.bbn.com) originally supplied the ULTRIX code.
Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk)
subsequently provided updates and information on variation between ULTRIX
@@ -1576,6 +1576,8 @@ Since 5.0 alpha4
Serrano for helping me debug this by email.) Changed the IA64 code to
do something similar for similar reasons.
+[5.0alpha5 doesn't really exist, but it may have escaped.]
+
Since 5.0alpha6:
- -DREDIRECT_MALLOC was broken in alpha6. Fixed.
- Cleaned up gc_ccp.h slightly, thus also causing the HP C++ compiler to
@@ -1616,8 +1618,6 @@ Since 5.0
- The block nearly full tests in reclaim.c were not correct for 64 bit
environments. This could result in unnecessary heap growth under unlikely
conditions.
- - Removed use of CLEAR_DOUBLE from generic reclaim code, since odd sizes
- could occur.
Since 5.1
- dyn_load.c declared GC_scratch_last_end_ptr as an extern even if it
@@ -1633,7 +1633,7 @@ Since 5.1
- The two copies of gc_hdrs.h had diverged. Made one a link to the other
again.
-Since 5.2
+Since 5.2 (A few 5.2 patches are not in 6.0alpha1)
- Fixed _end declaration for OSF1.
- There were lots of spurious leak reports in leak detection mode, caused
by the fact that some pages were not being swept, and hence unmarked
@@ -1642,8 +1642,96 @@ Since 5.2
- Added the GetExitCodeThread to Win32 GC_stop_world to (mostly) work
around a Windows 95 GetOpenFileName problem. (Thanks to Jacob Navia.)
+Since 5.3 (A few 5.3 patches are not in 6.0alpha2)
+ - Added HP/PA prefetch support.
+ - Added -DDBG_HDRS_ALL and -DSHORT_DBG_HDRS to reduce the cost and improve
+ the reliability of generating pointer backtrace information, e.g. in
+ the Bigloo environment.
+ - Added parallel marking support (-DPARALLEL_MARK). This currently
+ works only under IA32 and IA64 Linux, but it shouldn't be hard to adapt
+ to other platforms. This is intended to be a lighter-weight (less
+ new code, probably not as scalable) solution than the work by Toshio Endo
+ et al, at the University of Tokyo. A number of their ideas were
+ reused, though the code wasn't, and the underlying data structure
+ is significantly different. In particular, we keep the global mark
+ stack as a single shared data structure, but most of the work is done
+ on smaller thread-local mark stacks.
+ - Changed GC_malloc_many to be cheaper, and to require less mutual exclusion
+ with -DPARALLEL_MARK.
+ - Added full support for thread local allocation under Linux
+ (-DTHREAD_LOCAL_ALLOC). This is a thin veneer on GC_malloc_many, and
+ should be easily portable to other platforms, especially those that
+ support pthreads.
+ - CLEAR_DOUBLE was not always getting invoked when it should have been.
+ - GC_gcj_malloc and friends used different out of memory handling than
+ everything else, probably because I forgot about one when I implemented
+ the other. They now both call GC_oom_fn(), not GC_oom_action().
+ - Integrated Jakub Jelinek's fixes for Linux/SPARC.
+ - Moved GC_objfreelist, GC_aobjfreelist, and GC_words_allocd out of
+ GC_arrays, and separately registered the first two as excluded roots.
+ This makes code compiled with gc_inl.h less dependent on the
+ collector version. (It would be nice to remove the inclusion of
+ gc_priv.h by gc_inl.h completely, but we're not there yet. The
+ locking definitions in gc_priv.h are still referenced.)
+ This change was later coniditoned on SEPARATE_GLOBALS, which
+ is not defined by default, since it involves a performance hit.
+ - Register GC_obj_kinds separately as an excluded root region. The
+ attempt to register it with GC_arrays was usually failing. (This wasn't
+ serious, but seemed to generate some confusion.)
+ - Moved backptr.h to gc_backptr.h.
+
+Since 6.0alpha1
+ - Added USE_MARK_BYTES to reduce the need for compare-and-swap on platforms
+ for which that's expensive.
+ - Fixed a locking bug ib GC_gcj_malloc and some locking assertion problems.
+ - Added a missing volatile to OR_WORD and renamed the parameter to
+ GC_compare_and_swap so it's not a C++ reserved word. (Thanks to
+ Toshio Endo for pointing out both of those.)
+ - Changed Linux dynamic library registration code to look at /proc/self/maps
+ instead of the rld data structures when REDIRECT_MALLOC is defined.
+ Otherwise some of the rld data data structures may be prematurely garbage
+ collected. (Thanks to Eric Benson for helping to track this down.)
+ - Fixed USE_LD_WRAP a bit more, so it should now work without threads.
+ - Renamed XXX_THREADS macros to GC_XXX_THREADS for namespace correctness.
+ Tomporarily added some backward compatibility definitions. Renamed
+ USE_LD_WRAP to GC_USE_LD_WRAP.
+ - Many MACOSX POWERPC changes, some additions to the gctest output, and
+ a few minor generic bug fixes. (Thanks to Dietmar Planitzer.)
+
+Since 6.0 alpha2
+ - Fixed the /proc/self/maps code to not seek, since that apparently is not
+ reliable across all interesting kernels.
+ - Fixed some compilation problems in the absence of PARALLEL_MARK
+ (introduced in alpha2).
+ - Fixed an algorithmic problem with PARALLEL_MARK. If work needs to
+ be given back to the main mark "stack", the BOTTOM entries of the local
+ stack should be given away, not the top ones. This has substantial
+ performance impact, especially for > 2 processors, from what I can tell.
+ - Extracted gc_lock.h from gc_priv.h. This should eventually make it a
+ bit easier to avoid including gc_priv.h in clients.
+ - Moved all include files to include/ and removed duplicate links to the
+ same file. The old scheme was a bad idea because it was too easy to get the
+ copies out of sync, and many systems don't support hard links.
+ Unfortunately, it's likely that I broke some of the non-Unix Makefiles in
+ the process, although I tried to update them appropriately.
+ - Removed the partial support for a copied nursery. It's not clear that
+ this would be a tremendous win, since we don't consistently lose to
+ generational copying collectors. And it would significantly complicate
+ many things. May be reintroduced if/when it really turns out to win.
+ - Removed references to IRIX_JDK_THREADS, since I believe there never
+ were and never will be any clients.
+ - Added some code to linux_threads.c to possibly support HPUX threads
+ using the Linux code. Unfortunately, it doesn't work yet, and is
+ currently disabled.
+ - Added support under Linux/X86 for saving the call chain, both in (debug)
+ objects for client debugging, and in GC_arrays._last_stack for GC
+ debugging. This was previously supported only under Solaris. It is
+ not enabled by default under X86, since it requires that code be compiled
+ to explicitly dave frame pointers on the call stack. (With gcc this
+ currently happens by default, but is often turned off explicitly.)
+ To turn it on, define SAVE_CALL_CHAIN.
+
To do:
- - Integrate Linux/SPARC fixes.
- Very large root set sizes (> 16 MB or so) could cause the collector
to abort with an unexpected mark stack overflow. (Thanks again to
Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial
@@ -1663,3 +1751,7 @@ To do:
we make some unwarranted assumptions about how varargs are handled. This
currently makes the cord-aware versions of printf unusable on some platforms.
Fixing this is unfortunately not trivial.
+ - There should be an option to require all objects to be at least 2 words
+ long, and to reserve 4 mark bits for each word instead of one. This would
+ allow mark bits to be updated with a normal byte store in the parallel
+ marker, instead of a compare-and-exchange or similar operation.
diff --git a/README.MacOSX b/README.MacOSX
new file mode 100644
index 00000000..82343dd9
--- /dev/null
+++ b/README.MacOSX
@@ -0,0 +1,19 @@
+While the GC should work on MacOS X Server, MacOS X and Darwin, I only tested
+it on MacOS X Server.
+I've added a PPC assembly version of GC_push_regs(), thus the setjmp() hack is
+no longer necessary. Incremental collection is supported via mprotect/signal.
+The current solution isn't really optimal because the signal handler must decode
+the faulting PPC machine instruction in order to find the correct heap address.
+Further, it must poke around in the register state which the kernel saved away
+in some obscure register state structure before it calls the signal handler -
+needless to say the layout of this structure is no where documented.
+Threads and dynamic libraries are not yet supported (adding dynamic library
+support via the low-level dyld API shouldn't be that hard).
+
+The original MacOS X port was brought to you by Andrew Stone.
+
+
+June, 1 2000
+
+Dietmar Planitzer
+dave.pl@ping.at
diff --git a/README.hp b/README.hp
index 072ba538..4b62b277 100644
--- a/README.hp
+++ b/README.hp
@@ -4,13 +4,13 @@ in gcconfig.h and ensuring that all garbage collectable objects are
accessible without considering statically allocated variables in dynamic
libraries.
-The collector should compile with either plain cc or cc -Ae. CC -Aa
+The collector should compile with either plain cc or cc -Ae. Cc -Aa
fails to define _HPUX_SOURCE and thus will not configure the collector
correctly.
Incremental collection support was reccently added, and should now work.
-Thread support for HP/UX 11 Pthreads was also recently added. It is still
-flakey in this release. (It has only been tested on a uniprocessor. Even
-there some fraction of thread creation calls fail with a not-yet-understood
-error return from sem_wait.)
+Thread support for HP/UX 11 Pthreads was also recently added, but is very
+unreliable. At best it might work for running short tests on a uniprocessor.
+It currently appears that this will be fixed only for future versions of the
+pthread library.
diff --git a/README.linux b/README.linux
index e35e712e..24d3ec5e 100644
--- a/README.linux
+++ b/README.linux
@@ -3,7 +3,8 @@ See README.alpha for Linux on DEC AXP info.
This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K
and PowerPC are also integrated. They should behave similarly, except that
the PowerPC port lacks incremental GC support, and it is unknown to what
-extent the Linux threads code is functional.
+extent the Linux threads code is functional. See below for M68K specific
+notes.
Incremental GC is supported on Intel IA32 and M68K.
@@ -28,16 +29,16 @@ To use threads, you need to abide by the following requirements:
pthread implementations (in particular it will *not* work with
MIT pthreads).
-2) You must compile the collector with -DLINUX_THREADS and -D_REENTRANT
+2) You must compile the collector with -DGC_LINUX_THREADS and -D_REENTRANT
specified in the Makefile.
-3a) Every file that makes thread calls should define LINUX_THREADS and
+3a) Every file that makes thread calls should define GC_LINUX_THREADS and
_REENTRANT and then include gc.h. Gc.h redefines some of the
pthread primitives as macros which also provide the collector with
information it requires.
-3b) A new alternative to (3a) is to build the collector with
- -DUSE_LD_WRAP, and to link the final program with
+3b) A new alternative to (3a) is to build the collector and compile GC clients
+ with -DGC_USE_LD_WRAP, and to link the final program with
(for ld) --wrap read --wrap dlopen --wrap pthread_create \
--wrap pthread_join --wrap pthread_sigmask
@@ -54,7 +55,7 @@ To use threads, you need to abide by the following requirements:
user startup code may run as part of dlopen().) Under unusual
conditions, this may cause unexpected heap growth.
-5) The combination of LINUX_THREADS, REDIRECT_MALLOC, and incremental
+5) The combination of GC_LINUX_THREADS, REDIRECT_MALLOC, and incremental
collection fails in seemingly random places. This hasn't been tracked
down yet, but is perhaps not completely astonishing. The thread package
uses malloc, and thus can presumably get SIGSEGVs while inside the
@@ -66,3 +67,67 @@ To use threads, you need to abide by the following requirements:
time being, any collectable memory referenced by thread local storage should
also be referenced from elsewhere, or be allocated as uncollectable.
(This is really a bug that should be fixed somehow.)
+
+
+M68K LINUX:
+(From Richard Zidlicky)
+The bad news is that it can crash every linux-m68k kernel on a 68040,
+so an additional test is needed somewhere on startup. I have meanwhile
+patches to correct the problem in 68040 buserror handler but it is not
+yet in any standard kernel.
+
+Here is a simple test program to detect whether the kernel has the
+problem. It could be run as a separate check in configure or tested
+upon startup. If it fails (return !0) than mprotect can't be used
+on that system.
+
+/*
+ * test for bug that may crash 68040 based Linux
+ */
+
+#include <sys/mman.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+char *membase;
+int pagesize=4096;
+int pageshift=12;
+int x_taken=0;
+
+int sighandler(int sig)
+{
+ mprotect(membase,pagesize,PROT_READ|PROT_WRITE);
+ x_taken=1;
+}
+
+main()
+{
+ long l;
+
+ signal(SIGSEGV,sighandler);
+ l=(long)mmap(NULL,pagesize,PROT_READ,MAP_PRIVATE | MAP_ANON,-1,0);
+ if (l==-1)
+ {
+ perror("mmap/malloc");
+ abort();
+ }
+ membase=(char*)l;
+ *(long*)(membase+sizeof(long))=123456789;
+ if (*(long*)(membase+sizeof(long)) != 123456789 )
+ {
+ fprintf(stderr,"writeback failed !\n");
+ exit(1);
+ }
+ if (!x_taken)
+ {
+ fprintf(stderr,"exception not taken !\n");
+ exit(1);
+ }
+ fprintf(stderr,"vmtest Ok\n");
+ exit(0);
+}
+
+
diff --git a/README.sgi b/README.sgi
index e67124b5..7bdb50a4 100644
--- a/README.sgi
+++ b/README.sgi
@@ -13,7 +13,7 @@ ports.
Pthreads support is provided. This requires that:
-1) You compile the collector with -DIRIX_THREADS specified in the Makefile.
+1) You compile the collector with -DGC_IRIX_THREADS specified in the Makefile.
2) You have the latest pthreads patches installed.
diff --git a/README.solaris2 b/README.solaris2
index cb15e30a..6ed61dc8 100644
--- a/README.solaris2
+++ b/README.solaris2
@@ -20,16 +20,16 @@ You may want to reverse this decisions if you use -DREDIRECT_MALLOC=...
SOLARIS THREADS:
-The collector must be compiled with -DSOLARIS_THREADS to be thread safe.
+The collector must be compiled with -DGC_SOLARIS_THREADS (thr_ functions)
+or -DGC_SOLARIS_PTHREADS (pthread_ functions) to be thread safe.
It is also essential that gc.h be included in files that call thr_create,
thr_join, thr_suspend, thr_continue, or dlopen. Gc.h macro defines
these to also do GC bookkeeping, etc. Gc.h must be included with
-SOLARIS_THREADS defined, otherwise these replacements are not visible.
+one or both of these macros defined, otherwise
+these replacements are not visible.
A collector built in this way way only be used by programs that are
linked with the threads library.
-If you are using the Pthreads interface, also define _SOLARIS_PTHREADS.
-
In this mode, the collector contains various workarounds for older Solaris
bugs. Mostly, these should not be noticeable unless you look at system
call traces. However, it cannot protect a guard page at the end of
diff --git a/allchblk.c b/allchblk.c
index 41624c75..4bd4a123 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -14,10 +14,9 @@
* modified is included with the above copyright notice.
*/
-#define DEBUG
-#undef DEBUG
+/* #define DEBUG */
#include <stdio.h>
-#include "gc_priv.h"
+#include "private/gc_priv.h"
GC_bool GC_use_entire_heap = 0;
@@ -484,8 +483,8 @@ struct hblk * GC_allochblk_nth();
* NOTE: We set obj_map field in header correctly.
* Caller is responsible for building an object freelist in block.
*
- * We clear the block if it is destined for large objects, and if
- * kind requires that newly allocated objects be cleared.
+ * Unlike older versions of the collectors, the client is responsible
+ * for clearing the block, if necessary.
*/
struct hblk *
GC_allochblk(sz, kind, flags)
@@ -664,12 +663,6 @@ int n;
return(0); /* ditto */
}
- /* Clear block if necessary */
- if (GC_debugging_started
- || sz > MAXOBJSZ && GC_obj_kinds[kind].ok_init) {
- BZERO(hbp + HDR_BYTES, size_needed - HDR_BYTES);
- }
-
/* We just successfully allocated a block. Restart count of */
/* consecutive failures. */
{
diff --git a/alloc.c b/alloc.c
index e11ccdea..ed3a7ea8 100644
--- a/alloc.c
+++ b/alloc.c
@@ -16,10 +16,10 @@
*/
-# include "gc_priv.h"
+# include "private/gc_priv.h"
# include <stdio.h>
-# ifndef MACOS
+# if !defined(MACOS) && !defined(MSWINCE)
# include <signal.h>
# include <sys/types.h>
# endif
@@ -60,9 +60,11 @@ word GC_non_gc_bytes = 0; /* Number of bytes not intended to be collected */
word GC_gc_no = 0;
#ifndef SMALL_CONFIG
- int GC_incremental = 0; /* By default, stop the world. */
+ int GC_incremental = 0; /* By default, stop the world. */
#endif
+int GC_parallel = FALSE; /* By default, parallel GC is off. */
+
int GC_full_freq = 19; /* Every 20th collection is a full */
/* collection, whether we need it */
/* or not. */
@@ -76,6 +78,7 @@ char * GC_copyright[] =
{"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ",
"Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. ",
"Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. ",
+"Copyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved. ",
"THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY",
" EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.",
"See source code for details." };
@@ -220,7 +223,7 @@ GC_bool GC_should_collect()
void GC_notify_full_gc()
{
- if (GC_start_call_back != (void (*)())0) {
+ if (GC_start_call_back != (void (*) GC_PROTO((void)))0) {
(*GC_start_call_back)();
}
}
@@ -251,6 +254,9 @@ void GC_maybe_gc()
(long)WORDS_TO_BYTES(GC_words_allocd));
# endif
GC_promote_black_lists();
+# ifdef PARALLEL_MARK
+ GC_wait_for_reclaim();
+# endif
(void)GC_reclaim_all((GC_stop_func)0, TRUE);
GC_clear_marks();
n_partial_gcs = 0;
@@ -308,7 +314,10 @@ GC_stop_func stop_func;
/* If we're guaranteed to finish, then this is unnecessary. */
/* In the find_leak case, we have to finish to guarantee that */
/* previously unmarked objects are not reported as leaks. */
- if ((GC_find_leak || stop_func != GC_never_stop_func)
+# ifdef PARALLEL_MARK
+ GC_wait_for_reclaim();
+# endif
+ if ((GC_find_leak || stop_func != GC_never_stop_func)
&& !GC_reclaim_all(stop_func, FALSE)) {
/* Aborted. So far everything is still consistent. */
return(FALSE);
@@ -410,13 +419,15 @@ GC_stop_func stop_func;
{
register int i;
int dummy;
-# ifdef PRINTSTATS
+# ifdef PRINTTIMES
CLOCK_TYPE start_time, current_time;
# endif
STOP_WORLD();
-# ifdef PRINTSTATS
+# ifdef PRINTTIMES
GET_TIME(start_time);
+# endif
+# ifdef PRINTSTATS
GC_printf1("--> Marking for collection %lu ",
(unsigned long) GC_gc_no + 1);
GC_printf2("after %lu allocd bytes + %lu wasted bytes\n",
diff --git a/blacklst.c b/blacklst.c
index e5a3a26a..2ab09c25 100644
--- a/blacklst.c
+++ b/blacklst.c
@@ -12,7 +12,7 @@
* modified is included with the above copyright notice.
*/
/* Boehm, August 9, 1995 6:09 pm PDT */
-# include "gc_priv.h"
+# include "private/gc_priv.h"
/*
* We maintain several hash tables of hblks that have had false hits.
@@ -52,15 +52,19 @@ word GC_black_list_spacing = MINHINCR*HBLKSIZE; /* Initial rough guess */
void GC_clear_bl();
-void GC_default_print_heap_obj_proc(p)
-ptr_t p;
+# if defined(__STDC__) || defined(__cplusplus)
+ void GC_default_print_heap_obj_proc(ptr_t p)
+# else
+ void GC_default_print_heap_obj_proc(p)
+ ptr_t p;
+# endif
{
ptr_t base = GC_base(p);
GC_err_printf2("start: 0x%lx, appr. length: %ld", base, GC_size(base));
}
-void (*GC_print_heap_obj)(/* char * s, ptr_t p */) =
+void (*GC_print_heap_obj) GC_PROTO((ptr_t p)) =
GC_default_print_heap_obj_proc;
void GC_print_source_ptr(p)
diff --git a/checksums.c b/checksums.c
index 212655f4..121c36d4 100644
--- a/checksums.c
+++ b/checksums.c
@@ -80,7 +80,7 @@ int index;
if (pe -> block != 0 && pe -> block != h + OFFSET) ABORT("goofed");
pe -> old_sum = pe -> new_sum;
pe -> new_sum = GC_checksum(h);
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
if (pe -> new_sum != 0 && !GC_page_was_ever_dirty(h)) {
GC_printf1("GC_page_was_ever_dirty(0x%lx) is wrong\n",
(unsigned long)h);
diff --git a/cord/cord.h b/cord/cord.h
deleted file mode 100644
index 926089e8..00000000
--- a/cord/cord.h
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- *
- * Author: Hans-J. Boehm (boehm@parc.xerox.com)
- */
-/* Boehm, October 5, 1995 4:20 pm PDT */
-
-/*
- * Cords are immutable character strings. A number of operations
- * on long cords are much more efficient than their strings.h counterpart.
- * In particular, concatenation takes constant time independent of the length
- * of the arguments. (Cords are represented as trees, with internal
- * nodes representing concatenation and leaves consisting of either C
- * strings or a functional description of the string.)
- *
- * The following are reasonable applications of cords. They would perform
- * unacceptably if C strings were used:
- * - A compiler that produces assembly language output by repeatedly
- * concatenating instructions onto a cord representing the output file.
- * - A text editor that converts the input file to a cord, and then
- * performs editing operations by producing a new cord representing
- * the file after echa character change (and keeping the old ones in an
- * edit history)
- *
- * For optimal performance, cords should be built by
- * concatenating short sections.
- * This interface is designed for maximum compatibility with C strings.
- * ASCII NUL characters may be embedded in cords using CORD_from_fn.
- * This is handled correctly, but CORD_to_char_star will produce a string
- * with embedded NULs when given such a cord.
- *
- * This interface is fairly big, largely for performance reasons.
- * The most basic constants and functions:
- *
- * CORD - the type of a cord;
- * CORD_EMPTY - empty cord;
- * CORD_len(cord) - length of a cord;
- * CORD_cat(cord1,cord2) - concatenation of two cords;
- * CORD_substr(cord, start, len) - substring (or subcord);
- * CORD_pos i; CORD_FOR(i, cord) { ... CORD_pos_fetch(i) ... } -
- * examine each character in a cord. CORD_pos_fetch(i) is the char.
- * CORD_fetch(int i) - Retrieve i'th character (slowly).
- * CORD_cmp(cord1, cord2) - compare two cords.
- * CORD_from_file(FILE * f) - turn a read-only file into a cord.
- * CORD_to_char_star(cord) - convert to C string.
- * (Non-NULL C constant strings are cords.)
- * CORD_printf (etc.) - cord version of printf. Use %r for cords.
- */
-# ifndef CORD_H
-
-# define CORD_H
-# include <stddef.h>
-# include <stdio.h>
-/* Cords have type const char *. This is cheating quite a bit, and not */
-/* 100% portable. But it means that nonempty character string */
-/* constants may be used as cords directly, provided the string is */
-/* never modified in place. The empty cord is represented by, and */
-/* can be written as, 0. */
-
-typedef const char * CORD;
-
-/* An empty cord is always represented as nil */
-# define CORD_EMPTY 0
-
-/* Is a nonempty cord represented as a C string? */
-#define CORD_IS_STRING(s) (*(s) != '\0')
-
-/* Concatenate two cords. If the arguments are C strings, they may */
-/* not be subsequently altered. */
-CORD CORD_cat(CORD x, CORD y);
-
-/* Concatenate a cord and a C string with known length. Except for the */
-/* empty string case, this is a special case of CORD_cat. Since the */
-/* length is known, it can be faster. */
-/* The string y is shared with the resulting CORD. Hence it should */
-/* not be altered by the caller. */
-CORD CORD_cat_char_star(CORD x, const char * y, size_t leny);
-
-/* Compute the length of a cord */
-size_t CORD_len(CORD x);
-
-/* Cords may be represented by functions defining the ith character */
-typedef char (* CORD_fn)(size_t i, void * client_data);
-
-/* Turn a functional description into a cord. */
-CORD CORD_from_fn(CORD_fn fn, void * client_data, size_t len);
-
-/* Return the substring (subcord really) of x with length at most n, */
-/* starting at position i. (The initial character has position 0.) */
-CORD CORD_substr(CORD x, size_t i, size_t n);
-
-/* Return the argument, but rebalanced to allow more efficient */
-/* character retrieval, substring operations, and comparisons. */
-/* This is useful only for cords that were built using repeated */
-/* concatenation. Guarantees log time access to the result, unless */
-/* x was obtained through a large number of repeated substring ops */
-/* or the embedded functional descriptions take longer to evaluate. */
-/* May reallocate significant parts of the cord. The argument is not */
-/* modified; only the result is balanced. */
-CORD CORD_balance(CORD x);
-
-/* The following traverse a cord by applying a function to each */
-/* character. This is occasionally appropriate, especially where */
-/* speed is crucial. But, since C doesn't have nested functions, */
-/* clients of this sort of traversal are clumsy to write. Consider */
-/* the functions that operate on cord positions instead. */
-
-/* Function to iteratively apply to individual characters in cord. */
-typedef int (* CORD_iter_fn)(char c, void * client_data);
-
-/* Function to apply to substrings of a cord. Each substring is a */
-/* a C character string, not a general cord. */
-typedef int (* CORD_batched_iter_fn)(const char * s, void * client_data);
-# define CORD_NO_FN ((CORD_batched_iter_fn)0)
-
-/* Apply f1 to each character in the cord, in ascending order, */
-/* starting at position i. If */
-/* f2 is not CORD_NO_FN, then multiple calls to f1 may be replaced by */
-/* a single call to f2. The parameter f2 is provided only to allow */
-/* some optimization by the client. This terminates when the right */
-/* end of this string is reached, or when f1 or f2 return != 0. In the */
-/* latter case CORD_iter returns != 0. Otherwise it returns 0. */
-/* The specified value of i must be < CORD_len(x). */
-int CORD_iter5(CORD x, size_t i, CORD_iter_fn f1,
- CORD_batched_iter_fn f2, void * client_data);
-
-/* A simpler version that starts at 0, and without f2: */
-int CORD_iter(CORD x, CORD_iter_fn f1, void * client_data);
-# define CORD_iter(x, f1, cd) CORD_iter5(x, 0, f1, CORD_NO_FN, cd)
-
-/* Similar to CORD_iter5, but end-to-beginning. No provisions for */
-/* CORD_batched_iter_fn. */
-int CORD_riter4(CORD x, size_t i, CORD_iter_fn f1, void * client_data);
-
-/* A simpler version that starts at the end: */
-int CORD_riter(CORD x, CORD_iter_fn f1, void * client_data);
-
-/* Functions that operate on cord positions. The easy way to traverse */
-/* cords. A cord position is logically a pair consisting of a cord */
-/* and an index into that cord. But it is much faster to retrieve a */
-/* charcter based on a position than on an index. Unfortunately, */
-/* positions are big (order of a few 100 bytes), so allocate them with */
-/* caution. */
-/* Things in cord_pos.h should be treated as opaque, except as */
-/* described below. Also note that */
-/* CORD_pos_fetch, CORD_next and CORD_prev have both macro and function */
-/* definitions. The former may evaluate their argument more than once. */
-# include "private/cord_pos.h"
-
-/*
- Visible definitions from above:
-
- typedef <OPAQUE but fairly big> CORD_pos[1];
-
- * Extract the cord from a position:
- CORD CORD_pos_to_cord(CORD_pos p);
-
- * Extract the current index from a position:
- size_t CORD_pos_to_index(CORD_pos p);
-
- * Fetch the character located at the given position:
- char CORD_pos_fetch(CORD_pos p);
-
- * Initialize the position to refer to the given cord and index.
- * Note that this is the most expensive function on positions:
- void CORD_set_pos(CORD_pos p, CORD x, size_t i);
-
- * Advance the position to the next character.
- * P must be initialized and valid.
- * Invalidates p if past end:
- void CORD_next(CORD_pos p);
-
- * Move the position to the preceding character.
- * P must be initialized and valid.
- * Invalidates p if past beginning:
- void CORD_prev(CORD_pos p);
-
- * Is the position valid, i.e. inside the cord?
- int CORD_pos_valid(CORD_pos p);
-*/
-# define CORD_FOR(pos, cord) \
- for (CORD_set_pos(pos, cord, 0); CORD_pos_valid(pos); CORD_next(pos))
-
-
-/* An out of memory handler to call. May be supplied by client. */
-/* Must not return. */
-extern void (* CORD_oom_fn)(void);
-
-/* Dump the representation of x to stdout in an implementation defined */
-/* manner. Intended for debugging only. */
-void CORD_dump(CORD x);
-
-/* The following could easily be implemented by the client. They are */
-/* provided in cordxtra.c for convenience. */
-
-/* Concatenate a character to the end of a cord. */
-CORD CORD_cat_char(CORD x, char c);
-
-/* Concatenate n cords. */
-CORD CORD_catn(int n, /* CORD */ ...);
-
-/* Return the character in CORD_substr(x, i, 1) */
-char CORD_fetch(CORD x, size_t i);
-
-/* Return < 0, 0, or > 0, depending on whether x < y, x = y, x > y */
-int CORD_cmp(CORD x, CORD y);
-
-/* A generalization that takes both starting positions for the */
-/* comparison, and a limit on the number of characters to be compared. */
-int CORD_ncmp(CORD x, size_t x_start, CORD y, size_t y_start, size_t len);
-
-/* Find the first occurrence of s in x at position start or later. */
-/* Return the position of the first character of s in x, or */
-/* CORD_NOT_FOUND if there is none. */
-size_t CORD_str(CORD x, size_t start, CORD s);
-
-/* Return a cord consisting of i copies of (possibly NUL) c. Dangerous */
-/* in conjunction with CORD_to_char_star. */
-/* The resulting representation takes constant space, independent of i. */
-CORD CORD_chars(char c, size_t i);
-# define CORD_nul(i) CORD_chars('\0', (i))
-
-/* Turn a file into cord. The file must be seekable. Its contents */
-/* must remain constant. The file may be accessed as an immediate */
-/* result of this call and/or as a result of subsequent accesses to */
-/* the cord. Short files are likely to be immediately read, but */
-/* long files are likely to be read on demand, possibly relying on */
-/* stdio for buffering. */
-/* We must have exclusive access to the descriptor f, i.e. we may */
-/* read it at any time, and expect the file pointer to be */
-/* where we left it. Normally this should be invoked as */
-/* CORD_from_file(fopen(...)) */
-/* CORD_from_file arranges to close the file descriptor when it is no */
-/* longer needed (e.g. when the result becomes inaccessible). */
-/* The file f must be such that ftell reflects the actual character */
-/* position in the file, i.e. the number of characters that can be */
-/* or were read with fread. On UNIX systems this is always true. On */
-/* MS Windows systems, f must be opened in binary mode. */
-CORD CORD_from_file(FILE * f);
-
-/* Equivalent to the above, except that the entire file will be read */
-/* and the file pointer will be closed immediately. */
-/* The binary mode restriction from above does not apply. */
-CORD CORD_from_file_eager(FILE * f);
-
-/* Equivalent to the above, except that the file will be read on demand.*/
-/* The binary mode restriction applies. */
-CORD CORD_from_file_lazy(FILE * f);
-
-/* Turn a cord into a C string. The result shares no structure with */
-/* x, and is thus modifiable. */
-char * CORD_to_char_star(CORD x);
-
-/* Turn a C string into a CORD. The C string is copied, and so may */
-/* subsequently be modified. */
-CORD CORD_from_char_star(const char *s);
-
-/* Identical to the above, but the result may share structure with */
-/* the argument and is thus not modifiable. */
-const char * CORD_to_const_char_star(CORD x);
-
-/* Write a cord to a file, starting at the current position. No */
-/* trailing NULs are newlines are added. */
-/* Returns EOF if a write error occurs, 1 otherwise. */
-int CORD_put(CORD x, FILE * f);
-
-/* "Not found" result for the following two functions. */
-# define CORD_NOT_FOUND ((size_t)(-1))
-
-/* A vague analog of strchr. Returns the position (an integer, not */
-/* a pointer) of the first occurrence of (char) c inside x at position */
-/* i or later. The value i must be < CORD_len(x). */
-size_t CORD_chr(CORD x, size_t i, int c);
-
-/* A vague analog of strrchr. Returns index of the last occurrence */
-/* of (char) c inside x at position i or earlier. The value i */
-/* must be < CORD_len(x). */
-size_t CORD_rchr(CORD x, size_t i, int c);
-
-
-/* The following are also not primitive, but are implemented in */
-/* cordprnt.c. They provide functionality similar to the ANSI C */
-/* functions with corresponding names, but with the following */
-/* additions and changes: */
-/* 1. A %r conversion specification specifies a CORD argument. Field */
-/* width, precision, etc. have the same semantics as for %s. */
-/* (Note that %c,%C, and %S were already taken.) */
-/* 2. The format string is represented as a CORD. */
-/* 3. CORD_sprintf and CORD_vsprintf assign the result through the 1st */ /* argument. Unlike their ANSI C versions, there is no need to guess */
-/* the correct buffer size. */
-/* 4. Most of the conversions are implement through the native */
-/* vsprintf. Hence they are usually no faster, and */
-/* idiosyncracies of the native printf are preserved. However, */
-/* CORD arguments to CORD_sprintf and CORD_vsprintf are NOT copied; */
-/* the result shares the original structure. This may make them */
-/* very efficient in some unusual applications. */
-/* The format string is copied. */
-/* All functions return the number of characters generated or -1 on */
-/* error. This complies with the ANSI standard, but is inconsistent */
-/* with some older implementations of sprintf. */
-
-/* The implementation of these is probably less portable than the rest */
-/* of this package. */
-
-#ifndef CORD_NO_IO
-
-#include <stdarg.h>
-
-int CORD_sprintf(CORD * out, CORD format, ...);
-int CORD_vsprintf(CORD * out, CORD format, va_list args);
-int CORD_fprintf(FILE * f, CORD format, ...);
-int CORD_vfprintf(FILE * f, CORD format, va_list args);
-int CORD_printf(CORD format, ...);
-int CORD_vprintf(CORD format, va_list args);
-
-#endif /* CORD_NO_IO */
-
-# endif /* CORD_H */
diff --git a/cord/cordtest.c b/cord/cordtest.c
index d11d7dd4..d54c65fe 100644
--- a/cord/cordtest.c
+++ b/cord/cordtest.c
@@ -14,6 +14,7 @@
# include "cord.h"
# include <string.h>
# include <stdio.h>
+# include <stdlib.h>
/* This is a very incomplete test of the cord package. It knows about */
/* a few internals of the package (e.g. when C strings are returned) */
/* that real clients shouldn't rely on. */
diff --git a/cord/ec.h b/cord/ec.h
deleted file mode 100644
index c829b83a..00000000
--- a/cord/ec.h
+++ /dev/null
@@ -1,70 +0,0 @@
-# ifndef EC_H
-# define EC_H
-
-# ifndef CORD_H
-# include "cord.h"
-# endif
-
-/* Extensible cords are strings that may be destructively appended to. */
-/* They allow fast construction of cords from characters that are */
-/* being read from a stream. */
-/*
- * A client might look like:
- *
- * {
- * CORD_ec x;
- * CORD result;
- * char c;
- * FILE *f;
- *
- * ...
- * CORD_ec_init(x);
- * while(...) {
- * c = getc(f);
- * ...
- * CORD_ec_append(x, c);
- * }
- * result = CORD_balance(CORD_ec_to_cord(x));
- *
- * If a C string is desired as the final result, the call to CORD_balance
- * may be replaced by a call to CORD_to_char_star.
- */
-
-# ifndef CORD_BUFSZ
-# define CORD_BUFSZ 128
-# endif
-
-typedef struct CORD_ec_struct {
- CORD ec_cord;
- char * ec_bufptr;
- char ec_buf[CORD_BUFSZ+1];
-} CORD_ec[1];
-
-/* This structure represents the concatenation of ec_cord with */
-/* ec_buf[0 ... (ec_bufptr-ec_buf-1)] */
-
-/* Flush the buffer part of the extended chord into ec_cord. */
-/* Note that this is almost the only real function, and it is */
-/* implemented in 6 lines in cordxtra.c */
-void CORD_ec_flush_buf(CORD_ec x);
-
-/* Convert an extensible cord to a cord. */
-# define CORD_ec_to_cord(x) (CORD_ec_flush_buf(x), (x)[0].ec_cord)
-
-/* Initialize an extensible cord. */
-# define CORD_ec_init(x) ((x)[0].ec_cord = 0, (x)[0].ec_bufptr = (x)[0].ec_buf)
-
-/* Append a character to an extensible cord. */
-# define CORD_ec_append(x, c) \
- { \
- if ((x)[0].ec_bufptr == (x)[0].ec_buf + CORD_BUFSZ) { \
- CORD_ec_flush_buf(x); \
- } \
- *((x)[0].ec_bufptr)++ = (c); \
- }
-
-/* Append a cord to an extensible cord. Structure remains shared with */
-/* original. */
-void CORD_ec_append_cord(CORD_ec x, CORD s);
-
-# endif /* EC_H */
diff --git a/cord/gc.h b/cord/gc.h
deleted file mode 100644
index d7cd8996..00000000
--- a/cord/gc.h
+++ /dev/null
@@ -1,804 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
- * Copyright 1996-1999 by Silicon Graphics. All rights reserved.
- * Copyright 1999 by Hewlett-Packard Company. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-/*
- * Note that this defines a large number of tuning hooks, which can
- * safely be ignored in nearly all cases. For normal use it suffices
- * to call only GC_MALLOC and perhaps GC_REALLOC.
- * For better performance, also look at GC_MALLOC_ATOMIC, and
- * GC_enable_incremental. If you need an action to be performed
- * immediately before an object is collected, look at GC_register_finalizer.
- * If you are using Solaris threads, look at the end of this file.
- * Everything else is best ignored unless you encounter performance
- * problems.
- */
-
-#ifndef _GC_H
-
-# define _GC_H
-# define __GC
-# include <stddef.h>
-
-#if defined(__CYGWIN32__) && defined(GC_USE_DLL)
-#include "libgc_globals.h"
-#endif
-
-#if defined(__MINGW32__) && defined(WIN32_THREADS)
-# ifdef GC_BUILD
-# define GC_API __declspec(dllexport)
-# else
-# define GC_API __declspec(dllimport)
-# endif
-#endif
-
-#if defined(_MSC_VER) && defined(_DLL)
-# ifdef GC_BUILD
-# define GC_API __declspec(dllexport)
-# else
-# define GC_API __declspec(dllimport)
-# endif
-#endif
-
-#if defined(__WATCOMC__) && defined(GC_DLL)
-# ifdef GC_BUILD
-# define GC_API extern __declspec(dllexport)
-# else
-# define GC_API extern __declspec(dllimport)
-# endif
-#endif
-
-#ifndef GC_API
-#define GC_API extern
-#endif
-
-# if defined(__STDC__) || defined(__cplusplus)
-# define GC_PROTO(args) args
- typedef void * GC_PTR;
-# define GC_CONST const
-# else
-# define GC_PROTO(args) ()
- typedef char * GC_PTR;
-# define GC_CONST
-# endif
-
-# ifdef __cplusplus
- extern "C" {
-# endif
-
-
-/* Define word and signed_word to be unsigned and signed types of the */
-/* size as char * or void *. There seems to be no way to do this */
-/* even semi-portably. The following is probably no better/worse */
-/* than almost anything else. */
-/* The ANSI standard suggests that size_t and ptr_diff_t might be */
-/* better choices. But those appear to have incorrect definitions */
-/* on may systems. Notably "typedef int size_t" seems to be both */
-/* frequent and WRONG. */
-typedef unsigned long GC_word;
-typedef long GC_signed_word;
-
-/* Public read-only variables */
-
-GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
- /* Includes empty GCs at startup. */
-
-
-/* Public R/W variables */
-
-GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested));
- /* When there is insufficient memory to satisfy */
- /* an allocation request, we return */
- /* (*GC_oom_fn)(). By default this just */
- /* returns 0. */
- /* If it returns, it must return 0 or a valid */
- /* pointer to a previously allocated heap */
- /* object. */
-
-GC_API int GC_find_leak;
- /* Do not actually garbage collect, but simply */
- /* report inaccessible memory that was not */
- /* deallocated with GC_free. Initial value */
- /* is determined by FIND_LEAK macro. */
-
-GC_API int GC_quiet; /* Disable statistics output. Only matters if */
- /* collector has been compiled with statistics */
- /* enabled. This involves a performance cost, */
- /* and is thus not the default. */
-
-GC_API int GC_finalize_on_demand;
- /* If nonzero, finalizers will only be run in */
- /* response to an eplit GC_invoke_finalizers */
- /* call. The default is determined by whether */
- /* the FINALIZE_ON_DEMAND macro is defined */
- /* when the collector is built. */
-
-GC_API int GC_java_finalization;
- /* Mark objects reachable from finalizable */
- /* objects in a separate postpass. This makes */
- /* it a bit safer to use non-topologically- */
- /* ordered finalization. Default value is */
- /* determined by JAVA_FINALIZATION macro. */
-
-GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */
- /* because it's not safe. */
-
-GC_API int GC_dont_expand;
- /* Dont expand heap unless explicitly requested */
- /* or forced to. */
-
-GC_API int GC_use_entire_heap;
- /* Causes the nonincremental collector to use the */
- /* entire heap before collecting. This was the only */
- /* option for GC versions < 5.0. This sometimes */
- /* results in more large block fragmentation, since */
- /* very larg blocks will tend to get broken up */
- /* during each GC cycle. It is likely to result in a */
- /* larger working set, but lower collection */
- /* frequencies, and hence fewer instructions executed */
- /* in the collector. */
-
-GC_API int GC_full_freq; /* Number of partial collections between */
- /* full collections. Matters only if */
- /* GC_incremental is set. */
- /* Full collections are also triggered if */
- /* the collector detects a substantial */
- /* increase in the number of in-use heap */
- /* blocks. Values in the tens are now */
- /* perfectly reasonable, unlike for */
- /* earlier GC versions. */
-
-GC_API GC_word GC_non_gc_bytes;
- /* Bytes not considered candidates for collection. */
- /* Used only to control scheduling of collections. */
-
-GC_API GC_word GC_free_space_divisor;
- /* We try to make sure that we allocate at */
- /* least N/GC_free_space_divisor bytes between */
- /* collections, where N is the heap size plus */
- /* a rough estimate of the root set size. */
- /* Initially, GC_free_space_divisor = 4. */
- /* Increasing its value will use less space */
- /* but more collection time. Decreasing it */
- /* will appreciably decrease collection time */
- /* at the expense of space. */
- /* GC_free_space_divisor = 1 will effectively */
- /* disable collections. */
-
-GC_API GC_word GC_max_retries;
- /* The maximum number of GCs attempted before */
- /* reporting out of memory after heap */
- /* expansion fails. Initially 0. */
-
-
-GC_API char *GC_stackbottom; /* Cool end of user stack. */
- /* May be set in the client prior to */
- /* calling any GC_ routines. This */
- /* avoids some overhead, and */
- /* potentially some signals that can */
- /* confuse debuggers. Otherwise the */
- /* collector attempts to set it */
- /* automatically. */
- /* For multithreaded code, this is the */
- /* cold end of the stack for the */
- /* primordial thread. */
-
-/* Public procedures */
-/*
- * general purpose allocation routines, with roughly malloc calling conv.
- * The atomic versions promise that no relevant pointers are contained
- * in the object. The nonatomic versions guarantee that the new object
- * is cleared. GC_malloc_stubborn promises that no changes to the object
- * will occur after GC_end_stubborn_change has been called on the
- * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object
- * that is scanned for pointers to collectable objects, but is not itself
- * collectable. GC_malloc_uncollectable and GC_free called on the resulting
- * object implicitly update GC_non_gc_bytes appropriately.
- */
-GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes));
-
-/* The following is only defined if the library has been suitably */
-/* compiled: */
-GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes));
-
-/* Explicitly deallocate an object. Dangerous if used incorrectly. */
-/* Requires a pointer to the base of an object. */
-/* If the argument is stubborn, it should not be changeable when freed. */
-/* An object should not be enable for finalization when it is */
-/* explicitly deallocated. */
-/* GC_free(0) is a no-op, as required by ANSI C for free. */
-GC_API void GC_free GC_PROTO((GC_PTR object_addr));
-
-/*
- * Stubborn objects may be changed only if the collector is explicitly informed.
- * The collector is implicitly informed of coming change when such
- * an object is first allocated. The following routines inform the
- * collector that an object will no longer be changed, or that it will
- * once again be changed. Only nonNIL pointer stores into the object
- * are considered to be changes. The argument to GC_end_stubborn_change
- * must be exacly the value returned by GC_malloc_stubborn or passed to
- * GC_change_stubborn. (In the second case it may be an interior pointer
- * within 512 bytes of the beginning of the objects.)
- * There is a performance penalty for allowing more than
- * one stubborn object to be changed at once, but it is acceptable to
- * do so. The same applies to dropping stubborn objects that are still
- * changeable.
- */
-GC_API void GC_change_stubborn GC_PROTO((GC_PTR));
-GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
-
-/* Return a pointer to the base (lowest address) of an object given */
-/* a pointer to a location within the object. */
-/* Return 0 if displaced_pointer doesn't point to within a valid */
-/* object. */
-GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
-
-/* Given a pointer to the base of an object, return its size in bytes. */
-/* The returned size may be slightly larger than what was originally */
-/* requested. */
-GC_API size_t GC_size GC_PROTO((GC_PTR object_addr));
-
-/* For compatibility with C library. This is occasionally faster than */
-/* a malloc followed by a bcopy. But if you rely on that, either here */
-/* or with the standard C library, your code is broken. In my */
-/* opinion, it shouldn't have been invented, but now we're stuck. -HB */
-/* The resulting object has the same kind as the original. */
-/* If the argument is stubborn, the result will have changes enabled. */
-/* It is an error to have changes enabled for the original object. */
-/* Follows ANSI comventions for NULL old_object. */
-GC_API GC_PTR GC_realloc
- GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes));
-
-/* Explicitly increase the heap size. */
-/* Returns 0 on failure, 1 on success. */
-GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes));
-
-/* Limit the heap size to n bytes. Useful when you're debugging, */
-/* especially on systems that don't handle running out of memory well. */
-/* n == 0 ==> unbounded. This is the default. */
-GC_API void GC_set_max_heap_size GC_PROTO((GC_word n));
-
-/* Inform the collector that a certain section of statically allocated */
-/* memory contains no pointers to garbage collected memory. Thus it */
-/* need not be scanned. This is sometimes important if the application */
-/* maps large read/write files into the address space, which could be */
-/* mistaken for dynamic library data segments on some systems. */
-GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish));
-
-/* Clear the set of root segments. Wizards only. */
-GC_API void GC_clear_roots GC_PROTO((void));
-
-/* Add a root segment. Wizards only. */
-GC_API void GC_add_roots GC_PROTO((char * low_address,
- char * high_address_plus_1));
-
-/* Add a displacement to the set of those considered valid by the */
-/* collector. GC_register_displacement(n) means that if p was returned */
-/* by GC_malloc, then (char *)p + n will be considered to be a valid */
-/* pointer to n. N must be small and less than the size of p. */
-/* (All pointers to the interior of objects from the stack are */
-/* considered valid in any case. This applies to heap objects and */
-/* static data.) */
-/* Preferably, this should be called before any other GC procedures. */
-/* Calling it later adds to the probability of excess memory */
-/* retention. */
-/* This is a no-op if the collector was compiled with recognition of */
-/* arbitrary interior pointers enabled, which is now the default. */
-GC_API void GC_register_displacement GC_PROTO((GC_word n));
-
-/* The following version should be used if any debugging allocation is */
-/* being done. */
-GC_API void GC_debug_register_displacement GC_PROTO((GC_word n));
-
-/* Explicitly trigger a full, world-stop collection. */
-GC_API void GC_gcollect GC_PROTO((void));
-
-/* Trigger a full world-stopped collection. Abort the collection if */
-/* and when stop_func returns a nonzero value. Stop_func will be */
-/* called frequently, and should be reasonably fast. This works even */
-/* if virtual dirty bits, and hence incremental collection is not */
-/* available for this architecture. Collections can be aborted faster */
-/* than normal pause times for incremental collection. However, */
-/* aborted collections do no useful work; the next collection needs */
-/* to start from the beginning. */
-/* Return 0 if the collection was aborted, 1 if it succeeded. */
-typedef int (* GC_stop_func) GC_PROTO((void));
-GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func));
-
-/* Return the number of bytes in the heap. Excludes collector private */
-/* data structures. Includes empty blocks and fragmentation loss. */
-/* Includes some pages that were allocated but never written. */
-GC_API size_t GC_get_heap_size GC_PROTO((void));
-
-/* Return a lower bound on the number of free bytes in the heap. */
-GC_API size_t GC_get_free_bytes GC_PROTO((void));
-
-/* Return the number of bytes allocated since the last collection. */
-GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
-
-/* Enable incremental/generational collection. */
-/* Not advisable unless dirty bits are */
-/* available or most heap objects are */
-/* pointerfree(atomic) or immutable. */
-/* Don't use in leak finding mode. */
-/* Ignored if GC_dont_gc is true. */
-GC_API void GC_enable_incremental GC_PROTO((void));
-
-/* Perform some garbage collection work, if appropriate. */
-/* Return 0 if there is no more work to be done. */
-/* Typically performs an amount of work corresponding roughly */
-/* to marking from one page. May do more work if further */
-/* progress requires it, e.g. if incremental collection is */
-/* disabled. It is reasonable to call this in a wait loop */
-/* until it returns 0. */
-GC_API int GC_collect_a_little GC_PROTO((void));
-
-/* Allocate an object of size lb bytes. The client guarantees that */
-/* as long as the object is live, it will be referenced by a pointer */
-/* that points to somewhere within the first 256 bytes of the object. */
-/* (This should normally be declared volatile to prevent the compiler */
-/* from invalidating this assertion.) This routine is only useful */
-/* if a large array is being allocated. It reduces the chance of */
-/* accidentally retaining such an array as a result of scanning an */
-/* integer that happens to be an address inside the array. (Actually, */
-/* it reduces the chance of the allocator not finding space for such */
-/* an array, since it will try hard to avoid introducing such a false */
-/* reference.) On a SunOS 4.X or MS Windows system this is recommended */
-/* for arrays likely to be larger than 100K or so. For other systems, */
-/* or if the collector is not configured to recognize all interior */
-/* pointers, the threshold is normally much higher. */
-GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb));
-GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
-
-#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
-# define GC_ADD_CALLER
-# define GC_RETURN_ADDR (GC_word)__return_address
-#endif
-
-#ifdef GC_ADD_CALLER
-# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
-# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s, int i
-#else
-# define GC_EXTRAS __FILE__, __LINE__
-# define GC_EXTRA_PARAMS GC_CONST char * s, int i
-#endif
-
-/* Debugging (annotated) allocation. GC_gcollect will check */
-/* objects allocated in this way for overwrites, etc. */
-GC_API GC_PTR GC_debug_malloc
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_atomic
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_uncollectable
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_stubborn
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr));
-GC_API GC_PTR GC_debug_realloc
- GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes,
- GC_EXTRA_PARAMS));
-
-GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR));
-GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
-# ifdef GC_DEBUG
-# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
-# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
-# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \
- GC_EXTRAS)
-# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
-# define GC_FREE(p) GC_debug_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_debug_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_debug_register_finalizer_no_order(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
-# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, GC_base(obj))
-# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
-# else
-# define GC_MALLOC(sz) GC_malloc(sz)
-# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
-# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
-# define GC_REALLOC(old, sz) GC_realloc(old, sz)
-# define GC_FREE(p) GC_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_register_finalizer_no_order(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
-# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, obj)
-# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
-# endif
-/* The following are included because they are often convenient, and */
-/* reduce the chance for a misspecifed size argument. But calls may */
-/* expand to something syntactically incorrect if t is a complicated */
-/* type expression. */
-# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
-# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
-# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
-# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
-
-/* Finalization. Some of these primitives are grossly unsafe. */
-/* The idea is to make them both cheap, and sufficient to build */
-/* a safer layer, closer to PCedar finalization. */
-/* The interface represents my conclusions from a long discussion */
-/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
-/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
-/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
-typedef void (*GC_finalization_proc)
- GC_PROTO((GC_PTR obj, GC_PTR client_data));
-
-GC_API void GC_register_finalizer
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
- /* When obj is no longer accessible, invoke */
- /* (*fn)(obj, cd). If a and b are inaccessible, and */
- /* a points to b (after disappearing links have been */
- /* made to disappear), then only a will be */
- /* finalized. (If this does not create any new */
- /* pointers to b, then b will be finalized after the */
- /* next collection.) Any finalizable object that */
- /* is reachable from itself by following one or more */
- /* pointers will not be finalized (or collected). */
- /* Thus cycles involving finalizable objects should */
- /* be avoided, or broken by disappearing links. */
- /* All but the last finalizer registered for an object */
- /* is ignored. */
- /* Finalization may be removed by passing 0 as fn. */
- /* Finalizers are implicitly unregistered just before */
- /* they are invoked. */
- /* The old finalizer and client data are stored in */
- /* *ofn and *ocd. */
- /* Fn is never invoked on an accessible object, */
- /* provided hidden pointers are converted to real */
- /* pointers only if the allocation lock is held, and */
- /* such conversions are not performed by finalization */
- /* routines. */
- /* If GC_register_finalizer is aborted as a result of */
- /* a signal, the object may be left with no */
- /* finalization, even if neither the old nor new */
- /* finalizer were NULL. */
- /* Obj should be the nonNULL starting address of an */
- /* object allocated by GC_malloc or friends. */
- /* Note that any garbage collectable object referenced */
- /* by cd will be considered accessible until the */
- /* finalizer is invoked. */
-
-/* Another versions of the above follow. It ignores */
-/* self-cycles, i.e. pointers from a finalizable object to */
-/* itself. There is a stylistic argument that this is wrong, */
-/* but it's unavoidable for C++, since the compiler may */
-/* silently introduce these. It's also benign in that specific */
-/* case. */
-GC_API void GC_register_finalizer_ignore_self
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer_ignore_self
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-
-/* Another version of the above. It ignores all cycles. */
-/* It should probably only be used by Java implementations. */
-GC_API void GC_register_finalizer_no_order
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer_no_order
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-
-
-/* The following routine may be used to break cycles between */
-/* finalizable objects, thus causing cyclic finalizable */
-/* objects to be finalized in the correct order. Standard */
-/* use involves calling GC_register_disappearing_link(&p), */
-/* where p is a pointer that is not followed by finalization */
-/* code, and should not be considered in determining */
-/* finalization order. */
-GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */));
- /* Link should point to a field of a heap allocated */
- /* object obj. *link will be cleared when obj is */
- /* found to be inaccessible. This happens BEFORE any */
- /* finalization code is invoked, and BEFORE any */
- /* decisions about finalization order are made. */
- /* This is useful in telling the finalizer that */
- /* some pointers are not essential for proper */
- /* finalization. This may avoid finalization cycles. */
- /* Note that obj may be resurrected by another */
- /* finalizer, and thus the clearing of *link may */
- /* be visible to non-finalization code. */
- /* There's an argument that an arbitrary action should */
- /* be allowed here, instead of just clearing a pointer. */
- /* But this causes problems if that action alters, or */
- /* examines connectivity. */
- /* Returns 1 if link was already registered, 0 */
- /* otherwise. */
- /* Only exists for backward compatibility. See below: */
-
-GC_API int GC_general_register_disappearing_link
- GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
- /* A slight generalization of the above. *link is */
- /* cleared when obj first becomes inaccessible. This */
- /* can be used to implement weak pointers easily and */
- /* safely. Typically link will point to a location */
- /* holding a disguised pointer to obj. (A pointer */
- /* inside an "atomic" object is effectively */
- /* disguised.) In this way soft */
- /* pointers are broken before any object */
- /* reachable from them are finalized. Each link */
- /* May be registered only once, i.e. with one obj */
- /* value. This was added after a long email discussion */
- /* with John Ellis. */
- /* Obj must be a pointer to the first word of an object */
- /* we allocated. It is unsafe to explicitly deallocate */
- /* the object containing link. Explicitly deallocating */
- /* obj may or may not cause link to eventually be */
- /* cleared. */
-GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
- /* Returns 0 if link was not actually registered. */
- /* Undoes a registration by either of the above two */
- /* routines. */
-
-/* Auxiliary fns to make finalization work correctly with displaced */
-/* pointers introduced by the debugging allocators. */
-GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data));
-GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data));
-
-/* Returns !=0 if GC_invoke_finalizers has something to do. */
-GC_API int GC_should_invoke_finalizers GC_PROTO((void));
-
-GC_API int GC_invoke_finalizers GC_PROTO((void));
- /* Run finalizers for all objects that are ready to */
- /* be finalized. Return the number of finalizers */
- /* that were run. Normally this is also called */
- /* implicitly during some allocations. If */
- /* GC-finalize_on_demand is nonzero, it must be called */
- /* explicitly. */
-
-/* GC_set_warn_proc can be used to redirect or filter warning messages. */
-/* p may not be a NULL pointer. */
-typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg));
-GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
- /* Returns old warning procedure. */
-
-/* The following is intended to be used by a higher level */
-/* (e.g. cedar-like) finalization facility. It is expected */
-/* that finalization code will arrange for hidden pointers to */
-/* disappear. Otherwise objects can be accessed after they */
-/* have been collected. */
-/* Note that putting pointers in atomic objects or in */
-/* nonpointer slots of "typed" objects is equivalent to */
-/* disguising them in this way, and may have other advantages. */
-# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS)
- typedef GC_word GC_hidden_pointer;
-# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p))
-# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p)))
- /* Converting a hidden pointer to a real pointer requires verifying */
- /* that the object still exists. This involves acquiring the */
- /* allocator lock to avoid a race with the collector. */
-# endif /* I_HIDE_POINTERS */
-
-typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data));
-GC_API GC_PTR GC_call_with_alloc_lock
- GC_PROTO((GC_fn_type fn, GC_PTR client_data));
-
-/* Check that p and q point to the same object. */
-/* Fail conspicuously if they don't. */
-/* Returns the first argument. */
-/* Succeeds if neither p nor q points to the heap. */
-/* May succeed if both p and q point to between heap objects. */
-GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q));
-
-/* Checked pointer pre- and post- increment operations. Note that */
-/* the second argument is in units of bytes, not multiples of the */
-/* object size. This should either be invoked from a macro, or the */
-/* call should be automatically generated. */
-GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much));
-GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much));
-
-/* Check that p is visible */
-/* to the collector as a possibly pointer containing location. */
-/* If it isn't fail conspicuously. */
-/* Returns the argument in all cases. May erroneously succeed */
-/* in hard cases. (This is intended for debugging use with */
-/* untyped allocations. The idea is that it should be possible, though */
-/* slow, to add such a call to all indirect pointer stores.) */
-/* Currently useless for multithreaded worlds. */
-GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p));
-
-/* Check that if p is a pointer to a heap page, then it points to */
-/* a valid displacement within a heap object. */
-/* Fail conspicuously if this property does not hold. */
-/* Uninteresting with ALL_INTERIOR_POINTERS. */
-/* Always returns its argument. */
-GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p));
-
-/* Safer, but slow, pointer addition. Probably useful mainly with */
-/* a preprocessor. Useful only for heap pointers. */
-#ifdef GC_DEBUG
-# define GC_PTR_ADD3(x, n, type_of_result) \
- ((type_of_result)GC_same_obj((x)+(n), (x)))
-# define GC_PRE_INCR3(x, n, type_of_result) \
- ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
-# define GC_POST_INCR2(x, type_of_result) \
- ((type_of_result)GC_post_incr(&(x), sizeof(*x))
-# ifdef __GNUC__
-# define GC_PTR_ADD(x, n) \
- GC_PTR_ADD3(x, n, typeof(x))
-# define GC_PRE_INCR(x, n) \
- GC_PRE_INCR3(x, n, typeof(x))
-# define GC_POST_INCR(x, n) \
- GC_POST_INCR3(x, typeof(x))
-# else
- /* We can't do this right without typeof, which ANSI */
- /* decided was not sufficiently useful. Repeatedly */
- /* mentioning the arguments seems too dangerous to be */
- /* useful. So does not casting the result. */
-# define GC_PTR_ADD(x, n) ((x)+(n))
-# endif
-#else /* !GC_DEBUG */
-# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
-# define GC_PTR_ADD(x, n) ((x)+(n))
-# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
-# define GC_PRE_INCR(x, n) ((x) += (n))
-# define GC_POST_INCR2(x, n, type_of_result) ((x)++)
-# define GC_POST_INCR(x, n) ((x)++)
-#endif
-
-/* Safer assignment of a pointer to a nonstack location. */
-#ifdef GC_DEBUG
-# ifdef __STDC__
-# define GC_PTR_STORE(p, q) \
- (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
-# else
-# define GC_PTR_STORE(p, q) \
- (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q))
-# endif
-#else /* !GC_DEBUG */
-# define GC_PTR_STORE(p, q) *((p) = (q))
-#endif
-
-/* Fynctions called to report pointer checking errors */
-GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
-
-GC_API void (*GC_is_valid_displacement_print_proc)
- GC_PROTO((GC_PTR p));
-
-GC_API void (*GC_is_visible_print_proc)
- GC_PROTO((GC_PTR p));
-
-#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
-# define SOLARIS_THREADS
-#endif
-
-#ifdef SOLARIS_THREADS
-/* We need to intercept calls to many of the threads primitives, so */
-/* that we can locate thread stacks and stop the world. */
-/* Note also that the collector cannot see thread specific data. */
-/* Thread specific data should generally consist of pointers to */
-/* uncollectable objects, which are deallocated using the destructor */
-/* facility in thr_keycreate. */
-# include <thread.h>
-# include <signal.h>
- int GC_thr_create(void *stack_base, size_t stack_size,
- void *(*start_routine)(void *), void *arg, long flags,
- thread_t *new_thread);
- int GC_thr_join(thread_t wait_for, thread_t *departed, void **status);
- int GC_thr_suspend(thread_t target_thread);
- int GC_thr_continue(thread_t target_thread);
- void * GC_dlopen(const char *path, int mode);
-
-# ifdef _SOLARIS_PTHREADS
-# include <pthread.h>
- extern int GC_pthread_create(pthread_t *new_thread,
- const pthread_attr_t *attr,
- void * (*thread_execp)(void *), void *arg);
- extern int GC_pthread_join(pthread_t wait_for, void **status);
-
-# undef thread_t
-
-# define pthread_join GC_pthread_join
-# define pthread_create GC_pthread_create
-#endif
-
-# define thr_create GC_thr_create
-# define thr_join GC_thr_join
-# define thr_suspend GC_thr_suspend
-# define thr_continue GC_thr_continue
-# define dlopen GC_dlopen
-
-# endif /* SOLARIS_THREADS */
-
-
-#if !defined(USE_LD_WRAP) && \
- (defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
-/* We treat these similarly. */
-# include <pthread.h>
-# include <signal.h>
-
- int GC_pthread_create(pthread_t *new_thread,
- const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg);
- int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
- int GC_pthread_join(pthread_t thread, void **retval);
-
-# define pthread_create GC_pthread_create
-# define pthread_sigmask GC_pthread_sigmask
-# define pthread_join GC_pthread_join
-# define dlopen GC_dlopen
-
-#endif /* xxxxx_THREADS */
-
-# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
- defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
- defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
- /* Any flavor of threads except SRC_M3. */
-/* This returns a list of objects, linked through their first */
-/* word. Its use can greatly reduce lock contention problems, since */
-/* the allocation lock can be acquired and released many fewer times. */
-/* lb must be large enough to hold the pointer field. */
-GC_PTR GC_malloc_many(size_t lb);
-#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
- /* in returned list. */
-extern void GC_thr_init(); /* Needed for Solaris/X86 */
-
-#endif /* THREADS && !SRC_M3 */
-
-/*
- * If you are planning on putting
- * the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
- * from the statically loaded program section.
- * This circumvents a Solaris 2.X (X<=4) linker bug.
- */
-#if defined(sparc) || defined(__sparc)
-# define GC_INIT() { extern end, etext; \
- GC_noop(&end, &etext); }
-#else
-# if defined(__CYGWIN32__) && defined(GC_USE_DLL)
- /*
- * Similarly gnu-win32 DLLs need explicit initialization
- */
-# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
-# else
-# define GC_INIT()
-# endif
-#endif
-
-#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32)
- /* win32S may not free all resources on process exit. */
- /* This explicitly deallocates the heap. */
- GC_API void GC_win32_free_heap ();
-#endif
-
-#ifdef __cplusplus
- } /* end of extern "C" */
-#endif
-
-#endif /* _GC_H */
diff --git a/cord/private/cord_pos.h b/cord/private/cord_pos.h
deleted file mode 100644
index d2b24bb8..00000000
--- a/cord/private/cord_pos.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/* Boehm, May 19, 1994 2:23 pm PDT */
-# ifndef CORD_POSITION_H
-
-/* The representation of CORD_position. This is private to the */
-/* implementation, but the size is known to clients. Also */
-/* the implementation of some exported macros relies on it. */
-/* Don't use anything defined here and not in cord.h. */
-
-# define MAX_DEPTH 48
- /* The maximum depth of a balanced cord + 1. */
- /* We don't let cords get deeper than MAX_DEPTH. */
-
-struct CORD_pe {
- CORD pe_cord;
- size_t pe_start_pos;
-};
-
-/* A structure describing an entry on the path from the root */
-/* to current position. */
-typedef struct CORD_Pos {
- size_t cur_pos;
- int path_len;
-# define CORD_POS_INVALID (0x55555555)
- /* path_len == INVALID <==> position invalid */
- const char *cur_leaf; /* Current leaf, if it is a string. */
- /* If the current leaf is a function, */
- /* then this may point to function_buf */
- /* containing the next few characters. */
- /* Always points to a valid string */
- /* containing the current character */
- /* unless cur_end is 0. */
- size_t cur_start; /* Start position of cur_leaf */
- size_t cur_end; /* Ending position of cur_leaf */
- /* 0 if cur_leaf is invalid. */
- struct CORD_pe path[MAX_DEPTH + 1];
- /* path[path_len] is the leaf corresponding to cur_pos */
- /* path[0].pe_cord is the cord we point to. */
-# define FUNCTION_BUF_SZ 8
- char function_buf[FUNCTION_BUF_SZ]; /* Space for next few chars */
- /* from function node. */
-} CORD_pos[1];
-
-/* Extract the cord from a position: */
-CORD CORD_pos_to_cord(CORD_pos p);
-
-/* Extract the current index from a position: */
-size_t CORD_pos_to_index(CORD_pos p);
-
-/* Fetch the character located at the given position: */
-char CORD_pos_fetch(CORD_pos p);
-
-/* Initialize the position to refer to the give cord and index. */
-/* Note that this is the most expensive function on positions: */
-void CORD_set_pos(CORD_pos p, CORD x, size_t i);
-
-/* Advance the position to the next character. */
-/* P must be initialized and valid. */
-/* Invalidates p if past end: */
-void CORD_next(CORD_pos p);
-
-/* Move the position to the preceding character. */
-/* P must be initialized and valid. */
-/* Invalidates p if past beginning: */
-void CORD_prev(CORD_pos p);
-
-/* Is the position valid, i.e. inside the cord? */
-int CORD_pos_valid(CORD_pos p);
-
-char CORD__pos_fetch(CORD_pos);
-void CORD__next(CORD_pos);
-void CORD__prev(CORD_pos);
-
-#define CORD_pos_fetch(p) \
- (((p)[0].cur_end != 0)? \
- (p)[0].cur_leaf[(p)[0].cur_pos - (p)[0].cur_start] \
- : CORD__pos_fetch(p))
-
-#define CORD_next(p) \
- (((p)[0].cur_pos + 1 < (p)[0].cur_end)? \
- (p)[0].cur_pos++ \
- : (CORD__next(p), 0))
-
-#define CORD_prev(p) \
- (((p)[0].cur_end != 0 && (p)[0].cur_pos > (p)[0].cur_start)? \
- (p)[0].cur_pos-- \
- : (CORD__prev(p), 0))
-
-#define CORD_pos_to_index(p) ((p)[0].cur_pos)
-
-#define CORD_pos_to_cord(p) ((p)[0].path[0].pe_cord)
-
-#define CORD_pos_valid(p) ((p)[0].path_len != CORD_POS_INVALID)
-
-/* Some grubby stuff for performance-critical friends: */
-#define CORD_pos_chars_left(p) ((long)((p)[0].cur_end) - (long)((p)[0].cur_pos))
- /* Number of characters in cache. <= 0 ==> none */
-
-#define CORD_pos_advance(p,n) ((p)[0].cur_pos += (n) - 1, CORD_next(p))
- /* Advance position by n characters */
- /* 0 < n < CORD_pos_chars_left(p) */
-
-#define CORD_pos_cur_char_addr(p) \
- (p)[0].cur_leaf + ((p)[0].cur_pos - (p)[0].cur_start)
- /* address of current character in cache. */
-
-#endif
diff --git a/dbg_mlc.c b/dbg_mlc.c
index 20768715..be6c518c 100644
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -2,7 +2,7 @@
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
* Copyright (c) 1997 by Silicon Graphics. All rights reserved.
- * Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -14,7 +14,7 @@
* modified is included with the above copyright notice.
*/
-#include "dbg_mlc.h"
+#include "private/dbg_mlc.h"
void GC_default_print_heap_obj_proc();
GC_API void GC_register_finalizer_no_order
@@ -22,9 +22,14 @@ GC_API void GC_register_finalizer_no_order
GC_finalization_proc *ofn, GC_PTR *ocd));
+#ifndef SHORT_DBG_HDRS
/* Check whether object with base pointer p has debugging info */
/* p is assumed to point to a legitimate object in our part */
/* of the heap. */
+/* Note that if DBG_HDRS_ALL is set, uncollectable objects */
+/* on free lists may not have debug information set. Thus it's */
+/* not always safe to return TRUE, even if the client does */
+/* its part. */
GC_bool GC_has_debug_info(p)
ptr_t p;
{
@@ -46,6 +51,7 @@ ptr_t p;
}
return(FALSE);
}
+#endif
#ifdef KEEP_BACK_PTRS
/* Store back pointer to source in dest, if that appears to be possible. */
@@ -207,14 +213,46 @@ word integer;
# endif
((oh *)p) -> oh_string = string;
((oh *)p) -> oh_int = integer;
- ((oh *)p) -> oh_sz = sz;
- ((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
- ((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
+# ifndef SHORT_DBG_HDRS
+ ((oh *)p) -> oh_sz = sz;
+ ((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
+ ((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
result[ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result;
+# endif
UNLOCK();
return((ptr_t)result);
}
+#ifdef DBG_HDRS_ALL
+/* Store debugging info into p. Return displaced pointer. */
+/* This version assumes we do hold the allocation lock. */
+ptr_t GC_store_debug_info_inner(p, sz, string, integer)
+register ptr_t p; /* base pointer */
+word sz; /* bytes */
+char * string;
+word integer;
+{
+ register word * result = (word *)((oh *)p + 1);
+
+ /* There is some argument that we should dissble signals here. */
+ /* But that's expensive. And this way things should only appear */
+ /* inconsistent while we're in the handler. */
+# ifdef KEEP_BACK_PTRS
+ ((oh *)p) -> oh_back_ptr = 0;
+# endif
+ ((oh *)p) -> oh_string = string;
+ ((oh *)p) -> oh_int = integer;
+# ifndef SHORT_DBG_HDRS
+ ((oh *)p) -> oh_sz = sz;
+ ((oh *)p) -> oh_sf = START_FLAG ^ (word)result;
+ ((word *)p)[BYTES_TO_WORDS(GC_size(p))-1] =
+ result[ROUNDED_UP_WORDS(sz)] = END_FLAG ^ (word)result;
+# endif
+ return((ptr_t)result);
+}
+#endif
+
+#ifndef SHORT_DBG_HDRS
/* Check the object with debugging info at ohdr */
/* return NIL if it's OK. Else return clobbered */
/* address. */
@@ -238,6 +276,7 @@ register oh * ohdr;
}
return(0);
}
+#endif /* !SHORT_DBG_HDRS */
void GC_print_obj(p)
ptr_t p;
@@ -246,13 +285,21 @@ ptr_t p;
GC_err_printf1("0x%lx (", ((unsigned long)ohdr + sizeof(oh)));
GC_err_puts(ohdr -> oh_string);
- GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
- (unsigned long)(ohdr -> oh_sz));
+# ifdef SHORT_DBG_HDRS
+ GC_err_printf1(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int));
+# else
+ GC_err_printf2(":%ld, sz=%ld)\n", (unsigned long)(ohdr -> oh_int),
+ (unsigned long)(ohdr -> oh_sz));
+# endif
PRINT_CALL_CHAIN(ohdr);
}
-void GC_debug_print_heap_obj_proc(p)
-ptr_t p;
+# if defined(__STDC__) || defined(__cplusplus)
+ void GC_debug_print_heap_obj_proc(ptr_t p)
+# else
+ void GC_debug_print_heap_obj_proc(p)
+ ptr_t p;
+# endif
{
if (GC_has_debug_info(p)) {
GC_print_obj(p);
@@ -261,6 +308,7 @@ ptr_t p;
}
}
+#ifndef SHORT_DBG_HDRS
void GC_print_smashed_obj(p, clobbered_addr)
ptr_t p, clobbered_addr;
{
@@ -283,12 +331,19 @@ ptr_t p, clobbered_addr;
PRINT_CALL_CHAIN(ohdr);
}
}
+#endif
-void GC_check_heap_proc();
+void GC_check_heap_proc GC_PROTO((void));
+
+void GC_do_nothing() {}
void GC_start_debugging()
{
- GC_check_heap = GC_check_heap_proc;
+# ifndef SHORT_DBG_HDRS
+ GC_check_heap = GC_check_heap_proc;
+# else
+ GC_check_heap = GC_do_nothing;
+# endif
GC_print_heap_obj = GC_debug_print_heap_obj_proc;
GC_debugging_started = TRUE;
GC_register_displacement((word)sizeof(oh));
@@ -333,6 +388,43 @@ void GC_start_debugging()
return (GC_store_debug_info(result, (word)lb, s, (word)i));
}
+# ifdef DBG_HDRS_ALL
+/*
+ * An allocation function for internal use.
+ * Normally internally allocated objects do not have debug information.
+ * But in this case, we need to make sure that all objects have debug
+ * headers.
+ * We assume debugging was started in collector initialization,
+ * and we already hold the GC lock.
+ */
+ GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k)
+ {
+ GC_PTR result = GC_generic_malloc_inner(lb + DEBUG_BYTES, k);
+
+ if (result == 0) {
+ GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
+ (unsigned long) lb);
+ return(0);
+ }
+ ADD_CALL_CHAIN(result, ra);
+ return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
+ }
+
+ GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb, int k)
+ {
+ GC_PTR result = GC_generic_malloc_inner_ignore_off_page(
+ lb + DEBUG_BYTES, k);
+
+ if (result == 0) {
+ GC_err_printf1("GC internal allocation (%ld bytes) returning NIL\n",
+ (unsigned long) lb);
+ return(0);
+ }
+ ADD_CALL_CHAIN(result, ra);
+ return (GC_store_debug_info_inner(result, (word)lb, "INTERNAL", (word)0));
+ }
+# endif
+
#ifdef STUBBORN_ALLOC
# ifdef __STDC__
GC_PTR GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
@@ -525,18 +617,20 @@ GC_PTR p;
"GC_debug_free called on pointer %lx wo debugging info\n",
(unsigned long)p);
} else {
- clobbered = GC_check_annotated_obj((oh *)base);
- if (clobbered != 0) {
- if (((oh *)base) -> oh_sz == GC_size(base)) {
+# ifndef SHORT_DBG_HDRS
+ clobbered = GC_check_annotated_obj((oh *)base);
+ if (clobbered != 0) {
+ if (((oh *)base) -> oh_sz == GC_size(base)) {
GC_err_printf0(
"GC_debug_free: found previously deallocated (?) object at ");
- } else {
+ } else {
GC_err_printf0("GC_debug_free: found smashed location at ");
+ }
+ GC_print_smashed_obj(p, clobbered);
}
- GC_print_smashed_obj(p, clobbered);
- }
- /* Invalidate size */
- ((oh *)base) -> oh_sz = GC_size(base);
+ /* Invalidate size */
+ ((oh *)base) -> oh_sz = GC_size(base);
+# endif /* SHORT_DBG_HDRS */
}
if (GC_find_leak) {
GC_free(base);
@@ -610,12 +704,16 @@ GC_PTR p;
GC_err_printf0("GC_debug_realloc: encountered bad kind\n");
ABORT("bad kind");
}
- clobbered = GC_check_annotated_obj((oh *)base);
- if (clobbered != 0) {
+# ifdef SHORT_DBG_HDRS
+ old_sz = GC_size(base) - sizeof(oh);
+# else
+ clobbered = GC_check_annotated_obj((oh *)base);
+ if (clobbered != 0) {
GC_err_printf0("GC_debug_realloc: found smashed location at ");
GC_print_smashed_obj(p, clobbered);
- }
- old_sz = ((oh *)base) -> oh_sz;
+ }
+ old_sz = ((oh *)base) -> oh_sz;
+# endif
if (old_sz < copy_sz) copy_sz = old_sz;
if (result == 0) return(0);
BCOPY(p, result, copy_sz);
@@ -623,11 +721,16 @@ GC_PTR p;
return(result);
}
+#ifndef SHORT_DBG_HDRS
/* Check all marked objects in the given block for validity */
/*ARGSUSED*/
-void GC_check_heap_block(hbp, dummy)
-register struct hblk *hbp; /* ptr to current heap block */
-word dummy;
+# if defined(__STDC__) || defined(__cplusplus)
+ void GC_check_heap_block(register struct hblk *hbp, word dummy)
+# else
+ void GC_check_heap_block(hbp, dummy)
+ register struct hblk *hbp; /* ptr to current heap block */
+ word dummy;
+# endif
{
register struct hblkhdr * hhdr = HDR(hbp);
register word sz = hhdr -> hb_sz;
@@ -671,6 +774,8 @@ void GC_check_heap_proc()
GC_apply_to_all_blocks(GC_check_heap_block, (word)0);
}
+#endif /* !SHORT_DBG_HDRS */
+
struct closure {
GC_finalization_proc cl_fn;
GC_PTR cl_data;
@@ -685,7 +790,12 @@ struct closure {
# endif
{
struct closure * result =
- (struct closure *) GC_malloc(sizeof (struct closure));
+# ifdef DBG_HDRS_ALL
+ (struct closure *) GC_debug_malloc(sizeof (struct closure),
+ GC_EXTRAS);
+# else
+ (struct closure *) GC_malloc(sizeof (struct closure));
+# endif
result -> cl_fn = fn;
result -> cl_data = data;
diff --git a/dyn_load.c b/dyn_load.c
index 74aacd71..8830692f 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -26,15 +26,15 @@
* None of this is safe with dlclose and incremental collection.
* But then not much of anything is safe in the presence of dlclose.
*/
-#ifndef MACOS
+#if !defined(MACOS) && !defined(_WIN32_WCE)
# include <sys/types.h>
#endif
-#include "gc_priv.h"
+#include "private/gc_priv.h"
/* BTL: avoid circular redefinition of dlopen if SOLARIS_THREADS defined */
# if (defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \
|| defined(HPUX_THREADS) || defined(IRIX_THREADS)) && defined(dlopen) \
- && !defined(USE_LD_WRAP)
+ && !defined(GC_USE_LD_WRAP)
/* To support threads in Solaris, gc.h interposes on dlopen by */
/* defining "dlopen" to be "GC_dlopen", which is implemented below. */
/* However, both GC_FirstDLOpenedLinkMap() and GC_dlopen() use the */
@@ -46,9 +46,11 @@
# undef GC_must_restore_redefined_dlopen
# endif
-#if (defined(DYNAMIC_LOADING) || defined(MSWIN32)) && !defined(PCR)
+#if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE)) \
+ && !defined(PCR)
#if !defined(SUNOS4) && !defined(SUNOS5DL) && !defined(IRIX5) && \
- !defined(MSWIN32) && !(defined(ALPHA) && defined(OSF1)) && \
+ !defined(MSWIN32) && !defined(MSWINCE) && \
+ !(defined(ALPHA) && defined(OSF1)) && \
!defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \
!defined(RS6000) && !defined(SCO_ELF)
--> We only know how to find data segments of dynamic libraries for the
@@ -193,7 +195,7 @@ static ptr_t GC_first_common()
#include <dlfcn.h>
-#ifdef USE_LD_WRAP
+#ifdef GC_USE_LD_WRAP
void * __wrap_dlopen(const char *path, int mode)
#else
void * GC_dlopen(path, mode)
@@ -207,7 +209,7 @@ static ptr_t GC_first_common()
# ifndef USE_PROC_FOR_LIBRARIES
dont_gc_save = disable_gc_for_dlopen();
# endif
-# ifdef USE_LD_WRAP
+# ifdef GC_USE_LD_WRAP
result = __real_dlopen(path, mode);
# else
result = dlopen(path, mode);
@@ -299,6 +301,110 @@ void GC_register_dynamic_libraries()
#if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF)
+#ifdef USE_PROC_FOR_LIBRARIES
+
+#include <string.h>
+
+#ifdef LINUX_THREADS
+--> To support threads here, we would need to filter out all stack
+--> segments. This should just be a SMOP.
+#endif
+
+#ifdef GC_USE_LD_WRAP
+# define READ __wrap_read
+#else
+# define READ read
+#endif
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#define MAPS_BUF_SIZE (32*1024)
+
+void GC_register_dynamic_libraries()
+{
+ int f; /* File descriptor for /proc/self/maps. Empirically */
+ /* it should not be kept open across calls. This may */
+ /* be related to the fact that older kernels may not */
+ /* support seeking on the file. */
+ int result;
+ char prot_buf[5];
+ char maps_buf[MAPS_BUF_SIZE];
+ char *buf_ptr;
+ int count;
+ word start, end;
+ unsigned int maj_dev, min_dev;
+ word least_ha, greatest_ha;
+ unsigned i;
+ word datastart = (word)(DATASTART);
+
+ /* Read /proc/self/maps */
+ /* Note that we may not allocate, and thus can't use stdio. */
+ f = open("/proc/self/maps", O_RDONLY);
+ if (-1 == f) ABORT("Couldn't open /proc/self/maps");
+ result = read(f, maps_buf, MAPS_BUF_SIZE);
+ if (result <= 0) ABORT("Couldn't read /proc/self/maps");
+ if (result == MAPS_BUF_SIZE) ABORT("Too many memory mappings");
+ maps_buf[result] = '\0';
+ buf_ptr = maps_buf;
+ /* Compute heap bounds. Should be done by add_to_heap? */
+ least_ha = (word)(-1);
+ greatest_ha = 0;
+ for (i = 0; i < GC_n_heap_sects; ++i) {
+ word sect_start = (word)GC_heap_sects[i].hs_start;
+ word sect_end = sect_start + GC_heap_sects[i].hs_bytes;
+ if (sect_start < least_ha) least_ha = sect_start;
+ if (sect_end > greatest_ha) greatest_ha = sect_end;
+ }
+ if (greatest_ha < (word)GC_scratch_last_end_ptr)
+ greatest_ha = (word)GC_scratch_last_end_ptr;
+ for (;;) {
+ count = 0;
+ result = sscanf(buf_ptr, "%lx-%lx %4s %*lx %x:%x%*[^\n]\n%n",
+ &start, &end, prot_buf, &maj_dev, &min_dev, &count);
+ if (0 == result || EOF == result) {
+ close(f);
+ return;
+ }
+ if (result < 5 || 0 == count) ABORT("Bad /proc/self/maps format\n");
+ buf_ptr += count;
+ if (strchr(prot_buf, 'w') != 0) {
+ /* This is a writable mapping. Add it to */
+ /* the root set unless it is already otherwise */
+ /* accounted for. */
+ if (start <= (word)GC_stackbottom && end >= (word)GC_stackbottom) {
+ /* Stack mapping; discard */
+ continue;
+ }
+ if (start <= datastart && end > datastart && maj_dev != 0) {
+ /* Main data segment; discard */
+ continue;
+ }
+ /* The rest of this assumes that there is no mapping */
+ /* spanning the beginning of the data segment, or extending */
+ /* beyond the entire heap at both ends. */
+ /* Empirically these assumptions hold. */
+
+ if (start < (word)DATAEND && end > (word)DATAEND) {
+ /* Rld may use space at the end of the main data */
+ /* segment. Thus we add that in. */
+ start = (word)DATAEND;
+ }
+ if (start < least_ha && end > least_ha) {
+ end = least_ha;
+ }
+ if (start < greatest_ha && end > greatest_ha) {
+ start = greatest_ha;
+ }
+ if (start >= least_ha && end <= greatest_ha) continue;
+ GC_add_roots_inner((char *)start, (char *)end, TRUE);
+ }
+ }
+}
+
+#else
+
/* Dynamic loading code for Linux running ELF. Somewhat tested on
* Linux/x86, untested but hopefully should work on Linux/Alpha.
* This code was derived from the Solaris/ELF support. Thanks to
@@ -379,9 +485,11 @@ void GC_register_dynamic_libraries()
}
}
-#endif
+#endif /* !USE_PROC_FOR_LIBRARIES */
-#if defined(IRIX5) || defined(USE_PROC_FOR_LIBRARIES)
+#endif /* LINUX */
+
+#if defined(IRIX5) || (defined(USE_PROC_FOR_LIBRARIES) && !defined(LINUX))
#include <sys/procfs.h>
#include <sys/stat.h>
@@ -393,9 +501,6 @@ extern void * GC_roots_present();
/* The type is a lie, since the real type doesn't make sense here, */
/* and we only test for NULL. */
-#ifndef GC_scratch_last_end_ptr /* Never an extern any more? */
-extern ptr_t GC_scratch_last_end_ptr; /* End of GC_scratch_alloc arena */
-#endif
/* We use /proc to track down all parts of the address space that are */
/* mapped by the process, and throw out regions we know we shouldn't */
@@ -504,7 +609,7 @@ void GC_register_dynamic_libraries()
# endif /* USE_PROC || IRIX5 */
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# define WIN32_LEAN_AND_MEAN
# define NOSERVICE
@@ -513,86 +618,97 @@ void GC_register_dynamic_libraries()
/* We traverse the entire address space and register all segments */
/* that could possibly have been written to. */
- DWORD GC_allocation_granularity;
extern GC_bool GC_is_heap_base (ptr_t p);
# ifdef WIN32_THREADS
extern void GC_get_next_stack(char *start, char **lo, char **hi);
-# endif
-
- void GC_cond_add_roots(char *base, char * limit)
- {
- char dummy;
- char * stack_top
- = (char *) ((word)(&dummy) & ~(GC_allocation_granularity-1));
- if (base == limit) return;
-# ifdef WIN32_THREADS
+ void GC_cond_add_roots(char *base, char * limit)
{
- char * curr_base = base;
- char * next_stack_lo;
- char * next_stack_hi;
-
- for(;;) {
- GC_get_next_stack(curr_base, &next_stack_lo, &next_stack_hi);
- if (next_stack_lo >= limit) break;
- GC_add_roots_inner(curr_base, next_stack_lo, TRUE);
- curr_base = next_stack_hi;
- }
- if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE);
+ char * curr_base = base;
+ char * next_stack_lo;
+ char * next_stack_hi;
+
+ if (base == limit) return;
+ for(;;) {
+ GC_get_next_stack(curr_base, &next_stack_lo, &next_stack_hi);
+ if (next_stack_lo >= limit) break;
+ GC_add_roots_inner(curr_base, next_stack_lo, TRUE);
+ curr_base = next_stack_hi;
+ }
+ if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE);
}
-# else
- if (limit > stack_top && base < GC_stackbottom) {
- /* Part of the stack; ignore it. */
- return;
- }
- GC_add_roots_inner(base, limit, TRUE);
-# endif
- }
-
+# else
+ void GC_cond_add_roots(char *base, char * limit)
+ {
+ char dummy;
+ char * stack_top
+ = (char *) ((word)(&dummy) & ~(GC_sysinfo.dwAllocationGranularity-1));
+ if (base == limit) return;
+ if (limit > stack_top && base < GC_stackbottom) {
+ /* Part of the stack; ignore it. */
+ return;
+ }
+ GC_add_roots_inner(base, limit, TRUE);
+ }
+# endif
+
+# ifndef MSWINCE
extern GC_bool GC_win32s;
+# endif
void GC_register_dynamic_libraries()
{
MEMORY_BASIC_INFORMATION buf;
- SYSTEM_INFO sysinfo;
DWORD result;
DWORD protect;
LPVOID p;
char * base;
char * limit, * new_limit;
-
- if (GC_win32s) return;
- GetSystemInfo(&sysinfo);
- base = limit = p = sysinfo.lpMinimumApplicationAddress;
- GC_allocation_granularity = sysinfo.dwAllocationGranularity;
- while (p < sysinfo.lpMaximumApplicationAddress) {
+
+# ifdef MSWIN32
+ if (GC_win32s) return;
+# endif
+ base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
+# if defined(MSWINCE) && !defined(_WIN32_WCE_EMULATION)
+ /* Only the first 32 MB of address space belongs to the current process */
+ while (p < (LPVOID)0x02000000) {
result = VirtualQuery(p, &buf, sizeof(buf));
- if (result != sizeof(buf)) {
- ABORT("Weird VirtualQuery result");
- }
- new_limit = (char *)p + buf.RegionSize;
- protect = buf.Protect;
- if (buf.State == MEM_COMMIT
- && (protect == PAGE_EXECUTE_READWRITE
- || protect == PAGE_READWRITE)
- && !GC_is_heap_base(buf.AllocationBase)) {
- if ((char *)p == limit) {
- limit = new_limit;
- } else {
- GC_cond_add_roots(base, limit);
- base = p;
- limit = new_limit;
- }
- }
+ if (result == 0) {
+ /* Page is free; advance to the next possible allocation base */
+ new_limit = (char *)
+ (((DWORD) p + GC_sysinfo.dwAllocationGranularity)
+ & ~(GC_sysinfo.dwAllocationGranularity-1));
+ } else
+# else
+ while (p < GC_sysinfo.lpMaximumApplicationAddress) {
+ result = VirtualQuery(p, &buf, sizeof(buf));
+# endif
+ {
+ if (result != sizeof(buf)) {
+ ABORT("Weird VirtualQuery result");
+ }
+ new_limit = (char *)p + buf.RegionSize;
+ protect = buf.Protect;
+ if (buf.State == MEM_COMMIT
+ && (protect == PAGE_EXECUTE_READWRITE
+ || protect == PAGE_READWRITE)
+ && !GC_is_heap_base(buf.AllocationBase)) {
+ if ((char *)p != limit) {
+ GC_cond_add_roots(base, limit);
+ base = p;
+ }
+ limit = new_limit;
+ }
+ }
if (p > (LPVOID)new_limit /* overflow */) break;
p = (LPVOID)new_limit;
}
GC_cond_add_roots(base, limit);
}
-#endif /* MSWIN32 */
-
+#endif /* MSWIN32 || MSWINCE */
+
#if defined(ALPHA) && defined(OSF1)
#include <loader.h>
diff --git a/finalize.c b/finalize.c
index e70a9ff1..12fc6813 100644
--- a/finalize.c
+++ b/finalize.c
@@ -14,8 +14,8 @@
*/
/* Boehm, February 1, 1996 1:19 pm PST */
# define I_HIDE_POINTERS
-# include "gc_priv.h"
-# include "gc_mark.h"
+# include "private/gc_priv.h"
+# include "private/gc_mark.h"
# ifdef FINALIZE_ON_DEMAND
int GC_finalize_on_demand = 1;
@@ -110,7 +110,7 @@ signed_word * log_size_ptr;
word old_size = ((log_old_size == -1)? 0: (1 << log_old_size));
register word new_size = 1 << log_new_size;
struct hash_chain_entry **new_table = (struct hash_chain_entry **)
- GC_generic_malloc_inner_ignore_off_page(
+ GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
(size_t)new_size * sizeof(struct hash_chain_entry *), NORMAL);
if (new_table == 0) {
@@ -199,13 +199,8 @@ signed_word * log_size_ptr;
return(1);
}
}
-# ifdef THREADS
- new_dl = (struct disappearing_link *)
- GC_generic_malloc_inner(sizeof(struct disappearing_link),NORMAL);
-# else
- new_dl = (struct disappearing_link *)
- GC_malloc(sizeof(struct disappearing_link));
-# endif
+ new_dl = (struct disappearing_link *)
+ GC_INTERNAL_MALLOC(sizeof(struct disappearing_link),NORMAL);
if (new_dl != 0) {
new_dl -> dl_hidden_obj = HIDE_POINTER(obj);
new_dl -> dl_hidden_link = HIDE_POINTER(link);
@@ -248,7 +243,11 @@ signed_word * log_size_ptr;
GC_dl_entries--;
UNLOCK();
ENABLE_SIGNALS();
- GC_free((GC_PTR)curr_dl);
+# ifdef DBG_HDRS_ALL
+ dl_next(curr_dl) = 0;
+# else
+ GC_free((GC_PTR)curr_dl);
+# endif
return(1);
}
prev_dl = curr_dl;
@@ -369,7 +368,7 @@ finalization_mark_proc * mp;
/* May not happen if we get a signal. But a high */
/* estimate will only make the table larger than */
/* necessary. */
-# ifndef THREADS
+# if !defined(THREADS) && !defined(DBG_HDRS_ALL)
GC_free((GC_PTR)curr_fo);
# endif
} else {
@@ -402,13 +401,8 @@ finalization_mark_proc * mp;
# endif
return;
}
-# ifdef THREADS
- new_fo = (struct finalizable_object *)
- GC_generic_malloc_inner(sizeof(struct finalizable_object),NORMAL);
-# else
- new_fo = (struct finalizable_object *)
- GC_malloc(sizeof(struct finalizable_object));
-# endif
+ new_fo = (struct finalizable_object *)
+ GC_INTERNAL_MALLOC(sizeof(struct finalizable_object),NORMAL);
if (new_fo != 0) {
new_fo -> fo_hidden_base = (word)HIDE_POINTER(base);
new_fo -> fo_fn = fn;
@@ -478,6 +472,34 @@ finalization_mark_proc * mp;
ocd, GC_null_finalize_mark_proc);
}
+#ifndef NO_DEBUGGING
+void GC_dump_finalization()
+{
+ struct disappearing_link * curr_dl;
+ struct finalizable_object * curr_fo;
+ ptr_t real_ptr, real_link;
+ int dl_size = (log_dl_table_size == -1 ) ? 0 : (1 << log_dl_table_size);
+ int fo_size = (log_fo_table_size == -1 ) ? 0 : (1 << log_fo_table_size);
+ int i;
+
+ GC_printf0("Disappearing links:\n");
+ for (i = 0; i < dl_size; i++) {
+ for (curr_dl = dl_head[i]; curr_dl != 0; curr_dl = dl_next(curr_dl)) {
+ real_ptr = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_obj);
+ real_link = (ptr_t)REVEAL_POINTER(curr_dl -> dl_hidden_link);
+ GC_printf2("Object: 0x%lx, Link:0x%lx\n", real_ptr, real_link);
+ }
+ }
+ GC_printf0("Finalizers:\n");
+ for (i = 0; i < fo_size; i++) {
+ for (curr_fo = fo_head[i]; curr_fo != 0; curr_fo = fo_next(curr_fo)) {
+ real_ptr = (ptr_t)REVEAL_POINTER(curr_fo -> fo_hidden_base);
+ GC_printf1("Finalizable object: 0x%lx\n", real_ptr);
+ }
+ }
+}
+#endif
+
/* Called with world stopped. Cause disappearing links to disappear, */
/* and invoke finalizers. */
void GC_finalize()
@@ -758,7 +780,9 @@ int GC_invoke_finalizers()
# endif
result = (*fn)(client_data);
# ifdef THREADS
- UNSET_LOCK_HOLDER();
+# ifndef GC_ASSERTIONS
+ UNSET_LOCK_HOLDER();
+# endif /* o.w. UNLOCK() does it implicitly */
UNLOCK();
ENABLE_SIGNALS();
# endif
diff --git a/gc.h b/gc.h
deleted file mode 100644
index d7cd8996..00000000
--- a/gc.h
+++ /dev/null
@@ -1,804 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
- * Copyright 1996-1999 by Silicon Graphics. All rights reserved.
- * Copyright 1999 by Hewlett-Packard Company. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-/*
- * Note that this defines a large number of tuning hooks, which can
- * safely be ignored in nearly all cases. For normal use it suffices
- * to call only GC_MALLOC and perhaps GC_REALLOC.
- * For better performance, also look at GC_MALLOC_ATOMIC, and
- * GC_enable_incremental. If you need an action to be performed
- * immediately before an object is collected, look at GC_register_finalizer.
- * If you are using Solaris threads, look at the end of this file.
- * Everything else is best ignored unless you encounter performance
- * problems.
- */
-
-#ifndef _GC_H
-
-# define _GC_H
-# define __GC
-# include <stddef.h>
-
-#if defined(__CYGWIN32__) && defined(GC_USE_DLL)
-#include "libgc_globals.h"
-#endif
-
-#if defined(__MINGW32__) && defined(WIN32_THREADS)
-# ifdef GC_BUILD
-# define GC_API __declspec(dllexport)
-# else
-# define GC_API __declspec(dllimport)
-# endif
-#endif
-
-#if defined(_MSC_VER) && defined(_DLL)
-# ifdef GC_BUILD
-# define GC_API __declspec(dllexport)
-# else
-# define GC_API __declspec(dllimport)
-# endif
-#endif
-
-#if defined(__WATCOMC__) && defined(GC_DLL)
-# ifdef GC_BUILD
-# define GC_API extern __declspec(dllexport)
-# else
-# define GC_API extern __declspec(dllimport)
-# endif
-#endif
-
-#ifndef GC_API
-#define GC_API extern
-#endif
-
-# if defined(__STDC__) || defined(__cplusplus)
-# define GC_PROTO(args) args
- typedef void * GC_PTR;
-# define GC_CONST const
-# else
-# define GC_PROTO(args) ()
- typedef char * GC_PTR;
-# define GC_CONST
-# endif
-
-# ifdef __cplusplus
- extern "C" {
-# endif
-
-
-/* Define word and signed_word to be unsigned and signed types of the */
-/* size as char * or void *. There seems to be no way to do this */
-/* even semi-portably. The following is probably no better/worse */
-/* than almost anything else. */
-/* The ANSI standard suggests that size_t and ptr_diff_t might be */
-/* better choices. But those appear to have incorrect definitions */
-/* on may systems. Notably "typedef int size_t" seems to be both */
-/* frequent and WRONG. */
-typedef unsigned long GC_word;
-typedef long GC_signed_word;
-
-/* Public read-only variables */
-
-GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
- /* Includes empty GCs at startup. */
-
-
-/* Public R/W variables */
-
-GC_API GC_PTR (*GC_oom_fn) GC_PROTO((size_t bytes_requested));
- /* When there is insufficient memory to satisfy */
- /* an allocation request, we return */
- /* (*GC_oom_fn)(). By default this just */
- /* returns 0. */
- /* If it returns, it must return 0 or a valid */
- /* pointer to a previously allocated heap */
- /* object. */
-
-GC_API int GC_find_leak;
- /* Do not actually garbage collect, but simply */
- /* report inaccessible memory that was not */
- /* deallocated with GC_free. Initial value */
- /* is determined by FIND_LEAK macro. */
-
-GC_API int GC_quiet; /* Disable statistics output. Only matters if */
- /* collector has been compiled with statistics */
- /* enabled. This involves a performance cost, */
- /* and is thus not the default. */
-
-GC_API int GC_finalize_on_demand;
- /* If nonzero, finalizers will only be run in */
- /* response to an eplit GC_invoke_finalizers */
- /* call. The default is determined by whether */
- /* the FINALIZE_ON_DEMAND macro is defined */
- /* when the collector is built. */
-
-GC_API int GC_java_finalization;
- /* Mark objects reachable from finalizable */
- /* objects in a separate postpass. This makes */
- /* it a bit safer to use non-topologically- */
- /* ordered finalization. Default value is */
- /* determined by JAVA_FINALIZATION macro. */
-
-GC_API int GC_dont_gc; /* Dont collect unless explicitly requested, e.g. */
- /* because it's not safe. */
-
-GC_API int GC_dont_expand;
- /* Dont expand heap unless explicitly requested */
- /* or forced to. */
-
-GC_API int GC_use_entire_heap;
- /* Causes the nonincremental collector to use the */
- /* entire heap before collecting. This was the only */
- /* option for GC versions < 5.0. This sometimes */
- /* results in more large block fragmentation, since */
- /* very larg blocks will tend to get broken up */
- /* during each GC cycle. It is likely to result in a */
- /* larger working set, but lower collection */
- /* frequencies, and hence fewer instructions executed */
- /* in the collector. */
-
-GC_API int GC_full_freq; /* Number of partial collections between */
- /* full collections. Matters only if */
- /* GC_incremental is set. */
- /* Full collections are also triggered if */
- /* the collector detects a substantial */
- /* increase in the number of in-use heap */
- /* blocks. Values in the tens are now */
- /* perfectly reasonable, unlike for */
- /* earlier GC versions. */
-
-GC_API GC_word GC_non_gc_bytes;
- /* Bytes not considered candidates for collection. */
- /* Used only to control scheduling of collections. */
-
-GC_API GC_word GC_free_space_divisor;
- /* We try to make sure that we allocate at */
- /* least N/GC_free_space_divisor bytes between */
- /* collections, where N is the heap size plus */
- /* a rough estimate of the root set size. */
- /* Initially, GC_free_space_divisor = 4. */
- /* Increasing its value will use less space */
- /* but more collection time. Decreasing it */
- /* will appreciably decrease collection time */
- /* at the expense of space. */
- /* GC_free_space_divisor = 1 will effectively */
- /* disable collections. */
-
-GC_API GC_word GC_max_retries;
- /* The maximum number of GCs attempted before */
- /* reporting out of memory after heap */
- /* expansion fails. Initially 0. */
-
-
-GC_API char *GC_stackbottom; /* Cool end of user stack. */
- /* May be set in the client prior to */
- /* calling any GC_ routines. This */
- /* avoids some overhead, and */
- /* potentially some signals that can */
- /* confuse debuggers. Otherwise the */
- /* collector attempts to set it */
- /* automatically. */
- /* For multithreaded code, this is the */
- /* cold end of the stack for the */
- /* primordial thread. */
-
-/* Public procedures */
-/*
- * general purpose allocation routines, with roughly malloc calling conv.
- * The atomic versions promise that no relevant pointers are contained
- * in the object. The nonatomic versions guarantee that the new object
- * is cleared. GC_malloc_stubborn promises that no changes to the object
- * will occur after GC_end_stubborn_change has been called on the
- * result of GC_malloc_stubborn. GC_malloc_uncollectable allocates an object
- * that is scanned for pointers to collectable objects, but is not itself
- * collectable. GC_malloc_uncollectable and GC_free called on the resulting
- * object implicitly update GC_non_gc_bytes appropriately.
- */
-GC_API GC_PTR GC_malloc GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_atomic GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_uncollectable GC_PROTO((size_t size_in_bytes));
-GC_API GC_PTR GC_malloc_stubborn GC_PROTO((size_t size_in_bytes));
-
-/* The following is only defined if the library has been suitably */
-/* compiled: */
-GC_API GC_PTR GC_malloc_atomic_uncollectable GC_PROTO((size_t size_in_bytes));
-
-/* Explicitly deallocate an object. Dangerous if used incorrectly. */
-/* Requires a pointer to the base of an object. */
-/* If the argument is stubborn, it should not be changeable when freed. */
-/* An object should not be enable for finalization when it is */
-/* explicitly deallocated. */
-/* GC_free(0) is a no-op, as required by ANSI C for free. */
-GC_API void GC_free GC_PROTO((GC_PTR object_addr));
-
-/*
- * Stubborn objects may be changed only if the collector is explicitly informed.
- * The collector is implicitly informed of coming change when such
- * an object is first allocated. The following routines inform the
- * collector that an object will no longer be changed, or that it will
- * once again be changed. Only nonNIL pointer stores into the object
- * are considered to be changes. The argument to GC_end_stubborn_change
- * must be exacly the value returned by GC_malloc_stubborn or passed to
- * GC_change_stubborn. (In the second case it may be an interior pointer
- * within 512 bytes of the beginning of the objects.)
- * There is a performance penalty for allowing more than
- * one stubborn object to be changed at once, but it is acceptable to
- * do so. The same applies to dropping stubborn objects that are still
- * changeable.
- */
-GC_API void GC_change_stubborn GC_PROTO((GC_PTR));
-GC_API void GC_end_stubborn_change GC_PROTO((GC_PTR));
-
-/* Return a pointer to the base (lowest address) of an object given */
-/* a pointer to a location within the object. */
-/* Return 0 if displaced_pointer doesn't point to within a valid */
-/* object. */
-GC_API GC_PTR GC_base GC_PROTO((GC_PTR displaced_pointer));
-
-/* Given a pointer to the base of an object, return its size in bytes. */
-/* The returned size may be slightly larger than what was originally */
-/* requested. */
-GC_API size_t GC_size GC_PROTO((GC_PTR object_addr));
-
-/* For compatibility with C library. This is occasionally faster than */
-/* a malloc followed by a bcopy. But if you rely on that, either here */
-/* or with the standard C library, your code is broken. In my */
-/* opinion, it shouldn't have been invented, but now we're stuck. -HB */
-/* The resulting object has the same kind as the original. */
-/* If the argument is stubborn, the result will have changes enabled. */
-/* It is an error to have changes enabled for the original object. */
-/* Follows ANSI comventions for NULL old_object. */
-GC_API GC_PTR GC_realloc
- GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes));
-
-/* Explicitly increase the heap size. */
-/* Returns 0 on failure, 1 on success. */
-GC_API int GC_expand_hp GC_PROTO((size_t number_of_bytes));
-
-/* Limit the heap size to n bytes. Useful when you're debugging, */
-/* especially on systems that don't handle running out of memory well. */
-/* n == 0 ==> unbounded. This is the default. */
-GC_API void GC_set_max_heap_size GC_PROTO((GC_word n));
-
-/* Inform the collector that a certain section of statically allocated */
-/* memory contains no pointers to garbage collected memory. Thus it */
-/* need not be scanned. This is sometimes important if the application */
-/* maps large read/write files into the address space, which could be */
-/* mistaken for dynamic library data segments on some systems. */
-GC_API void GC_exclude_static_roots GC_PROTO((GC_PTR start, GC_PTR finish));
-
-/* Clear the set of root segments. Wizards only. */
-GC_API void GC_clear_roots GC_PROTO((void));
-
-/* Add a root segment. Wizards only. */
-GC_API void GC_add_roots GC_PROTO((char * low_address,
- char * high_address_plus_1));
-
-/* Add a displacement to the set of those considered valid by the */
-/* collector. GC_register_displacement(n) means that if p was returned */
-/* by GC_malloc, then (char *)p + n will be considered to be a valid */
-/* pointer to n. N must be small and less than the size of p. */
-/* (All pointers to the interior of objects from the stack are */
-/* considered valid in any case. This applies to heap objects and */
-/* static data.) */
-/* Preferably, this should be called before any other GC procedures. */
-/* Calling it later adds to the probability of excess memory */
-/* retention. */
-/* This is a no-op if the collector was compiled with recognition of */
-/* arbitrary interior pointers enabled, which is now the default. */
-GC_API void GC_register_displacement GC_PROTO((GC_word n));
-
-/* The following version should be used if any debugging allocation is */
-/* being done. */
-GC_API void GC_debug_register_displacement GC_PROTO((GC_word n));
-
-/* Explicitly trigger a full, world-stop collection. */
-GC_API void GC_gcollect GC_PROTO((void));
-
-/* Trigger a full world-stopped collection. Abort the collection if */
-/* and when stop_func returns a nonzero value. Stop_func will be */
-/* called frequently, and should be reasonably fast. This works even */
-/* if virtual dirty bits, and hence incremental collection is not */
-/* available for this architecture. Collections can be aborted faster */
-/* than normal pause times for incremental collection. However, */
-/* aborted collections do no useful work; the next collection needs */
-/* to start from the beginning. */
-/* Return 0 if the collection was aborted, 1 if it succeeded. */
-typedef int (* GC_stop_func) GC_PROTO((void));
-GC_API int GC_try_to_collect GC_PROTO((GC_stop_func stop_func));
-
-/* Return the number of bytes in the heap. Excludes collector private */
-/* data structures. Includes empty blocks and fragmentation loss. */
-/* Includes some pages that were allocated but never written. */
-GC_API size_t GC_get_heap_size GC_PROTO((void));
-
-/* Return a lower bound on the number of free bytes in the heap. */
-GC_API size_t GC_get_free_bytes GC_PROTO((void));
-
-/* Return the number of bytes allocated since the last collection. */
-GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
-
-/* Enable incremental/generational collection. */
-/* Not advisable unless dirty bits are */
-/* available or most heap objects are */
-/* pointerfree(atomic) or immutable. */
-/* Don't use in leak finding mode. */
-/* Ignored if GC_dont_gc is true. */
-GC_API void GC_enable_incremental GC_PROTO((void));
-
-/* Perform some garbage collection work, if appropriate. */
-/* Return 0 if there is no more work to be done. */
-/* Typically performs an amount of work corresponding roughly */
-/* to marking from one page. May do more work if further */
-/* progress requires it, e.g. if incremental collection is */
-/* disabled. It is reasonable to call this in a wait loop */
-/* until it returns 0. */
-GC_API int GC_collect_a_little GC_PROTO((void));
-
-/* Allocate an object of size lb bytes. The client guarantees that */
-/* as long as the object is live, it will be referenced by a pointer */
-/* that points to somewhere within the first 256 bytes of the object. */
-/* (This should normally be declared volatile to prevent the compiler */
-/* from invalidating this assertion.) This routine is only useful */
-/* if a large array is being allocated. It reduces the chance of */
-/* accidentally retaining such an array as a result of scanning an */
-/* integer that happens to be an address inside the array. (Actually, */
-/* it reduces the chance of the allocator not finding space for such */
-/* an array, since it will try hard to avoid introducing such a false */
-/* reference.) On a SunOS 4.X or MS Windows system this is recommended */
-/* for arrays likely to be larger than 100K or so. For other systems, */
-/* or if the collector is not configured to recognize all interior */
-/* pointers, the threshold is normally much higher. */
-GC_API GC_PTR GC_malloc_ignore_off_page GC_PROTO((size_t lb));
-GC_API GC_PTR GC_malloc_atomic_ignore_off_page GC_PROTO((size_t lb));
-
-#if defined(__sgi) && !defined(__GNUC__) && _COMPILER_VERSION >= 720
-# define GC_ADD_CALLER
-# define GC_RETURN_ADDR (GC_word)__return_address
-#endif
-
-#ifdef GC_ADD_CALLER
-# define GC_EXTRAS GC_RETURN_ADDR, __FILE__, __LINE__
-# define GC_EXTRA_PARAMS GC_word ra, GC_CONST char * s, int i
-#else
-# define GC_EXTRAS __FILE__, __LINE__
-# define GC_EXTRA_PARAMS GC_CONST char * s, int i
-#endif
-
-/* Debugging (annotated) allocation. GC_gcollect will check */
-/* objects allocated in this way for overwrites, etc. */
-GC_API GC_PTR GC_debug_malloc
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_atomic
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_uncollectable
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API GC_PTR GC_debug_malloc_stubborn
- GC_PROTO((size_t size_in_bytes, GC_EXTRA_PARAMS));
-GC_API void GC_debug_free GC_PROTO((GC_PTR object_addr));
-GC_API GC_PTR GC_debug_realloc
- GC_PROTO((GC_PTR old_object, size_t new_size_in_bytes,
- GC_EXTRA_PARAMS));
-
-GC_API void GC_debug_change_stubborn GC_PROTO((GC_PTR));
-GC_API void GC_debug_end_stubborn_change GC_PROTO((GC_PTR));
-# ifdef GC_DEBUG
-# define GC_MALLOC(sz) GC_debug_malloc(sz, GC_EXTRAS)
-# define GC_MALLOC_ATOMIC(sz) GC_debug_malloc_atomic(sz, GC_EXTRAS)
-# define GC_MALLOC_UNCOLLECTABLE(sz) GC_debug_malloc_uncollectable(sz, \
- GC_EXTRAS)
-# define GC_REALLOC(old, sz) GC_debug_realloc(old, sz, GC_EXTRAS)
-# define GC_FREE(p) GC_debug_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_debug_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_debug_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_debug_register_finalizer_no_order(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_debug_malloc_stubborn(sz, GC_EXTRAS);
-# define GC_CHANGE_STUBBORN(p) GC_debug_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_debug_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, GC_base(obj))
-# define GC_REGISTER_DISPLACEMENT(n) GC_debug_register_displacement(n)
-# else
-# define GC_MALLOC(sz) GC_malloc(sz)
-# define GC_MALLOC_ATOMIC(sz) GC_malloc_atomic(sz)
-# define GC_MALLOC_UNCOLLECTABLE(sz) GC_malloc_uncollectable(sz)
-# define GC_REALLOC(old, sz) GC_realloc(old, sz)
-# define GC_FREE(p) GC_free(p)
-# define GC_REGISTER_FINALIZER(p, f, d, of, od) \
- GC_register_finalizer(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_IGNORE_SELF(p, f, d, of, od) \
- GC_register_finalizer_ignore_self(p, f, d, of, od)
-# define GC_REGISTER_FINALIZER_NO_ORDER(p, f, d, of, od) \
- GC_register_finalizer_no_order(p, f, d, of, od)
-# define GC_MALLOC_STUBBORN(sz) GC_malloc_stubborn(sz)
-# define GC_CHANGE_STUBBORN(p) GC_change_stubborn(p)
-# define GC_END_STUBBORN_CHANGE(p) GC_end_stubborn_change(p)
-# define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) \
- GC_general_register_disappearing_link(link, obj)
-# define GC_REGISTER_DISPLACEMENT(n) GC_register_displacement(n)
-# endif
-/* The following are included because they are often convenient, and */
-/* reduce the chance for a misspecifed size argument. But calls may */
-/* expand to something syntactically incorrect if t is a complicated */
-/* type expression. */
-# define GC_NEW(t) (t *)GC_MALLOC(sizeof (t))
-# define GC_NEW_ATOMIC(t) (t *)GC_MALLOC_ATOMIC(sizeof (t))
-# define GC_NEW_STUBBORN(t) (t *)GC_MALLOC_STUBBORN(sizeof (t))
-# define GC_NEW_UNCOLLECTABLE(t) (t *)GC_MALLOC_UNCOLLECTABLE(sizeof (t))
-
-/* Finalization. Some of these primitives are grossly unsafe. */
-/* The idea is to make them both cheap, and sufficient to build */
-/* a safer layer, closer to PCedar finalization. */
-/* The interface represents my conclusions from a long discussion */
-/* with Alan Demers, Dan Greene, Carl Hauser, Barry Hayes, */
-/* Christian Jacobi, and Russ Atkinson. It's not perfect, and */
-/* probably nobody else agrees with it. Hans-J. Boehm 3/13/92 */
-typedef void (*GC_finalization_proc)
- GC_PROTO((GC_PTR obj, GC_PTR client_data));
-
-GC_API void GC_register_finalizer
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
- /* When obj is no longer accessible, invoke */
- /* (*fn)(obj, cd). If a and b are inaccessible, and */
- /* a points to b (after disappearing links have been */
- /* made to disappear), then only a will be */
- /* finalized. (If this does not create any new */
- /* pointers to b, then b will be finalized after the */
- /* next collection.) Any finalizable object that */
- /* is reachable from itself by following one or more */
- /* pointers will not be finalized (or collected). */
- /* Thus cycles involving finalizable objects should */
- /* be avoided, or broken by disappearing links. */
- /* All but the last finalizer registered for an object */
- /* is ignored. */
- /* Finalization may be removed by passing 0 as fn. */
- /* Finalizers are implicitly unregistered just before */
- /* they are invoked. */
- /* The old finalizer and client data are stored in */
- /* *ofn and *ocd. */
- /* Fn is never invoked on an accessible object, */
- /* provided hidden pointers are converted to real */
- /* pointers only if the allocation lock is held, and */
- /* such conversions are not performed by finalization */
- /* routines. */
- /* If GC_register_finalizer is aborted as a result of */
- /* a signal, the object may be left with no */
- /* finalization, even if neither the old nor new */
- /* finalizer were NULL. */
- /* Obj should be the nonNULL starting address of an */
- /* object allocated by GC_malloc or friends. */
- /* Note that any garbage collectable object referenced */
- /* by cd will be considered accessible until the */
- /* finalizer is invoked. */
-
-/* Another versions of the above follow. It ignores */
-/* self-cycles, i.e. pointers from a finalizable object to */
-/* itself. There is a stylistic argument that this is wrong, */
-/* but it's unavoidable for C++, since the compiler may */
-/* silently introduce these. It's also benign in that specific */
-/* case. */
-GC_API void GC_register_finalizer_ignore_self
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer_ignore_self
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-
-/* Another version of the above. It ignores all cycles. */
-/* It should probably only be used by Java implementations. */
-GC_API void GC_register_finalizer_no_order
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-GC_API void GC_debug_register_finalizer_no_order
- GC_PROTO((GC_PTR obj, GC_finalization_proc fn, GC_PTR cd,
- GC_finalization_proc *ofn, GC_PTR *ocd));
-
-
-/* The following routine may be used to break cycles between */
-/* finalizable objects, thus causing cyclic finalizable */
-/* objects to be finalized in the correct order. Standard */
-/* use involves calling GC_register_disappearing_link(&p), */
-/* where p is a pointer that is not followed by finalization */
-/* code, and should not be considered in determining */
-/* finalization order. */
-GC_API int GC_register_disappearing_link GC_PROTO((GC_PTR * /* link */));
- /* Link should point to a field of a heap allocated */
- /* object obj. *link will be cleared when obj is */
- /* found to be inaccessible. This happens BEFORE any */
- /* finalization code is invoked, and BEFORE any */
- /* decisions about finalization order are made. */
- /* This is useful in telling the finalizer that */
- /* some pointers are not essential for proper */
- /* finalization. This may avoid finalization cycles. */
- /* Note that obj may be resurrected by another */
- /* finalizer, and thus the clearing of *link may */
- /* be visible to non-finalization code. */
- /* There's an argument that an arbitrary action should */
- /* be allowed here, instead of just clearing a pointer. */
- /* But this causes problems if that action alters, or */
- /* examines connectivity. */
- /* Returns 1 if link was already registered, 0 */
- /* otherwise. */
- /* Only exists for backward compatibility. See below: */
-
-GC_API int GC_general_register_disappearing_link
- GC_PROTO((GC_PTR * /* link */, GC_PTR obj));
- /* A slight generalization of the above. *link is */
- /* cleared when obj first becomes inaccessible. This */
- /* can be used to implement weak pointers easily and */
- /* safely. Typically link will point to a location */
- /* holding a disguised pointer to obj. (A pointer */
- /* inside an "atomic" object is effectively */
- /* disguised.) In this way soft */
- /* pointers are broken before any object */
- /* reachable from them are finalized. Each link */
- /* May be registered only once, i.e. with one obj */
- /* value. This was added after a long email discussion */
- /* with John Ellis. */
- /* Obj must be a pointer to the first word of an object */
- /* we allocated. It is unsafe to explicitly deallocate */
- /* the object containing link. Explicitly deallocating */
- /* obj may or may not cause link to eventually be */
- /* cleared. */
-GC_API int GC_unregister_disappearing_link GC_PROTO((GC_PTR * /* link */));
- /* Returns 0 if link was not actually registered. */
- /* Undoes a registration by either of the above two */
- /* routines. */
-
-/* Auxiliary fns to make finalization work correctly with displaced */
-/* pointers introduced by the debugging allocators. */
-GC_API GC_PTR GC_make_closure GC_PROTO((GC_finalization_proc fn, GC_PTR data));
-GC_API void GC_debug_invoke_finalizer GC_PROTO((GC_PTR obj, GC_PTR data));
-
-/* Returns !=0 if GC_invoke_finalizers has something to do. */
-GC_API int GC_should_invoke_finalizers GC_PROTO((void));
-
-GC_API int GC_invoke_finalizers GC_PROTO((void));
- /* Run finalizers for all objects that are ready to */
- /* be finalized. Return the number of finalizers */
- /* that were run. Normally this is also called */
- /* implicitly during some allocations. If */
- /* GC-finalize_on_demand is nonzero, it must be called */
- /* explicitly. */
-
-/* GC_set_warn_proc can be used to redirect or filter warning messages. */
-/* p may not be a NULL pointer. */
-typedef void (*GC_warn_proc) GC_PROTO((char *msg, GC_word arg));
-GC_API GC_warn_proc GC_set_warn_proc GC_PROTO((GC_warn_proc p));
- /* Returns old warning procedure. */
-
-/* The following is intended to be used by a higher level */
-/* (e.g. cedar-like) finalization facility. It is expected */
-/* that finalization code will arrange for hidden pointers to */
-/* disappear. Otherwise objects can be accessed after they */
-/* have been collected. */
-/* Note that putting pointers in atomic objects or in */
-/* nonpointer slots of "typed" objects is equivalent to */
-/* disguising them in this way, and may have other advantages. */
-# if defined(I_HIDE_POINTERS) || defined(GC_I_HIDE_POINTERS)
- typedef GC_word GC_hidden_pointer;
-# define HIDE_POINTER(p) (~(GC_hidden_pointer)(p))
-# define REVEAL_POINTER(p) ((GC_PTR)(HIDE_POINTER(p)))
- /* Converting a hidden pointer to a real pointer requires verifying */
- /* that the object still exists. This involves acquiring the */
- /* allocator lock to avoid a race with the collector. */
-# endif /* I_HIDE_POINTERS */
-
-typedef GC_PTR (*GC_fn_type) GC_PROTO((GC_PTR client_data));
-GC_API GC_PTR GC_call_with_alloc_lock
- GC_PROTO((GC_fn_type fn, GC_PTR client_data));
-
-/* Check that p and q point to the same object. */
-/* Fail conspicuously if they don't. */
-/* Returns the first argument. */
-/* Succeeds if neither p nor q points to the heap. */
-/* May succeed if both p and q point to between heap objects. */
-GC_API GC_PTR GC_same_obj GC_PROTO((GC_PTR p, GC_PTR q));
-
-/* Checked pointer pre- and post- increment operations. Note that */
-/* the second argument is in units of bytes, not multiples of the */
-/* object size. This should either be invoked from a macro, or the */
-/* call should be automatically generated. */
-GC_API GC_PTR GC_pre_incr GC_PROTO((GC_PTR *p, size_t how_much));
-GC_API GC_PTR GC_post_incr GC_PROTO((GC_PTR *p, size_t how_much));
-
-/* Check that p is visible */
-/* to the collector as a possibly pointer containing location. */
-/* If it isn't fail conspicuously. */
-/* Returns the argument in all cases. May erroneously succeed */
-/* in hard cases. (This is intended for debugging use with */
-/* untyped allocations. The idea is that it should be possible, though */
-/* slow, to add such a call to all indirect pointer stores.) */
-/* Currently useless for multithreaded worlds. */
-GC_API GC_PTR GC_is_visible GC_PROTO((GC_PTR p));
-
-/* Check that if p is a pointer to a heap page, then it points to */
-/* a valid displacement within a heap object. */
-/* Fail conspicuously if this property does not hold. */
-/* Uninteresting with ALL_INTERIOR_POINTERS. */
-/* Always returns its argument. */
-GC_API GC_PTR GC_is_valid_displacement GC_PROTO((GC_PTR p));
-
-/* Safer, but slow, pointer addition. Probably useful mainly with */
-/* a preprocessor. Useful only for heap pointers. */
-#ifdef GC_DEBUG
-# define GC_PTR_ADD3(x, n, type_of_result) \
- ((type_of_result)GC_same_obj((x)+(n), (x)))
-# define GC_PRE_INCR3(x, n, type_of_result) \
- ((type_of_result)GC_pre_incr(&(x), (n)*sizeof(*x))
-# define GC_POST_INCR2(x, type_of_result) \
- ((type_of_result)GC_post_incr(&(x), sizeof(*x))
-# ifdef __GNUC__
-# define GC_PTR_ADD(x, n) \
- GC_PTR_ADD3(x, n, typeof(x))
-# define GC_PRE_INCR(x, n) \
- GC_PRE_INCR3(x, n, typeof(x))
-# define GC_POST_INCR(x, n) \
- GC_POST_INCR3(x, typeof(x))
-# else
- /* We can't do this right without typeof, which ANSI */
- /* decided was not sufficiently useful. Repeatedly */
- /* mentioning the arguments seems too dangerous to be */
- /* useful. So does not casting the result. */
-# define GC_PTR_ADD(x, n) ((x)+(n))
-# endif
-#else /* !GC_DEBUG */
-# define GC_PTR_ADD3(x, n, type_of_result) ((x)+(n))
-# define GC_PTR_ADD(x, n) ((x)+(n))
-# define GC_PRE_INCR3(x, n, type_of_result) ((x) += (n))
-# define GC_PRE_INCR(x, n) ((x) += (n))
-# define GC_POST_INCR2(x, n, type_of_result) ((x)++)
-# define GC_POST_INCR(x, n) ((x)++)
-#endif
-
-/* Safer assignment of a pointer to a nonstack location. */
-#ifdef GC_DEBUG
-# ifdef __STDC__
-# define GC_PTR_STORE(p, q) \
- (*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
-# else
-# define GC_PTR_STORE(p, q) \
- (*(char **)GC_is_visible(p) = GC_is_valid_displacement(q))
-# endif
-#else /* !GC_DEBUG */
-# define GC_PTR_STORE(p, q) *((p) = (q))
-#endif
-
-/* Fynctions called to report pointer checking errors */
-GC_API void (*GC_same_obj_print_proc) GC_PROTO((GC_PTR p, GC_PTR q));
-
-GC_API void (*GC_is_valid_displacement_print_proc)
- GC_PROTO((GC_PTR p));
-
-GC_API void (*GC_is_visible_print_proc)
- GC_PROTO((GC_PTR p));
-
-#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
-# define SOLARIS_THREADS
-#endif
-
-#ifdef SOLARIS_THREADS
-/* We need to intercept calls to many of the threads primitives, so */
-/* that we can locate thread stacks and stop the world. */
-/* Note also that the collector cannot see thread specific data. */
-/* Thread specific data should generally consist of pointers to */
-/* uncollectable objects, which are deallocated using the destructor */
-/* facility in thr_keycreate. */
-# include <thread.h>
-# include <signal.h>
- int GC_thr_create(void *stack_base, size_t stack_size,
- void *(*start_routine)(void *), void *arg, long flags,
- thread_t *new_thread);
- int GC_thr_join(thread_t wait_for, thread_t *departed, void **status);
- int GC_thr_suspend(thread_t target_thread);
- int GC_thr_continue(thread_t target_thread);
- void * GC_dlopen(const char *path, int mode);
-
-# ifdef _SOLARIS_PTHREADS
-# include <pthread.h>
- extern int GC_pthread_create(pthread_t *new_thread,
- const pthread_attr_t *attr,
- void * (*thread_execp)(void *), void *arg);
- extern int GC_pthread_join(pthread_t wait_for, void **status);
-
-# undef thread_t
-
-# define pthread_join GC_pthread_join
-# define pthread_create GC_pthread_create
-#endif
-
-# define thr_create GC_thr_create
-# define thr_join GC_thr_join
-# define thr_suspend GC_thr_suspend
-# define thr_continue GC_thr_continue
-# define dlopen GC_dlopen
-
-# endif /* SOLARIS_THREADS */
-
-
-#if !defined(USE_LD_WRAP) && \
- (defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
-/* We treat these similarly. */
-# include <pthread.h>
-# include <signal.h>
-
- int GC_pthread_create(pthread_t *new_thread,
- const pthread_attr_t *attr,
- void *(*start_routine)(void *), void *arg);
- int GC_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
- int GC_pthread_join(pthread_t thread, void **retval);
-
-# define pthread_create GC_pthread_create
-# define pthread_sigmask GC_pthread_sigmask
-# define pthread_join GC_pthread_join
-# define dlopen GC_dlopen
-
-#endif /* xxxxx_THREADS */
-
-# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
- defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
- defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
- /* Any flavor of threads except SRC_M3. */
-/* This returns a list of objects, linked through their first */
-/* word. Its use can greatly reduce lock contention problems, since */
-/* the allocation lock can be acquired and released many fewer times. */
-/* lb must be large enough to hold the pointer field. */
-GC_PTR GC_malloc_many(size_t lb);
-#define GC_NEXT(p) (*(GC_PTR *)(p)) /* Retrieve the next element */
- /* in returned list. */
-extern void GC_thr_init(); /* Needed for Solaris/X86 */
-
-#endif /* THREADS && !SRC_M3 */
-
-/*
- * If you are planning on putting
- * the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
- * from the statically loaded program section.
- * This circumvents a Solaris 2.X (X<=4) linker bug.
- */
-#if defined(sparc) || defined(__sparc)
-# define GC_INIT() { extern end, etext; \
- GC_noop(&end, &etext); }
-#else
-# if defined(__CYGWIN32__) && defined(GC_USE_DLL)
- /*
- * Similarly gnu-win32 DLLs need explicit initialization
- */
-# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
-# else
-# define GC_INIT()
-# endif
-#endif
-
-#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32)
- /* win32S may not free all resources on process exit. */
- /* This explicitly deallocates the heap. */
- GC_API void GC_win32_free_heap ();
-#endif
-
-#ifdef __cplusplus
- } /* end of extern "C" */
-#endif
-
-#endif /* _GC_H */
diff --git a/gc.mak b/gc.mak
index 0fd22b70..08478f03 100644
--- a/gc.mak
+++ b/gc.mak
@@ -111,8 +111,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
+# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\
"WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\Release/
@@ -289,8 +289,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
+# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\
/D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\
"WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\
/Fd"$(INTDIR)/" /c
@@ -418,8 +418,8 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
+# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
"ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\gctest\Release/
@@ -505,7 +505,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\
/D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\
/Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\gctest\Debug/
@@ -596,7 +596,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "." /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\
"ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX /Fo"$(INTDIR)/" /c
CPP_OBJS=.\cord\Release/
CPP_SBRS=.\.
@@ -688,7 +688,7 @@ CLEAN :
CPP=cl.exe
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /D "_DEBUG" /D "WIN32" /D\
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "." /I include /D "_DEBUG" /D "WIN32" /D\
"_WINDOWS" /D "ALL_INTERIOR_POINTERS" /Fp"$(INTDIR)/cord.pch" /YX\
/Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
CPP_OBJS=.\cord\Debug/
@@ -768,10 +768,10 @@ SOURCE=.\reclaim.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_RECLA=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_RECLA=\
@@ -788,10 +788,10 @@ NODEP_CPP_RECLA=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_RECLA=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_RECLA=\
@@ -816,10 +816,10 @@ SOURCE=.\os_dep.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_OS_DE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -840,10 +840,10 @@ NODEP_CPP_OS_DE=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_OS_DE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -872,10 +872,10 @@ SOURCE=.\misc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MISC_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MISC_=\
@@ -893,10 +893,10 @@ NODEP_CPP_MISC_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MISC_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MISC_=\
@@ -922,10 +922,10 @@ SOURCE=.\mark_rts.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MARK_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_=\
@@ -942,10 +942,10 @@ NODEP_CPP_MARK_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MARK_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_=\
@@ -970,10 +970,10 @@ SOURCE=.\mach_dep.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MACH_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MACH_=\
@@ -990,10 +990,10 @@ NODEP_CPP_MACH_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MACH_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MACH_=\
@@ -1018,10 +1018,10 @@ SOURCE=.\headers.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_HEADE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_HEADE=\
@@ -1038,10 +1038,10 @@ NODEP_CPP_HEADE=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_HEADE=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_HEADE=\
@@ -1066,10 +1066,10 @@ SOURCE=.\alloc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_ALLOC=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLOC=\
@@ -1086,10 +1086,10 @@ NODEP_CPP_ALLOC=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_ALLOC=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLOC=\
@@ -1114,10 +1114,10 @@ SOURCE=.\allchblk.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_ALLCH=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLCH=\
@@ -1134,10 +1134,10 @@ NODEP_CPP_ALLCH=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_ALLCH=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_ALLCH=\
@@ -1162,10 +1162,10 @@ SOURCE=.\stubborn.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_STUBB=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_STUBB=\
@@ -1182,10 +1182,10 @@ NODEP_CPP_STUBB=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_STUBB=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_STUBB=\
@@ -1210,10 +1210,10 @@ SOURCE=.\obj_map.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_OBJ_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_OBJ_M=\
@@ -1230,10 +1230,10 @@ NODEP_CPP_OBJ_M=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_OBJ_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_OBJ_M=\
@@ -1258,10 +1258,10 @@ SOURCE=.\new_hblk.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_NEW_H=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_NEW_H=\
@@ -1278,10 +1278,10 @@ NODEP_CPP_NEW_H=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_NEW_H=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_NEW_H=\
@@ -1306,11 +1306,11 @@ SOURCE=.\mark.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MARK_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_C=\
@@ -1327,11 +1327,11 @@ NODEP_CPP_MARK_C=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MARK_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MARK_C=\
@@ -1356,10 +1356,10 @@ SOURCE=.\malloc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MALLO=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLO=\
@@ -1376,10 +1376,10 @@ NODEP_CPP_MALLO=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MALLO=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLO=\
@@ -1404,10 +1404,10 @@ SOURCE=.\mallocx.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_MALLX=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLX=\
@@ -1424,10 +1424,10 @@ NODEP_CPP_MALLX=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_MALLX=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_MALLX=\
@@ -1452,11 +1452,11 @@ SOURCE=.\finalize.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_FINAL=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_FINAL=\
@@ -1473,11 +1473,11 @@ NODEP_CPP_FINAL=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_FINAL=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_FINAL=\
@@ -1502,10 +1502,10 @@ SOURCE=.\dbg_mlc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_DBG_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_DBG_M=\
@@ -1522,10 +1522,10 @@ NODEP_CPP_DBG_M=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_DBG_M=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_DBG_M=\
@@ -1550,10 +1550,10 @@ SOURCE=.\blacklst.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_BLACK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_BLACK=\
@@ -1570,10 +1570,10 @@ NODEP_CPP_BLACK=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_BLACK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_BLACK=\
@@ -1598,12 +1598,12 @@ SOURCE=.\typd_mlc.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_TYPD_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TYPD_=\
@@ -1620,12 +1620,12 @@ NODEP_CPP_TYPD_=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_TYPD_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TYPD_=\
@@ -1650,11 +1650,11 @@ SOURCE=.\ptr_chck.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_PTR_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_PTR_C=\
@@ -1671,11 +1671,11 @@ NODEP_CPP_PTR_C=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_PTR_C=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_mark.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_mark.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_PTR_C=\
@@ -1700,10 +1700,10 @@ SOURCE=.\dyn_load.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_DYN_L=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -1723,10 +1723,10 @@ NODEP_CPP_DYN_L=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_DYN_L=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\STAT.H"\
{$(INCLUDE)}"\sys\TYPES.H"\
@@ -1754,10 +1754,10 @@ SOURCE=.\win32_threads.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_WIN32=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_WIN32=\
@@ -1774,10 +1774,10 @@ NODEP_CPP_WIN32=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_WIN32=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_WIN32=\
@@ -1802,10 +1802,10 @@ SOURCE=.\checksums.c
!IF "$(CFG)" == "gc - Win32 Release"
DEP_CPP_CHECK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_CHECK=\
@@ -1822,10 +1822,10 @@ NODEP_CPP_CHECK=\
!ELSEIF "$(CFG)" == "gc - Win32 Debug"
DEP_CPP_CHECK=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_CHECK=\
@@ -1878,11 +1878,11 @@ NODEP_CPP_CHECK=\
SOURCE=.\test.c
DEP_CPP_TEST_=\
- ".\gcconfig.h"\
- ".\gc.h"\
- ".\gc_hdrs.h"\
- ".\gc_priv.h"\
- ".\gc_typed.h"\
+ ".\include\private\gcconfig.h"\
+ ".\include\gc.h"\
+ ".\include\private\gc_hdrs.h"\
+ ".\include\private\gc_priv.h"\
+ ".\include\gc_typed.h"\
{$(INCLUDE)}"\sys\TYPES.H"\
NODEP_CPP_TEST_=\
@@ -1944,13 +1944,13 @@ NODEP_CPP_TEST_=\
SOURCE=.\cord\de_win.c
DEP_CPP_DE_WI=\
- ".\cord\cord.h"\
+ ".\include\cord.h"\
".\cord\de_cmds.h"\
".\cord\de_win.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_DE_WI=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -1975,13 +1975,13 @@ NODEP_CPP_DE_WI=\
SOURCE=.\cord\de.c
DEP_CPP_DE_C2e=\
- ".\cord\cord.h"\
+ ".\include\cord.h"\
".\cord\de_cmds.h"\
".\cord\de_win.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_DE_C2e=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -2006,12 +2006,12 @@ NODEP_CPP_DE_C2e=\
SOURCE=.\cord\cordxtra.c
DEP_CPP_CORDX=\
- ".\cord\cord.h"\
- ".\cord\ec.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\cord.h"\
+ ".\include\ec.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_CORDX=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
@@ -2036,11 +2036,11 @@ NODEP_CPP_CORDX=\
SOURCE=.\cord\cordbscs.c
DEP_CPP_CORDB=\
- ".\cord\cord.h"\
- ".\cord\private\cord_pos.h"\
+ ".\include\cord.h"\
+ ".\include\private\cord_pos.h"\
NODEP_CPP_CORDB=\
- ".\cord\gc.h"\
+ ".\include\gc.h"\
!IF "$(CFG)" == "cord - Win32 Release"
diff --git a/gc_alloc.h b/gc_alloc.h
deleted file mode 100644
index 1f1d54af..00000000
--- a/gc_alloc.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-//
-// This is a C++ header file that is intended to replace the SGI STL
-// alloc.h. This assumes SGI STL version < 3.0.
-//
-// This assumes the collector has been compiled with -DATOMIC_UNCOLLECTABLE
-// and -DALL_INTERIOR_POINTERS. We also recommend
-// -DREDIRECT_MALLOC=GC_uncollectable_malloc.
-//
-// Some of this could be faster in the explicit deallocation case. In particular,
-// we spend too much time clearing objects on the free lists. That could be avoided.
-//
-// This uses template classes with static members, and hence does not work
-// with g++ 2.7.2 and earlier.
-//
-
-#include "gc.h"
-
-#ifndef GC_ALLOC_H
-
-#define GC_ALLOC_H
-#define __ALLOC_H // Prevent inclusion of the default version. Ugly.
-#define __SGI_STL_ALLOC_H
-#define __SGI_STL_INTERNAL_ALLOC_H
-
-#ifndef __ALLOC
-# define __ALLOC alloc
-#endif
-
-#include <stddef.h>
-#include <string.h>
-
-// The following is just replicated from the conventional SGI alloc.h:
-
-template<class T, class alloc>
-class simple_alloc {
-
-public:
- static T *allocate(size_t n)
- { return 0 == n? 0 : (T*) alloc::allocate(n * sizeof (T)); }
- static T *allocate(void)
- { return (T*) alloc::allocate(sizeof (T)); }
- static void deallocate(T *p, size_t n)
- { if (0 != n) alloc::deallocate(p, n * sizeof (T)); }
- static void deallocate(T *p)
- { alloc::deallocate(p, sizeof (T)); }
-};
-
-#include "gc.h"
-
-// The following need to match collector data structures.
-// We can't include gc_priv.h, since that pulls in way too much stuff.
-// This should eventually be factored out into another include file.
-
-extern "C" {
- extern void ** const GC_objfreelist_ptr;
- extern void ** const GC_aobjfreelist_ptr;
- extern void ** const GC_uobjfreelist_ptr;
- extern void ** const GC_auobjfreelist_ptr;
-
- extern void GC_incr_words_allocd(size_t words);
- extern void GC_incr_mem_freed(size_t words);
-
- extern char * GC_generic_malloc_words_small(size_t word, int kind);
-}
-
-// Object kinds; must match PTRFREE, NORMAL, UNCOLLECTABLE, and
-// AUNCOLLECTABLE in gc_priv.h.
-
-enum { GC_PTRFREE = 0, GC_NORMAL = 1, GC_UNCOLLECTABLE = 2,
- GC_AUNCOLLECTABLE = 3 };
-
-enum { GC_max_fast_bytes = 255 };
-
-enum { GC_bytes_per_word = sizeof(char *) };
-
-enum { GC_byte_alignment = 8 };
-
-enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word };
-
-inline void * &GC_obj_link(void * p)
-{ return *(void **)p; }
-
-// Compute a number of words >= n+1 bytes.
-// The +1 allows for pointers one past the end.
-inline size_t GC_round_up(size_t n)
-{
- return ((n + GC_byte_alignment)/GC_byte_alignment)*GC_word_alignment;
-}
-
-// The same but don't allow for extra byte.
-inline size_t GC_round_up_uncollectable(size_t n)
-{
- return ((n + GC_byte_alignment - 1)/GC_byte_alignment)*GC_word_alignment;
-}
-
-template <int dummy>
-class GC_aux_template {
-public:
- // File local count of allocated words. Occasionally this is
- // added into the global count. A separate count is necessary since the
- // real one must be updated with a procedure call.
- static size_t GC_words_recently_allocd;
-
- // Same for uncollectable mmory. Not yet reflected in either
- // GC_words_recently_allocd or GC_non_gc_bytes.
- static size_t GC_uncollectable_words_recently_allocd;
-
- // Similar counter for explicitly deallocated memory.
- static size_t GC_mem_recently_freed;
-
- // Again for uncollectable memory.
- static size_t GC_uncollectable_mem_recently_freed;
-
- static void * GC_out_of_line_malloc(size_t nwords, int kind);
-};
-
-template <int dummy>
-size_t GC_aux_template<dummy>::GC_words_recently_allocd = 0;
-
-template <int dummy>
-size_t GC_aux_template<dummy>::GC_uncollectable_words_recently_allocd = 0;
-
-template <int dummy>
-size_t GC_aux_template<dummy>::GC_mem_recently_freed = 0;
-
-template <int dummy>
-size_t GC_aux_template<dummy>::GC_uncollectable_mem_recently_freed = 0;
-
-template <int dummy>
-void * GC_aux_template<dummy>::GC_out_of_line_malloc(size_t nwords, int kind)
-{
- GC_words_recently_allocd += GC_uncollectable_words_recently_allocd;
- GC_non_gc_bytes +=
- GC_bytes_per_word * GC_uncollectable_words_recently_allocd;
- GC_uncollectable_words_recently_allocd = 0;
-
- GC_mem_recently_freed += GC_uncollectable_mem_recently_freed;
- GC_non_gc_bytes -=
- GC_bytes_per_word * GC_uncollectable_mem_recently_freed;
- GC_uncollectable_mem_recently_freed = 0;
-
- GC_incr_words_allocd(GC_words_recently_allocd);
- GC_words_recently_allocd = 0;
-
- GC_incr_mem_freed(GC_mem_recently_freed);
- GC_mem_recently_freed = 0;
-
- return GC_generic_malloc_words_small(nwords, kind);
-}
-
-typedef GC_aux_template<0> GC_aux;
-
-// A fast, single-threaded, garbage-collected allocator
-// We assume the first word will be immediately overwritten.
-// In this version, deallocation is not a noop, and explicit
-// deallocation is likely to help performance.
-template <int dummy>
-class single_client_gc_alloc_template {
- public:
- static void * allocate(size_t n)
- {
- size_t nwords = GC_round_up(n);
- void ** flh;
- void * op;
-
- if (n > GC_max_fast_bytes) return GC_malloc(n);
- flh = GC_objfreelist_ptr + nwords;
- if (0 == (op = *flh)) {
- return GC_aux::GC_out_of_line_malloc(nwords, GC_NORMAL);
- }
- *flh = GC_obj_link(op);
- GC_aux::GC_words_recently_allocd += nwords;
- return op;
- }
- static void * ptr_free_allocate(size_t n)
- {
- size_t nwords = GC_round_up(n);
- void ** flh;
- void * op;
-
- if (n > GC_max_fast_bytes) return GC_malloc_atomic(n);
- flh = GC_aobjfreelist_ptr + nwords;
- if (0 == (op = *flh)) {
- return GC_aux::GC_out_of_line_malloc(nwords, GC_PTRFREE);
- }
- *flh = GC_obj_link(op);
- GC_aux::GC_words_recently_allocd += nwords;
- return op;
- }
- static void deallocate(void *p, size_t n)
- {
- size_t nwords = GC_round_up(n);
- void ** flh;
-
- if (n > GC_max_fast_bytes) {
- GC_free(p);
- } else {
- flh = GC_objfreelist_ptr + nwords;
- GC_obj_link(p) = *flh;
- memset((char *)p + GC_bytes_per_word, 0,
- GC_bytes_per_word * (nwords - 1));
- *flh = p;
- GC_aux::GC_mem_recently_freed += nwords;
- }
- }
- static void ptr_free_deallocate(void *p, size_t n)
- {
- size_t nwords = GC_round_up(n);
- void ** flh;
-
- if (n > GC_max_fast_bytes) {
- GC_free(p);
- } else {
- flh = GC_aobjfreelist_ptr + nwords;
- GC_obj_link(p) = *flh;
- *flh = p;
- GC_aux::GC_mem_recently_freed += nwords;
- }
- }
-};
-
-typedef single_client_gc_alloc_template<0> single_client_gc_alloc;
-
-// Once more, for uncollectable objects.
-template <int dummy>
-class single_client_alloc_template {
- public:
- static void * allocate(size_t n)
- {
- size_t nwords = GC_round_up_uncollectable(n);
- void ** flh;
- void * op;
-
- if (n > GC_max_fast_bytes) return GC_malloc_uncollectable(n);
- flh = GC_uobjfreelist_ptr + nwords;
- if (0 == (op = *flh)) {
- return GC_aux::GC_out_of_line_malloc(nwords, GC_UNCOLLECTABLE);
- }
- *flh = GC_obj_link(op);
- GC_aux::GC_uncollectable_words_recently_allocd += nwords;
- return op;
- }
- static void * ptr_free_allocate(size_t n)
- {
- size_t nwords = GC_round_up_uncollectable(n);
- void ** flh;
- void * op;
-
- if (n > GC_max_fast_bytes) return GC_malloc_atomic_uncollectable(n);
- flh = GC_auobjfreelist_ptr + nwords;
- if (0 == (op = *flh)) {
- return GC_aux::GC_out_of_line_malloc(nwords, GC_AUNCOLLECTABLE);
- }
- *flh = GC_obj_link(op);
- GC_aux::GC_uncollectable_words_recently_allocd += nwords;
- return op;
- }
- static void deallocate(void *p, size_t n)
- {
- size_t nwords = GC_round_up_uncollectable(n);
- void ** flh;
-
- if (n > GC_max_fast_bytes) {
- GC_free(p);
- } else {
- flh = GC_uobjfreelist_ptr + nwords;
- GC_obj_link(p) = *flh;
- *flh = p;
- GC_aux::GC_uncollectable_mem_recently_freed += nwords;
- }
- }
- static void ptr_free_deallocate(void *p, size_t n)
- {
- size_t nwords = GC_round_up_uncollectable(n);
- void ** flh;
-
- if (n > GC_max_fast_bytes) {
- GC_free(p);
- } else {
- flh = GC_auobjfreelist_ptr + nwords;
- GC_obj_link(p) = *flh;
- *flh = p;
- GC_aux::GC_uncollectable_mem_recently_freed += nwords;
- }
- }
-};
-
-typedef single_client_alloc_template<0> single_client_alloc;
-
-template < int dummy >
-class gc_alloc_template {
- public:
- static void * allocate(size_t n) { return GC_malloc(n); }
- static void * ptr_free_allocate(size_t n)
- { return GC_malloc_atomic(n); }
- static void deallocate(void *, size_t) { }
- static void ptr_free_deallocate(void *, size_t) { }
-};
-
-typedef gc_alloc_template < 0 > gc_alloc;
-
-template < int dummy >
-class alloc_template {
- public:
- static void * allocate(size_t n) { return GC_malloc_uncollectable(n); }
- static void * ptr_free_allocate(size_t n)
- { return GC_malloc_atomic_uncollectable(n); }
- static void deallocate(void *p, size_t) { GC_free(p); }
- static void ptr_free_deallocate(void *p, size_t) { GC_free(p); }
-};
-
-typedef alloc_template < 0 > alloc;
-
-#ifdef _SGI_SOURCE
-
-// We want to specialize simple_alloc so that it does the right thing
-// for all pointerfree types. At the moment there is no portable way to
-// even approximate that. The following approximation should work for
-// SGI compilers, and perhaps some others.
-
-# define __GC_SPECIALIZE(T,alloc) \
-class simple_alloc<T, alloc> { \
-public: \
- static T *allocate(size_t n) \
- { return 0 == n? 0 : \
- (T*) alloc::ptr_free_allocate(n * sizeof (T)); } \
- static T *allocate(void) \
- { return (T*) alloc::ptr_free_allocate(sizeof (T)); } \
- static void deallocate(T *p, size_t n) \
- { if (0 != n) alloc::ptr_free_deallocate(p, n * sizeof (T)); } \
- static void deallocate(T *p) \
- { alloc::ptr_free_deallocate(p, sizeof (T)); } \
-};
-
-__GC_SPECIALIZE(char, gc_alloc)
-__GC_SPECIALIZE(int, gc_alloc)
-__GC_SPECIALIZE(unsigned, gc_alloc)
-__GC_SPECIALIZE(float, gc_alloc)
-__GC_SPECIALIZE(double, gc_alloc)
-
-__GC_SPECIALIZE(char, alloc)
-__GC_SPECIALIZE(int, alloc)
-__GC_SPECIALIZE(unsigned, alloc)
-__GC_SPECIALIZE(float, alloc)
-__GC_SPECIALIZE(double, alloc)
-
-__GC_SPECIALIZE(char, single_client_gc_alloc)
-__GC_SPECIALIZE(int, single_client_gc_alloc)
-__GC_SPECIALIZE(unsigned, single_client_gc_alloc)
-__GC_SPECIALIZE(float, single_client_gc_alloc)
-__GC_SPECIALIZE(double, single_client_gc_alloc)
-
-__GC_SPECIALIZE(char, single_client_alloc)
-__GC_SPECIALIZE(int, single_client_alloc)
-__GC_SPECIALIZE(unsigned, single_client_alloc)
-__GC_SPECIALIZE(float, single_client_alloc)
-__GC_SPECIALIZE(double, single_client_alloc)
-
-#ifdef __STL_USE_STD_ALLOCATORS
-
-???copy stuff from stl_alloc.h or remove it to a different file ???
-
-#endif /* __STL_USE_STD_ALLOCATORS */
-
-#endif /* _SGI_SOURCE */
-
-#endif /* GC_ALLOC_H */
diff --git a/gc_cpp.h b/gc_cpp.h
deleted file mode 100644
index 3b86824c..00000000
--- a/gc_cpp.h
+++ /dev/null
@@ -1,310 +0,0 @@
-#ifndef GC_CPP_H
-#define GC_CPP_H
-/****************************************************************************
-Copyright (c) 1994 by Xerox Corporation. All rights reserved.
-
-THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
-OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
-
-Permission is hereby granted to use or copy this program for any
-purpose, provided the above notices are retained on all copies.
-Permission to modify the code and to distribute modified code is
-granted, provided the above notices are retained, and a notice that
-the code was modified is included with the above copyright notice.
-****************************************************************************
-
-C++ Interface to the Boehm Collector
-
- John R. Ellis and Jesse Hull
-
-This interface provides access to the Boehm collector. It provides
-basic facilities similar to those described in "Safe, Efficient
-Garbage Collection for C++", by John R. Elis and David L. Detlefs
-(ftp://ftp.parc.xerox.com/pub/ellis/gc).
-
-All heap-allocated objects are either "collectable" or
-"uncollectable". Programs must explicitly delete uncollectable
-objects, whereas the garbage collector will automatically delete
-collectable objects when it discovers them to be inaccessible.
-Collectable objects may freely point at uncollectable objects and vice
-versa.
-
-Objects allocated with the built-in "::operator new" are uncollectable.
-
-Objects derived from class "gc" are collectable. For example:
-
- class A: public gc {...};
- A* a = new A; // a is collectable.
-
-Collectable instances of non-class types can be allocated using the GC
-(or UseGC) placement:
-
- typedef int A[ 10 ];
- A* a = new (GC) A;
-
-Uncollectable instances of classes derived from "gc" can be allocated
-using the NoGC placement:
-
- class A: public gc {...};
- A* a = new (NoGC) A; // a is uncollectable.
-
-Both uncollectable and collectable objects can be explicitly deleted
-with "delete", which invokes an object's destructors and frees its
-storage immediately.
-
-A collectable object may have a clean-up function, which will be
-invoked when the collector discovers the object to be inaccessible.
-An object derived from "gc_cleanup" or containing a member derived
-from "gc_cleanup" has a default clean-up function that invokes the
-object's destructors. Explicit clean-up functions may be specified as
-an additional placement argument:
-
- A* a = ::new (GC, MyCleanup) A;
-
-An object is considered "accessible" by the collector if it can be
-reached by a path of pointers from static variables, automatic
-variables of active functions, or from some object with clean-up
-enabled; pointers from an object to itself are ignored.
-
-Thus, if objects A and B both have clean-up functions, and A points at
-B, B is considered accessible. After A's clean-up is invoked and its
-storage released, B will then become inaccessible and will have its
-clean-up invoked. If A points at B and B points to A, forming a
-cycle, then that's considered a storage leak, and neither will be
-collectable. See the interface gc.h for low-level facilities for
-handling such cycles of objects with clean-up.
-
-The collector cannot guarrantee that it will find all inaccessible
-objects. In practice, it finds almost all of them.
-
-
-Cautions:
-
-1. Be sure the collector has been augmented with "make c++".
-
-2. If your compiler supports the new "operator new[]" syntax, then
-add -DOPERATOR_NEW_ARRAY to the Makefile.
-
-If your compiler doesn't support "operator new[]", beware that an
-array of type T, where T is derived from "gc", may or may not be
-allocated as a collectable object (it depends on the compiler). Use
-the explicit GC placement to make the array collectable. For example:
-
- class A: public gc {...};
- A* a1 = new A[ 10 ]; // collectable or uncollectable?
- A* a2 = new (GC) A[ 10 ]; // collectable
-
-3. The destructors of collectable arrays of objects derived from
-"gc_cleanup" will not be invoked properly. For example:
-
- class A: public gc_cleanup {...};
- A* a = new (GC) A[ 10 ]; // destructors not invoked correctly
-
-Typically, only the destructor for the first element of the array will
-be invoked when the array is garbage-collected. To get all the
-destructors of any array executed, you must supply an explicit
-clean-up function:
-
- A* a = new (GC, MyCleanUp) A[ 10 ];
-
-(Implementing clean-up of arrays correctly, portably, and in a way
-that preserves the correct exception semantics requires a language
-extension, e.g. the "gc" keyword.)
-
-4. Compiler bugs:
-
-* Solaris 2's CC (SC3.0) doesn't implement t->~T() correctly, so the
-destructors of classes derived from gc_cleanup won't be invoked.
-You'll have to explicitly register a clean-up function with
-new-placement syntax.
-
-* Evidently cfront 3.0 does not allow destructors to be explicitly
-invoked using the ANSI-conforming syntax t->~T(). If you're using
-cfront 3.0, you'll have to comment out the class gc_cleanup, which
-uses explicit invocation.
-
-5. GC name conflicts:
-
-Many other systems seem to use the identifier "GC" as an abbreviation
-for "Graphics Context". Since version 5.0, GC placement has been replaced
-by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
-
-****************************************************************************/
-
-#include "gc.h"
-
-#ifndef THINK_CPLUS
-#define _cdecl
-#endif
-
-#if ! defined( OPERATOR_NEW_ARRAY ) \
- && (__BORLANDC__ >= 0x450 || (__GNUC__ >= 2 && __GNUC_MINOR__ >= 6) \
- || __WATCOMC__ >= 1050 || _MSC_VER >= 1100)
-# define OPERATOR_NEW_ARRAY
-#endif
-
-enum GCPlacement {UseGC,
-#ifndef GC_NAME_CONFLICT
- GC=UseGC,
-#endif
- NoGC, PointerFreeGC};
-
-class gc {public:
- inline void* operator new( size_t size );
- inline void* operator new( size_t size, GCPlacement gcp );
- inline void operator delete( void* obj );
-
-#ifdef OPERATOR_NEW_ARRAY
- inline void* operator new[]( size_t size );
- inline void* operator new[]( size_t size, GCPlacement gcp );
- inline void operator delete[]( void* obj );
-#endif /* OPERATOR_NEW_ARRAY */
- };
- /*
- Instances of classes derived from "gc" will be allocated in the
- collected heap by default, unless an explicit NoGC placement is
- specified. */
-
-class gc_cleanup: virtual public gc {public:
- inline gc_cleanup();
- inline virtual ~gc_cleanup();
-private:
- inline static void _cdecl cleanup( void* obj, void* clientData );};
- /*
- Instances of classes derived from "gc_cleanup" will be allocated
- in the collected heap by default. When the collector discovers an
- inaccessible object derived from "gc_cleanup" or containing a
- member derived from "gc_cleanup", its destructors will be
- invoked. */
-
-extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );}
-
-inline void* operator new(
- size_t size,
- GCPlacement gcp,
- GCCleanUpFunc cleanup = 0,
- void* clientData = 0 );
- /*
- Allocates a collectable or uncollected object, according to the
- value of "gcp".
-
- For collectable objects, if "cleanup" is non-null, then when the
- allocated object "obj" becomes inaccessible, the collector will
- invoke the function "cleanup( obj, clientData )" but will not
- invoke the object's destructors. It is an error to explicitly
- delete an object allocated with a non-null "cleanup".
-
- It is an error to specify a non-null "cleanup" with NoGC or for
- classes derived from "gc_cleanup" or containing members derived
- from "gc_cleanup". */
-
-#ifdef OPERATOR_NEW_ARRAY
-
-#ifdef _MSC_VER
- /** This ensures that the system default operator new[] doesn't get
- * undefined, which is what seems to happen on VC++ 6 for some reason
- * if we define a multi-argument operator new[].
- */
- inline void *operator new[]( size_t size )
- {
- return ::operator new( size );
- }
-#endif /* _MSC_VER */
-
-inline void* operator new[](
- size_t size,
- GCPlacement gcp,
- GCCleanUpFunc cleanup = 0,
- void* clientData = 0 );
- /*
- The operator new for arrays, identical to the above. */
-
-#endif /* OPERATOR_NEW_ARRAY */
-
-/****************************************************************************
-
-Inline implementation
-
-****************************************************************************/
-
-inline void* gc::operator new( size_t size ) {
- return GC_MALLOC( size );}
-
-inline void* gc::operator new( size_t size, GCPlacement gcp ) {
- if (gcp == UseGC)
- return GC_MALLOC( size );
- else if (gcp == PointerFreeGC)
- return GC_MALLOC_ATOMIC( size );
- else
- return GC_MALLOC_UNCOLLECTABLE( size );}
-
-inline void gc::operator delete( void* obj ) {
- GC_FREE( obj );}
-
-
-#ifdef OPERATOR_NEW_ARRAY
-
-inline void* gc::operator new[]( size_t size ) {
- return gc::operator new( size );}
-
-inline void* gc::operator new[]( size_t size, GCPlacement gcp ) {
- return gc::operator new( size, gcp );}
-
-inline void gc::operator delete[]( void* obj ) {
- gc::operator delete( obj );}
-
-#endif /* OPERATOR_NEW_ARRAY */
-
-
-inline gc_cleanup::~gc_cleanup() {
- GC_REGISTER_FINALIZER_IGNORE_SELF( GC_base(this), 0, 0, 0, 0 );}
-
-inline void gc_cleanup::cleanup( void* obj, void* displ ) {
- ((gc_cleanup*) ((char*) obj + (ptrdiff_t) displ))->~gc_cleanup();}
-
-inline gc_cleanup::gc_cleanup() {
- GC_finalization_proc oldProc;
- void* oldData;
- void* base = GC_base( (void *) this );
- if (0 != base) {
- GC_REGISTER_FINALIZER_IGNORE_SELF(
- base, (GC_finalization_proc)cleanup, (void*) ((char*) this - (char*) base),
- &oldProc, &oldData );
- if (0 != oldProc) {
- GC_REGISTER_FINALIZER_IGNORE_SELF( base, oldProc, oldData, 0, 0 );}}}
-
-inline void* operator new(
- size_t size,
- GCPlacement gcp,
- GCCleanUpFunc cleanup,
- void* clientData )
-{
- void* obj;
-
- if (gcp == UseGC) {
- obj = GC_MALLOC( size );
- if (cleanup != 0)
- GC_REGISTER_FINALIZER_IGNORE_SELF(
- obj, cleanup, clientData, 0, 0 );}
- else if (gcp == PointerFreeGC) {
- obj = GC_MALLOC_ATOMIC( size );}
- else {
- obj = GC_MALLOC_UNCOLLECTABLE( size );};
- return obj;}
-
-
-#ifdef OPERATOR_NEW_ARRAY
-
-inline void* operator new[](
- size_t size,
- GCPlacement gcp,
- GCCleanUpFunc cleanup,
- void* clientData )
-{
- return ::operator new( size, gcp, cleanup, clientData );}
-
-#endif /* OPERATOR_NEW_ARRAY */
-
-
-#endif /* GC_CPP_H */
-
diff --git a/gc_hdrs.h b/gc_hdrs.h
deleted file mode 100644
index 6966a9a1..00000000
--- a/gc_hdrs.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/* Boehm, July 11, 1995 11:54 am PDT */
-# ifndef GC_HEADERS_H
-# define GC_HEADERS_H
-typedef struct hblkhdr hdr;
-
-# if CPP_WORDSZ != 32 && CPP_WORDSZ < 36
- --> Get a real machine.
-# endif
-
-/*
- * The 2 level tree data structure that is used to find block headers.
- * If there are more than 32 bits in a pointer, the top level is a hash
- * table.
- *
- * This defines HDR, GET_HDR, and SET_HDR, the main macros used to
- * retrieve and set object headers. We also define some variants to
- * retrieve 2 unrelated headers in interleaved fashion. This
- * slightly improves scheduling.
- *
- * Since 5.0 alpha 5, we can also take advantage of a header lookup
- * cache. This is a locally declared direct mapped cache, used inside
- * the marker. The HC_GET_HDR and HC_GET_HDR2 macros use and maintain this
- * cache. Assuming we get reasonable hit rates, this shaves a few
- * memory references from each pointer validation.
- */
-
-# if CPP_WORDSZ > 32
-# define HASH_TL
-# endif
-
-/* Define appropriate out-degrees for each of the two tree levels */
-# ifdef SMALL_CONFIG
-# define LOG_BOTTOM_SZ 11
- /* Keep top index size reasonable with smaller blocks. */
-# else
-# define LOG_BOTTOM_SZ 10
-# endif
-# ifndef HASH_TL
-# define LOG_TOP_SZ (WORDSZ - LOG_BOTTOM_SZ - LOG_HBLKSIZE)
-# else
-# define LOG_TOP_SZ 11
-# endif
-# define TOP_SZ (1 << LOG_TOP_SZ)
-# define BOTTOM_SZ (1 << LOG_BOTTOM_SZ)
-
-#ifndef SMALL_CONFIG
-# define USE_HDR_CACHE
-#endif
-
-/* #define COUNT_HDR_CACHE_HITS */
-
-extern hdr * GC_invalid_header; /* header for an imaginary block */
- /* containing no objects. */
-
-
-/* Check whether p and corresponding hhdr point to long or invalid */
-/* object. If so, advance them to */
-/* beginning of block, or set hhdr to GC_invalid_header. */
-#define ADVANCE(p, hhdr, source) \
- if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) { \
- p = GC_FIND_START(p, hhdr, (word)source); \
- if (p == 0) { \
- hhdr = GC_invalid_header; \
- } else { \
- hhdr = GC_find_header(p); \
- } \
- }
-
-#ifdef USE_HDR_CACHE
-
-# ifdef COUNT_HDR_CACHE_HITS
- extern word GC_hdr_cache_hits;
- extern word GC_hdr_cache_misses;
-# define HC_HIT() ++GC_hdr_cache_hits
-# define HC_MISS() ++GC_hdr_cache_misses
-# else
-# define HC_HIT()
-# define HC_MISS()
-# endif
-
- typedef struct hce {
- word block_addr; /* right shifted by LOG_HBLKSIZE */
- hdr * hce_hdr;
- } hdr_cache_entry;
-
-# define HDR_CACHE_SIZE 8 /* power of 2 */
-
-# define DECLARE_HDR_CACHE \
- hdr_cache_entry hdr_cache[HDR_CACHE_SIZE]
-
-# define INIT_HDR_CACHE BZERO(hdr_cache, sizeof(hdr_cache));
-
-# define HCE(h) hdr_cache + (((word)(h) >> LOG_HBLKSIZE) & (HDR_CACHE_SIZE-1))
-
-# define HCE_VALID_FOR(hce,h) ((hce) -> block_addr == \
- ((word)(h) >> LOG_HBLKSIZE))
-
-# define HCE_HDR(h) ((hce) -> hce_hdr)
-
-
-/* Analogous to GET_HDR, except that in the case of large objects, it */
-/* Returns the header for the object beginning, and updates p. */
-/* Returns &GC_bad_header instead of 0. All of this saves a branch */
-/* in the fast path. */
-# define HC_GET_HDR(p, hhdr, source) \
- { \
- hdr_cache_entry * hce = HCE(p); \
- if (HCE_VALID_FOR(hce, p)) { \
- HC_HIT(); \
- hhdr = hce -> hce_hdr; \
- } else { \
- HC_MISS(); \
- GET_HDR(p, hhdr); \
- ADVANCE(p, hhdr, source); \
- hce -> block_addr = (word)(p) >> LOG_HBLKSIZE; \
- hce -> hce_hdr = hhdr; \
- } \
- }
-
-# define HC_GET_HDR2(p1, hhdr1, source1, p2, hhdr2, source2) \
- { \
- hdr_cache_entry * hce1 = HCE(p1); \
- hdr_cache_entry * hce2 = HCE(p2); \
- if (HCE_VALID_FOR(hce1, p1)) { \
- HC_HIT(); \
- hhdr1 = hce1 -> hce_hdr; \
- } else { \
- HC_MISS(); \
- GET_HDR(p1, hhdr1); \
- ADVANCE(p1, hhdr1, source1); \
- hce1 -> block_addr = (word)(p1) >> LOG_HBLKSIZE; \
- hce1 -> hce_hdr = hhdr1; \
- } \
- if (HCE_VALID_FOR(hce2, p2)) { \
- HC_HIT(); \
- hhdr2 = hce2 -> hce_hdr; \
- } else { \
- HC_MISS(); \
- GET_HDR(p2, hhdr2); \
- ADVANCE(p2, hhdr2, source2); \
- hce2 -> block_addr = (word)(p2) >> LOG_HBLKSIZE; \
- hce2 -> hce_hdr = hhdr2; \
- } \
- }
-
-#else /* !USE_HDR_CACHE */
-
-# define DECLARE_HDR_CACHE
-
-# define INIT_HDR_CACHE
-
-# define HC_GET_HDR(p, hhdr, source) \
- { \
- GET_HDR(p, hhdr); \
- ADVANCE(p, hhdr, source); \
- }
-
-# define HC_GET_HDR2(p1, hhdr1, source1, p2, hhdr2, source2) \
- { \
- GET_HDR2(p1, hhdr1, p2, hhdr2); \
- ADVANCE(p1, hhdr1, source1); \
- ADVANCE(p2, hhdr2, source2); \
- }
-
-#endif
-
-typedef struct bi {
- hdr * index[BOTTOM_SZ];
- /*
- * The bottom level index contains one of three kinds of values:
- * 0 means we're not responsible for this block,
- * or this is a block other than the first one in a free block.
- * 1 < (long)X <= MAX_JUMP means the block starts at least
- * X * HBLKSIZE bytes before the current address.
- * A valid pointer points to a hdr structure. (The above can't be
- * valid pointers due to the GET_MEM return convention.)
- */
- struct bi * asc_link; /* All indices are linked in */
- /* ascending order... */
- struct bi * desc_link; /* ... and in descending order. */
- word key; /* high order address bits. */
-# ifdef HASH_TL
- struct bi * hash_link; /* Hash chain link. */
-# endif
-} bottom_index;
-
-/* extern bottom_index GC_all_nils; - really part of GC_arrays */
-
-/* extern bottom_index * GC_top_index []; - really part of GC_arrays */
- /* Each entry points to a bottom_index. */
- /* On a 32 bit machine, it points to */
- /* the index for a set of high order */
- /* bits equal to the index. For longer */
- /* addresses, we hash the high order */
- /* bits to compute the index in */
- /* GC_top_index, and each entry points */
- /* to a hash chain. */
- /* The last entry in each chain is */
- /* GC_all_nils. */
-
-
-# define MAX_JUMP (HBLKSIZE - 1)
-
-# define HDR_FROM_BI(bi, p) \
- ((bi)->index[((word)(p) >> LOG_HBLKSIZE) & (BOTTOM_SZ - 1)])
-# ifndef HASH_TL
-# define BI(p) (GC_top_index \
- [(word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE)])
-# define HDR_INNER(p) HDR_FROM_BI(BI(p),p)
-# ifdef SMALL_CONFIG
-# define HDR(p) GC_find_header((ptr_t)(p))
-# else
-# define HDR(p) HDR_INNER(p)
-# endif
-# define GET_BI(p, bottom_indx) (bottom_indx) = BI(p)
-# define GET_HDR(p, hhdr) (hhdr) = HDR(p)
-# define SET_HDR(p, hhdr) HDR_INNER(p) = (hhdr)
-# define GET_HDR_ADDR(p, ha) (ha) = &(HDR_INNER(p))
-# define GET_HDR2(p1, hhdr1, p2, hhdr2) \
- { GET_HDR(p1, hhdr1); GET_HDR(p2, hhdr2); }
-# else /* hash */
-/* Hash function for tree top level */
-# define TL_HASH(hi) ((hi) & (TOP_SZ - 1))
-/* Set bottom_indx to point to the bottom index for address p */
-# define GET_BI(p, bottom_indx) \
- { \
- register word hi = \
- (word)(p) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
- register bottom_index * _bi = GC_top_index[TL_HASH(hi)]; \
- \
- while (_bi -> key != hi && _bi != GC_all_nils) \
- _bi = _bi -> hash_link; \
- (bottom_indx) = _bi; \
- }
-# define GET_HDR_ADDR(p, ha) \
- { \
- register bottom_index * bi; \
- \
- GET_BI(p, bi); \
- (ha) = &(HDR_FROM_BI(bi, p)); \
- }
-# define GET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
- (hhdr) = *_ha; }
-# define SET_HDR(p, hhdr) { register hdr ** _ha; GET_HDR_ADDR(p, _ha); \
- *_ha = (hhdr); }
-# define HDR(p) GC_find_header((ptr_t)(p))
- /* And some interleaved versions for two pointers at once. */
- /* This hopefully helps scheduling on processors like IA64. */
-# define GET_BI2(p1, bottom_indx1, p2, bottom_indx2) \
- { \
- register word hi1 = \
- (word)(p1) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
- register word hi2 = \
- (word)(p2) >> (LOG_BOTTOM_SZ + LOG_HBLKSIZE); \
- register bottom_index * _bi1 = GC_top_index[TL_HASH(hi1)]; \
- register bottom_index * _bi2 = GC_top_index[TL_HASH(hi2)]; \
- \
- while (_bi1 -> key != hi1 && _bi1 != GC_all_nils) \
- _bi1 = _bi1 -> hash_link; \
- while (_bi2 -> key != hi2 && _bi2 != GC_all_nils) \
- _bi2 = _bi2 -> hash_link; \
- (bottom_indx1) = _bi1; \
- (bottom_indx2) = _bi2; \
- }
-# define GET_HDR_ADDR2(p1, ha1, p2, ha2) \
- { \
- register bottom_index * bi1; \
- register bottom_index * bi2; \
- \
- GET_BI2(p1, bi1, p2, bi2); \
- (ha1) = &(HDR_FROM_BI(bi1, p1)); \
- (ha2) = &(HDR_FROM_BI(bi2, p2)); \
- }
-# define GET_HDR2(p1, hhdr1, p2, hhdr2) \
- { register hdr ** _ha1; \
- register hdr ** _ha2; \
- GET_HDR_ADDR2(p1, _ha1, p2, _ha2); \
- (hhdr1) = *_ha1; \
- (hhdr2) = *_ha2; \
- }
-# endif
-
-/* Is the result a forwarding address to someplace closer to the */
-/* beginning of the block or NIL? */
-# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP)
-
-/* Get an HBLKSIZE aligned address closer to the beginning of the block */
-/* h. Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr). */
-# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr))
-# endif /* GC_HEADERS_H */
diff --git a/gc_priv.h b/gc_priv.h
deleted file mode 100644
index ce685875..00000000
--- a/gc_priv.h
+++ /dev/null
@@ -1,1884 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
- * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
- * Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
- *
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/* Boehm, February 16, 1996 2:30 pm PST */
-
-
-# ifndef GC_PRIVATE_H
-# define GC_PRIVATE_H
-
-#if defined(mips) && defined(SYSTYPE_BSD) && defined(sony_news)
- /* sony RISC NEWS, NEWSOS 4 */
-# define BSD_TIME
-/* typedef long ptrdiff_t; -- necessary on some really old systems */
-#endif
-
-#if defined(mips) && defined(SYSTYPE_BSD43)
- /* MIPS RISCOS 4 */
-# define BSD_TIME
-#endif
-
-#ifdef BSD_TIME
-# include <sys/types.h>
-# include <sys/time.h>
-# include <sys/resource.h>
-#endif /* BSD_TIME */
-
-# ifndef GC_H
-# include "gc.h"
-# endif
-
-typedef GC_word word;
-typedef GC_signed_word signed_word;
-
-# ifndef GCCONFIG_H
-# include "gcconfig.h"
-# endif
-
-# ifndef HEADERS_H
-# include "gc_hdrs.h"
-# endif
-
-typedef int GC_bool;
-# define TRUE 1
-# define FALSE 0
-
-typedef char * ptr_t; /* A generic pointer to which we can add */
- /* byte displacements. */
- /* Preferably identical to caddr_t, if it */
- /* exists. */
-
-#if defined(__STDC__)
-# include <stdlib.h>
-# if !(defined( sony_news ) )
-# include <stddef.h>
-# endif
-# define VOLATILE volatile
-#else
-# ifdef MSWIN32
-# include <stdlib.h>
-# endif
-# define VOLATILE
-#endif
-
-#define CONST GC_CONST
-
-#if 0 /* was once defined for AMIGA */
-# define GC_FAR __far
-#else
-# define GC_FAR
-#endif
-
-
-/*********************************/
-/* */
-/* Definitions for conservative */
-/* collector */
-/* */
-/*********************************/
-
-/*********************************/
-/* */
-/* Easily changeable parameters */
-/* */
-/*********************************/
-
-#define STUBBORN_ALLOC /* Define stubborn allocation primitives */
-#if defined(SRC_M3) || defined(SMALL_CONFIG)
-# undef STUBBORN_ALLOC
-#endif
-
-
-/* #define ALL_INTERIOR_POINTERS */
- /* Forces all pointers into the interior of an */
- /* object to be considered valid. Also causes the */
- /* sizes of all objects to be inflated by at least */
- /* one byte. This should suffice to guarantee */
- /* that in the presence of a compiler that does */
- /* not perform garbage-collector-unsafe */
- /* optimizations, all portable, strictly ANSI */
- /* conforming C programs should be safely usable */
- /* with malloc replaced by GC_malloc and free */
- /* calls removed. There are several disadvantages: */
- /* 1. There are probably no interesting, portable, */
- /* strictly ANSI conforming C programs. */
- /* 2. This option makes it hard for the collector */
- /* to allocate space that is not ``pointed to'' */
- /* by integers, etc. Under SunOS 4.X with a */
- /* statically linked libc, we empiricaly */
- /* observed that it would be difficult to */
- /* allocate individual objects larger than 100K. */
- /* Even if only smaller objects are allocated, */
- /* more swap space is likely to be needed. */
- /* Fortunately, much of this will never be */
- /* touched. */
- /* If you can easily avoid using this option, do. */
- /* If not, try to keep individual objects small. */
-
-#define PRINTSTATS /* Print garbage collection statistics */
- /* For less verbose output, undefine in reclaim.c */
-
-#define PRINTTIMES /* Print the amount of time consumed by each garbage */
- /* collection. */
-
-#define PRINTBLOCKS /* Print object sizes associated with heap blocks, */
- /* whether the objects are atomic or composite, and */
- /* whether or not the block was found to be empty */
- /* during the reclaim phase. Typically generates */
- /* about one screenful per garbage collection. */
-#undef PRINTBLOCKS
-
-#ifdef SILENT
-# ifdef PRINTSTATS
-# undef PRINTSTATS
-# endif
-# ifdef PRINTTIMES
-# undef PRINTTIMES
-# endif
-# ifdef PRINTNBLOCKS
-# undef PRINTNBLOCKS
-# endif
-#endif
-
-#if defined(PRINTSTATS) && !defined(GATHERSTATS)
-# define GATHERSTATS
-#endif
-
-#ifdef FINALIZE_ON_DEMAND
-# define GC_INVOKE_FINALIZERS()
-#else
-# define GC_INVOKE_FINALIZERS() (void)GC_invoke_finalizers()
-#endif
-
-#define MERGE_SIZES /* Round up some object sizes, so that fewer distinct */
- /* free lists are actually maintained. This applies */
- /* only to the top level routines in misc.c, not to */
- /* user generated code that calls GC_allocobj and */
- /* GC_allocaobj directly. */
- /* Slows down average programs slightly. May however */
- /* substantially reduce fragmentation if allocation */
- /* request sizes are widely scattered. */
- /* May save significant amounts of space for obj_map */
- /* entries. */
-
-/* ALIGN_DOUBLE requires MERGE_SIZES at present. */
-# if defined(ALIGN_DOUBLE) && !defined(MERGE_SIZES)
-# define MERGE_SIZES
-# endif
-
-#if defined(ALL_INTERIOR_POINTERS) && !defined(DONT_ADD_BYTE_AT_END)
-# define ADD_BYTE_AT_END
-#endif
-
-
-# ifndef LARGE_CONFIG
-# define MINHINCR 16 /* Minimum heap increment, in blocks of HBLKSIZE */
- /* Must be multiple of largest page size. */
-# define MAXHINCR 512 /* Maximum heap increment, in blocks */
-# else
-# define MINHINCR 64
-# define MAXHINCR 4096
-# endif
-
-# define TIME_LIMIT 50 /* We try to keep pause times from exceeding */
- /* this by much. In milliseconds. */
-
-# define BL_LIMIT GC_black_list_spacing
- /* If we need a block of N bytes, and we have */
- /* a block of N + BL_LIMIT bytes available, */
- /* and N > BL_LIMIT, */
- /* but all possible positions in it are */
- /* blacklisted, we just use it anyway (and */
- /* print a warning, if warnings are enabled). */
- /* This risks subsequently leaking the block */
- /* due to a false reference. But not using */
- /* the block risks unreasonable immediate */
- /* heap growth. */
-
-/*********************************/
-/* */
-/* Stack saving for debugging */
-/* */
-/*********************************/
-
-#ifdef SAVE_CALL_CHAIN
-
-/*
- * Number of frames and arguments to save in objects allocated by
- * debugging allocator.
- */
-# define NFRAMES 6 /* Number of frames to save. Even for */
- /* alignment reasons. */
-# define NARGS 2 /* Mumber of arguments to save for each call. */
-
-# define NEED_CALLINFO
-
-/* Fill in the pc and argument information for up to NFRAMES of my */
-/* callers. Ignore my frame and my callers frame. */
-void GC_save_callers (/* struct callinfo info[NFRAMES] */);
-
-void GC_print_callers (/* struct callinfo info[NFRAMES] */);
-
-#else
-
-# ifdef GC_ADD_CALLER
-# define NFRAMES 1
-# define NARGS 0
-# define NEED_CALLINFO
-# endif
-
-#endif
-
-#ifdef NEED_CALLINFO
- struct callinfo {
- word ci_pc;
-# if NARGS > 0
- word ci_arg[NARGS]; /* bit-wise complement to avoid retention */
-# endif
-# if defined(ALIGN_DOUBLE) && (NFRAMES * (NARGS + 1)) % 2 == 1
- /* Likely alignment problem. */
- word ci_dummy;
-# endif
- };
-#endif
-
-
-/*********************************/
-/* */
-/* OS interface routines */
-/* */
-/*********************************/
-
-#ifdef BSD_TIME
-# undef CLOCK_TYPE
-# undef GET_TIME
-# undef MS_TIME_DIFF
-# define CLOCK_TYPE struct timeval
-# define GET_TIME(x) { struct rusage rusage; \
- getrusage (RUSAGE_SELF, &rusage); \
- x = rusage.ru_utime; }
-# define MS_TIME_DIFF(a,b) ((double) (a.tv_sec - b.tv_sec) * 1000.0 \
- + (double) (a.tv_usec - b.tv_usec) / 1000.0)
-#else /* !BSD_TIME */
-# ifdef MSWIN32
-# include <windows.h>
-# include <winbase.h>
-# define CLOCK_TYPE DWORD
-# define GET_TIME(x) x = GetTickCount()
-# define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
-# else /* !MSWIN32, !BSD_TIME */
-# include <time.h>
-# if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4)
- clock_t clock(); /* Not in time.h, where it belongs */
-# endif
-# if defined(FREEBSD) && !defined(CLOCKS_PER_SEC)
-# include <machine/limits.h>
-# define CLOCKS_PER_SEC CLK_TCK
-# endif
-# if !defined(CLOCKS_PER_SEC)
-# define CLOCKS_PER_SEC 1000000
-/*
- * This is technically a bug in the implementation. ANSI requires that
- * CLOCKS_PER_SEC be defined. But at least under SunOS4.1.1, it isn't.
- * Also note that the combination of ANSI C and POSIX is incredibly gross
- * here. The type clock_t is used by both clock() and times(). But on
- * some machines these use different notions of a clock tick, CLOCKS_PER_SEC
- * seems to apply only to clock. Hence we use it here. On many machines,
- * including SunOS, clock actually uses units of microseconds (which are
- * not really clock ticks).
- */
-# endif
-# define CLOCK_TYPE clock_t
-# define GET_TIME(x) x = clock()
-# define MS_TIME_DIFF(a,b) ((unsigned long) \
- (1000.0*(double)((a)-(b))/(double)CLOCKS_PER_SEC))
-# endif /* !MSWIN32 */
-#endif /* !BSD_TIME */
-
-/* We use bzero and bcopy internally. They may not be available. */
-# if defined(SPARC) && defined(SUNOS4)
-# define BCOPY_EXISTS
-# endif
-# if defined(M68K) && defined(AMIGA)
-# define BCOPY_EXISTS
-# endif
-# if defined(M68K) && defined(NEXT)
-# define BCOPY_EXISTS
-# endif
-# if defined(VAX)
-# define BCOPY_EXISTS
-# endif
-# if defined(AMIGA)
-# include <string.h>
-# define BCOPY_EXISTS
-# endif
-
-# ifndef BCOPY_EXISTS
-# include <string.h>
-# define BCOPY(x,y,n) memcpy(y, x, (size_t)(n))
-# define BZERO(x,n) memset(x, 0, (size_t)(n))
-# else
-# define BCOPY(x,y,n) bcopy((char *)(x),(char *)(y),(int)(n))
-# define BZERO(x,n) bzero((char *)(x),(int)(n))
-# endif
-
-/* HBLKSIZE aligned allocation. 0 is taken to mean failure */
-/* space is assumed to be cleared. */
-/* In the case os USE_MMAP, the argument must also be a */
-/* physical page size. */
-/* GET_MEM is currently not assumed to retrieve 0 filled space, */
-/* though we should perhaps take advantage of the case in which */
-/* does. */
-# ifdef PCR
- char * real_malloc();
-# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
- + GC_page_size-1)
-# else
-# ifdef OS2
- void * os2_alloc(size_t bytes);
-# define GET_MEM(bytes) HBLKPTR((ptr_t)os2_alloc((size_t)bytes \
- + GC_page_size) \
- + GC_page_size-1)
-# else
-# if defined(AMIGA) || defined(NEXT) || defined(MACOSX) || defined(DOS4GW)
-# define GET_MEM(bytes) HBLKPTR((size_t) \
- calloc(1, (size_t)bytes + GC_page_size) \
- + GC_page_size-1)
-# else
-# ifdef MSWIN32
- extern ptr_t GC_win32_get_mem();
-# define GET_MEM(bytes) (struct hblk *)GC_win32_get_mem(bytes)
-# else
-# ifdef MACOS
-# if defined(USE_TEMPORARY_MEMORY)
- extern Ptr GC_MacTemporaryNewPtr(size_t size,
- Boolean clearMemory);
-# define GET_MEM(bytes) HBLKPTR( \
- GC_MacTemporaryNewPtr(bytes + GC_page_size, true) \
- + GC_page_size-1)
-# else
-# define GET_MEM(bytes) HBLKPTR( \
- NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
-# endif
-# else
- extern ptr_t GC_unix_get_mem();
-# define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
-# endif
-# endif
-# endif
-# endif
-# endif
-
-/*
- * Mutual exclusion between allocator/collector routines.
- * Needed if there is more than one allocator thread.
- * FASTLOCK() is assumed to try to acquire the lock in a cheap and
- * dirty way that is acceptable for a few instructions, e.g. by
- * inhibiting preemption. This is assumed to have succeeded only
- * if a subsequent call to FASTLOCK_SUCCEEDED() returns TRUE.
- * FASTUNLOCK() is called whether or not FASTLOCK_SUCCEEDED().
- * If signals cannot be tolerated with the FASTLOCK held, then
- * FASTLOCK should disable signals. The code executed under
- * FASTLOCK is otherwise immune to interruption, provided it is
- * not restarted.
- * DCL_LOCK_STATE declares any local variables needed by LOCK and UNLOCK
- * and/or DISABLE_SIGNALS and ENABLE_SIGNALS and/or FASTLOCK.
- * (There is currently no equivalent for FASTLOCK.)
- */
-# ifdef THREADS
-# ifdef PCR_OBSOLETE /* Faster, but broken with multiple lwp's */
-# include "th/PCR_Th.h"
-# include "th/PCR_ThCrSec.h"
- extern struct PCR_Th_MLRep GC_allocate_ml;
-# define DCL_LOCK_STATE PCR_sigset_t GC_old_sig_mask
-# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
-# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
-# define FASTLOCK() PCR_ThCrSec_EnterSys()
- /* Here we cheat (a lot): */
-# define FASTLOCK_SUCCEEDED() (*(int *)(&GC_allocate_ml) == 0)
- /* TRUE if nobody currently holds the lock */
-# define FASTUNLOCK() PCR_ThCrSec_ExitSys()
-# endif
-# ifdef PCR
-# include <base/PCR_Base.h>
-# include <th/PCR_Th.h>
- extern PCR_Th_ML GC_allocate_ml;
-# define DCL_LOCK_STATE \
- PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask
-# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
-# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
-# define FASTLOCK() (GC_fastLockRes = PCR_Th_ML_Try(&GC_allocate_ml))
-# define FASTLOCK_SUCCEEDED() (GC_fastLockRes == PCR_ERes_okay)
-# define FASTUNLOCK() {\
- if( FASTLOCK_SUCCEEDED() ) PCR_Th_ML_Release(&GC_allocate_ml); }
-# endif
-# ifdef SRC_M3
- extern word RT0u__inCritical;
-# define LOCK() RT0u__inCritical++
-# define UNLOCK() RT0u__inCritical--
-# endif
-# ifdef SOLARIS_THREADS
-# include <thread.h>
-# include <signal.h>
- extern mutex_t GC_allocate_ml;
-# define LOCK() mutex_lock(&GC_allocate_ml);
-# define UNLOCK() mutex_unlock(&GC_allocate_ml);
-# endif
-# if defined(LINUX_THREADS)
-# if defined(I386)|| defined(POWERPC) || defined(ALPHA) || defined(IA64) \
- || defined(M68K)
-# include <pthread.h>
-# define USE_SPIN_LOCK
-# if defined(I386)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- /* Note: the "xchg" instruction does not need a "lock" prefix */
- __asm__ __volatile__("xchgl %0, %1"
- : "=r"(oldval), "=m"(*(addr))
- : "0"(1), "m"(*(addr)));
- return oldval;
- }
-# endif
-# if defined(IA64)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- __asm__ __volatile__("xchg4 %0=%1,%2"
- : "=r"(oldval), "=m"(*addr)
- : "r"(1), "1"(*addr));
- return oldval;
- }
- inline static void GC_clear(volatile unsigned int *addr) {
- __asm__ __volatile__("st4.rel %0=r0" : "=m" (*addr));
- }
-# define GC_CLEAR_DEFINED
-# endif
-# ifdef M68K
- /* Contributed by Tony Mantler. I'm not sure how well it was */
- /* tested. */
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- char oldval; /* this must be no longer than 8 bits */
-
- /* The return value is semi-phony. */
- /* 'tas' sets bit 7 while the return */
- /* value pretends bit 0 was set */
- __asm__ __volatile__(
- "tas %1@; sne %0; negb %0"
- : "=d" (oldval)
- : "a" (addr));
- return oldval;
- }
-# endif
-# if defined(POWERPC)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- int temp = 1; // locked value
-
- __asm__ __volatile__(
- "1:\tlwarx %0,0,%3\n" // load and reserve
- "\tcmpwi %0, 0\n" // if load is
- "\tbne 2f\n" // non-zero, return already set
- "\tstwcx. %2,0,%1\n" // else store conditional
- "\tbne- 1b\n" // retry if lost reservation
- "2:\t\n" // oldval is zero if we set
- : "=&r"(oldval), "=p"(addr)
- : "r"(temp), "1"(addr)
- : "memory");
- return (int)oldval;
- }
- inline static void GC_clear(volatile unsigned int *addr) {
- __asm__ __volatile__("eieio");
- *(addr) = 0;
- }
-# define GC_CLEAR_DEFINED
-# endif
-# ifdef ALPHA
- inline static int GC_test_and_set(volatile unsigned int * addr)
- {
- unsigned long oldvalue;
- unsigned long temp;
-
- __asm__ __volatile__(
- "1: ldl_l %0,%1\n"
- " and %0,%3,%2\n"
- " bne %2,2f\n"
- " xor %0,%3,%0\n"
- " stl_c %0,%1\n"
- " beq %0,3f\n"
- " mb\n"
- "2:\n"
- ".section .text2,\"ax\"\n"
- "3: br 1b\n"
- ".previous"
- :"=&r" (temp), "=m" (*addr), "=&r" (oldvalue)
- :"Ir" (1), "m" (*addr));
-
- return oldvalue;
- }
- /* Should probably also define GC_clear, since it needs */
- /* a memory barrier ?? */
-# endif /* ALPHA */
-# ifdef ARM32
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- /* SWP on ARM is very similar to XCHG on x86. Doesn't lock the
- * bus because there are no SMP ARM machines. If/when there are,
- * this code will likely need to be updated. */
- /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */
- __asm__ __volatile__("swp %0, %1, [%2]"
- : "=r"(oldval)
- : "r"(1), "r"(addr));
- return oldval;
- }
-# endif
-# ifndef GC_CLEAR_DEFINED
- inline static void GC_clear(volatile unsigned int *addr) {
- /* Try to discourage gcc from moving anything past this. */
- __asm__ __volatile__(" ");
- *(addr) = 0;
- }
-# endif
-
- extern volatile unsigned int GC_allocate_lock;
- extern pthread_t GC_lock_holder;
- extern void GC_lock(void);
- /* Allocation lock holder. Only set if acquired by client through */
- /* GC_call_with_alloc_lock. */
-# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
-# define NO_THREAD (pthread_t)(-1)
-# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
-# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
-# define LOCK() \
- { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); }
-# define UNLOCK() \
- GC_clear(&GC_allocate_lock)
- extern VOLATILE GC_bool GC_collecting;
-# define ENTER_GC() \
- { \
- GC_collecting = 1; \
- }
-# define EXIT_GC() GC_collecting = 0;
-# else /* LINUX_THREADS on hardware for which we don't know how */
- /* to do test and set. */
-# include <pthread.h>
- extern pthread_mutex_t GC_allocate_ml;
-# define LOCK() pthread_mutex_lock(&GC_allocate_ml)
-# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
-# endif
-# endif /* LINUX_THREADS */
-# if defined(HPUX_THREADS)
-# include <pthread.h>
- extern pthread_mutex_t GC_allocate_ml;
-# define LOCK() pthread_mutex_lock(&GC_allocate_ml)
-# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
-# endif
-# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS)
- /* This may also eventually be appropriate for HPUX_THREADS */
-# include <pthread.h>
-# ifndef HPUX_THREADS
- /* This probably should never be included, but I can't test */
- /* on Irix anymore. */
-# include <mutex.h>
-# endif
-
-# ifndef HPUX_THREADS
-# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) \
- || !defined(_COMPILER_VERSION) || _COMPILER_VERSION < 700
-# define GC_test_and_set(addr, v) test_and_set(addr,v)
-# else
-# define GC_test_and_set(addr, v) __test_and_set(addr,v)
-# endif
-# else
- /* I couldn't find a way to do this inline on HP/UX */
-# endif
- extern unsigned long GC_allocate_lock;
- /* This is not a mutex because mutexes that obey the (optional) */
- /* POSIX scheduling rules are subject to convoys in high contention */
- /* applications. This is basically a spin lock. */
- extern pthread_t GC_lock_holder;
- extern void GC_lock(void);
- /* Allocation lock holder. Only set if acquired by client through */
- /* GC_call_with_alloc_lock. */
-# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
-# define NO_THREAD (pthread_t)(-1)
-# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
-# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
-# ifdef HPUX_THREADS
-# define LOCK() { if (!GC_test_and_clear(&GC_allocate_lock)) GC_lock(); }
- /* The following is INCORRECT, since the memory model is too weak. */
-# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
- *(volatile unsigned long *)(&GC_allocate_lock) = 1; }
-# else
-# define LOCK() { if (GC_test_and_set(&GC_allocate_lock, 1)) GC_lock(); }
-# if __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) \
- && defined(_COMPILER_VERSION) && _COMPILER_VERSION >= 700
-# define UNLOCK() __lock_release(&GC_allocate_lock)
-# else
- /* The function call in the following should prevent the */
- /* compiler from moving assignments to below the UNLOCK. */
- /* This is probably not necessary for ucode or gcc 2.8. */
- /* It may be necessary for Ragnarok and future gcc */
- /* versions. */
-# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
- *(volatile unsigned long *)(&GC_allocate_lock) = 0; }
-# endif
-# endif
- extern VOLATILE GC_bool GC_collecting;
-# define ENTER_GC() \
- { \
- GC_collecting = 1; \
- }
-# define EXIT_GC() GC_collecting = 0;
-# endif /* IRIX_THREADS || IRIX_JDK_THREADS */
-# ifdef WIN32_THREADS
-# include <windows.h>
- GC_API CRITICAL_SECTION GC_allocate_ml;
-# define LOCK() EnterCriticalSection(&GC_allocate_ml);
-# define UNLOCK() LeaveCriticalSection(&GC_allocate_ml);
-# endif
-# ifndef SET_LOCK_HOLDER
-# define SET_LOCK_HOLDER()
-# define UNSET_LOCK_HOLDER()
-# define I_HOLD_LOCK() FALSE
- /* Used on platforms were locks can be reacquired, */
- /* so it doesn't matter if we lie. */
-# endif
-# else
-# define LOCK()
-# define UNLOCK()
-# endif
-# ifndef SET_LOCK_HOLDER
-# define SET_LOCK_HOLDER()
-# define UNSET_LOCK_HOLDER()
-# define I_HOLD_LOCK() FALSE
- /* Used on platforms were locks can be reacquired, */
- /* so it doesn't matter if we lie. */
-# endif
-# ifndef ENTER_GC
-# define ENTER_GC()
-# define EXIT_GC()
-# endif
-
-# ifndef DCL_LOCK_STATE
-# define DCL_LOCK_STATE
-# endif
-# ifndef FASTLOCK
-# define FASTLOCK() LOCK()
-# define FASTLOCK_SUCCEEDED() TRUE
-# define FASTUNLOCK() UNLOCK()
-# endif
-
-/* Delay any interrupts or signals that may abort this thread. Data */
-/* structures are in a consistent state outside this pair of calls. */
-/* ANSI C allows both to be empty (though the standard isn't very */
-/* clear on that point). Standard malloc implementations are usually */
-/* neither interruptable nor thread-safe, and thus correspond to */
-/* empty definitions. */
-# ifdef PCR
-# define DISABLE_SIGNALS() \
- PCR_Th_SetSigMask(PCR_allSigsBlocked,&GC_old_sig_mask)
-# define ENABLE_SIGNALS() \
- PCR_Th_SetSigMask(&GC_old_sig_mask, NIL)
-# else
-# if defined(SRC_M3) || defined(AMIGA) || defined(SOLARIS_THREADS) \
- || defined(MSWIN32) || defined(MACOS) || defined(DJGPP) \
- || defined(NO_SIGNALS) || defined(IRIX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(LINUX_THREADS)
- /* Also useful for debugging. */
- /* Should probably use thr_sigsetmask for SOLARIS_THREADS. */
-# define DISABLE_SIGNALS()
-# define ENABLE_SIGNALS()
-# else
-# define DISABLE_SIGNALS() GC_disable_signals()
- void GC_disable_signals();
-# define ENABLE_SIGNALS() GC_enable_signals()
- void GC_enable_signals();
-# endif
-# endif
-
-/*
- * Stop and restart mutator threads.
- */
-# ifdef PCR
-# include "th/PCR_ThCtl.h"
-# define STOP_WORLD() \
- PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_stopNormal, \
- PCR_allSigsBlocked, \
- PCR_waitForever)
-# define START_WORLD() \
- PCR_ThCtl_SetExclusiveMode(PCR_ThCtl_ExclusiveMode_null, \
- PCR_allSigsBlocked, \
- PCR_waitForever);
-# else
-# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \
- || defined(IRIX_THREADS) || defined(LINUX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
- void GC_stop_world();
- void GC_start_world();
-# define STOP_WORLD() GC_stop_world()
-# define START_WORLD() GC_start_world()
-# else
-# define STOP_WORLD()
-# define START_WORLD()
-# endif
-# endif
-
-/* Abandon ship */
-# ifdef PCR
-# define ABORT(s) PCR_Base_Panic(s)
-# else
-# ifdef SMALL_CONFIG
-# define ABORT(msg) abort();
-# else
- GC_API void GC_abort();
-# define ABORT(msg) GC_abort(msg);
-# endif
-# endif
-
-/* Exit abnormally, but without making a mess (e.g. out of memory) */
-# ifdef PCR
-# define EXIT() PCR_Base_Exit(1,PCR_waitForever)
-# else
-# define EXIT() (void)exit(1)
-# endif
-
-/* Print warning message, e.g. almost out of memory. */
-# define WARN(msg,arg) (*GC_current_warn_proc)(msg, (GC_word)(arg))
-extern GC_warn_proc GC_current_warn_proc;
-
-/*********************************/
-/* */
-/* Word-size-dependent defines */
-/* */
-/*********************************/
-
-#if CPP_WORDSZ == 32
-# define WORDS_TO_BYTES(x) ((x)<<2)
-# define BYTES_TO_WORDS(x) ((x)>>2)
-# define LOGWL ((word)5) /* log[2] of CPP_WORDSZ */
-# define modWORDSZ(n) ((n) & 0x1f) /* n mod size of word */
-# if ALIGNMENT != 4
-# define UNALIGNED
-# endif
-#endif
-
-#if CPP_WORDSZ == 64
-# define WORDS_TO_BYTES(x) ((x)<<3)
-# define BYTES_TO_WORDS(x) ((x)>>3)
-# define LOGWL ((word)6) /* log[2] of CPP_WORDSZ */
-# define modWORDSZ(n) ((n) & 0x3f) /* n mod size of word */
-# if ALIGNMENT != 8
-# define UNALIGNED
-# endif
-#endif
-
-#define WORDSZ ((word)CPP_WORDSZ)
-#define SIGNB ((word)1 << (WORDSZ-1))
-#define BYTES_PER_WORD ((word)(sizeof (word)))
-#define ONES ((word)(-1))
-#define divWORDSZ(n) ((n) >> LOGWL) /* divide n by size of word */
-
-/*********************/
-/* */
-/* Size Parameters */
-/* */
-/*********************/
-
-/* heap block size, bytes. Should be power of 2 */
-
-#ifndef HBLKSIZE
-# ifdef SMALL_CONFIG
-# define CPP_LOG_HBLKSIZE 10
-# else
-# if CPP_WORDSZ == 32
-# define CPP_LOG_HBLKSIZE 12
-# else
-# define CPP_LOG_HBLKSIZE 13
-# endif
-# endif
-#else
-# if HBLKSIZE == 512
-# define CPP_LOG_HBLKSIZE 9
-# endif
-# if HBLKSIZE == 1024
-# define CPP_LOG_HBLKSIZE 10
-# endif
-# if HBLKSIZE == 2048
-# define CPP_LOG_HBLKSIZE 11
-# endif
-# if HBLKSIZE == 4096
-# define CPP_LOG_HBLKSIZE 12
-# endif
-# if HBLKSIZE == 8192
-# define CPP_LOG_HBLKSIZE 13
-# endif
-# if HBLKSIZE == 16384
-# define CPP_LOG_HBLKSIZE 14
-# endif
-# ifndef CPP_LOG_HBLKSIZE
- --> fix HBLKSIZE
-# endif
-# undef HBLKSIZE
-#endif
-# define CPP_HBLKSIZE (1 << CPP_LOG_HBLKSIZE)
-# define LOG_HBLKSIZE ((word)CPP_LOG_HBLKSIZE)
-# define HBLKSIZE ((word)CPP_HBLKSIZE)
-
-
-/* max size objects supported by freelist (larger objects may be */
-/* allocated, but less efficiently) */
-
-#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2)
-#define MAXOBJSZ ((word)CPP_MAXOBJSZ)
-
-# define divHBLKSZ(n) ((n) >> LOG_HBLKSIZE)
-
-# define HBLK_PTR_DIFF(p,q) divHBLKSZ((ptr_t)p - (ptr_t)q)
- /* Equivalent to subtracting 2 hblk pointers. */
- /* We do it this way because a compiler should */
- /* find it hard to use an integer division */
- /* instead of a shift. The bundled SunOS 4.1 */
- /* o.w. sometimes pessimizes the subtraction to */
- /* involve a call to .div. */
-
-# define modHBLKSZ(n) ((n) & (HBLKSIZE-1))
-
-# define HBLKPTR(objptr) ((struct hblk *)(((word) (objptr)) & ~(HBLKSIZE-1)))
-
-# define HBLKDISPL(objptr) (((word) (objptr)) & (HBLKSIZE-1))
-
-/* Round up byte allocation requests to integral number of words, etc. */
-# ifdef ADD_BYTE_AT_END
-# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + WORDS_TO_BYTES(1))
-# ifdef ALIGN_DOUBLE
-# define ALIGNED_WORDS(n) (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2)) & ~1)
-# else
-# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n)
-# endif
-# define SMALL_OBJ(bytes) ((bytes) < WORDS_TO_BYTES(MAXOBJSZ))
-# define ADD_SLOP(bytes) ((bytes)+1)
-# else
-# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + (WORDS_TO_BYTES(1) - 1))
-# ifdef ALIGN_DOUBLE
-# define ALIGNED_WORDS(n) \
- (BYTES_TO_WORDS((n) + WORDS_TO_BYTES(2) - 1) & ~1)
-# else
-# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n)
-# endif
-# define SMALL_OBJ(bytes) ((bytes) <= WORDS_TO_BYTES(MAXOBJSZ))
-# define ADD_SLOP(bytes) (bytes)
-# endif
-
-
-/*
- * Hash table representation of sets of pages. This assumes it is
- * OK to add spurious entries to sets.
- * Used by black-listing code, and perhaps by dirty bit maintenance code.
- */
-
-# ifdef LARGE_CONFIG
-# define LOG_PHT_ENTRIES 17
-# else
-# define LOG_PHT_ENTRIES 14 /* Collisions are likely if heap grows */
- /* to more than 16K hblks = 64MB. */
- /* Each hash table occupies 2K bytes. */
-# endif
-# define PHT_ENTRIES ((word)1 << LOG_PHT_ENTRIES)
-# define PHT_SIZE (PHT_ENTRIES >> LOGWL)
-typedef word page_hash_table[PHT_SIZE];
-
-# define PHT_HASH(addr) ((((word)(addr)) >> LOG_HBLKSIZE) & (PHT_ENTRIES - 1))
-
-# define get_pht_entry_from_index(bl, index) \
- (((bl)[divWORDSZ(index)] >> modWORDSZ(index)) & 1)
-# define set_pht_entry_from_index(bl, index) \
- (bl)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index)
-# define clear_pht_entry_from_index(bl, index) \
- (bl)[divWORDSZ(index)] &= ~((word)1 << modWORDSZ(index))
-
-
-
-/********************************************/
-/* */
-/* H e a p B l o c k s */
-/* */
-/********************************************/
-
-/* heap block header */
-#define HBLKMASK (HBLKSIZE-1)
-
-#define BITS_PER_HBLK (HBLKSIZE * 8)
-
-#define MARK_BITS_PER_HBLK (BITS_PER_HBLK/CPP_WORDSZ)
- /* upper bound */
- /* We allocate 1 bit/word. Only the first word */
- /* in each object is actually marked. */
-
-# ifdef ALIGN_DOUBLE
-# define MARK_BITS_SZ (((MARK_BITS_PER_HBLK + 2*CPP_WORDSZ - 1) \
- / (2*CPP_WORDSZ))*2)
-# else
-# define MARK_BITS_SZ ((MARK_BITS_PER_HBLK + CPP_WORDSZ - 1)/CPP_WORDSZ)
-# endif
- /* Upper bound on number of mark words per heap block */
-
-struct hblkhdr {
- word hb_sz; /* If in use, size in words, of objects in the block. */
- /* if free, the size in bytes of the whole block */
- struct hblk * hb_next; /* Link field for hblk free list */
- /* and for lists of chunks waiting to be */
- /* reclaimed. */
- struct hblk * hb_prev; /* Backwards link for free list. */
- word hb_descr; /* object descriptor for marking. See */
- /* mark.h. */
- char* hb_map; /* A pointer to a pointer validity map of the block. */
- /* See GC_obj_map. */
- /* Valid for all blocks with headers. */
- /* Free blocks point to GC_invalid_map. */
- unsigned char hb_obj_kind;
- /* Kind of objects in the block. Each kind */
- /* identifies a mark procedure and a set of */
- /* list headers. Sometimes called regions. */
- unsigned char hb_flags;
-# define IGNORE_OFF_PAGE 1 /* Ignore pointers that do not */
- /* point to the first page of */
- /* this object. */
-# define WAS_UNMAPPED 2 /* This is a free block, which has */
- /* been unmapped from the address */
- /* space. */
- /* GC_remap must be invoked on it */
- /* before it can be reallocated. */
- /* Only set with USE_MUNMAP. */
- unsigned short hb_last_reclaimed;
- /* Value of GC_gc_no when block was */
- /* last allocated or swept. May wrap. */
- /* For a free block, this is maintained */
- /* unly for USE_MUNMAP, and indicates */
- /* when the header was allocated, or */
- /* when the size of the block last */
- /* changed. */
- word hb_marks[MARK_BITS_SZ];
- /* Bit i in the array refers to the */
- /* object starting at the ith word (header */
- /* INCLUDED) in the heap block. */
- /* The lsb of word 0 is numbered 0. */
- /* Unused bits are invalid, and are */
- /* occasionally set, e.g for uncollectable */
- /* objects. */
-};
-
-/* heap block body */
-
-# define DISCARD_WORDS 0
- /* Number of words to be dropped at the beginning of each block */
- /* Must be a multiple of WORDSZ. May reasonably be nonzero */
- /* on machines that don't guarantee longword alignment of */
- /* pointers, so that the number of false hits is minimized. */
- /* 0 and WORDSZ are probably the only reasonable values. */
-
-# define BODY_SZ ((HBLKSIZE-WORDS_TO_BYTES(DISCARD_WORDS))/sizeof(word))
-
-struct hblk {
-# if (DISCARD_WORDS != 0)
- word garbage[DISCARD_WORDS];
-# endif
- word hb_body[BODY_SZ];
-};
-
-# define HDR_WORDS ((word)DISCARD_WORDS)
-# define HDR_BYTES ((word)WORDS_TO_BYTES(DISCARD_WORDS))
-
-# define OBJ_SZ_TO_BLOCKS(sz) \
- divHBLKSZ(HDR_BYTES + WORDS_TO_BYTES(sz) + HBLKSIZE-1)
- /* Size of block (in units of HBLKSIZE) needed to hold objects of */
- /* given sz (in words). */
-
-/* Object free list link */
-# define obj_link(p) (*(ptr_t *)(p))
-
-/* The type of mark procedures. This really belongs in gc_mark.h. */
-/* But we put it here, so that we can avoid scanning the mark proc */
-/* table. */
-typedef struct ms_entry * (*mark_proc)(/* word * addr,
- struct ms_entry *mark_stack_ptr,
- struct ms_entry *mark_stack_limit,
- word env */);
-# define LOG_MAX_MARK_PROCS 6
-# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS)
-
-/* Root sets. Logically private to mark_rts.c. But we don't want the */
-/* tables scanned, so we put them here. */
-/* MAX_ROOT_SETS is the maximum number of ranges that can be */
-/* registered as static roots. */
-# ifdef LARGE_CONFIG
-# define MAX_ROOT_SETS 4096
-# else
-# ifdef PCR
-# define MAX_ROOT_SETS 1024
-# else
-# ifdef MSWIN32
-# define MAX_ROOT_SETS 512
- /* Under NT, we add only written pages, which can result */
- /* in many small root sets. */
-# else
-# define MAX_ROOT_SETS 64
-# endif
-# endif
-# endif
-
-# define MAX_EXCLUSIONS (MAX_ROOT_SETS/4)
-/* Maximum number of segments that can be excluded from root sets. */
-
-/*
- * Data structure for excluded static roots.
- */
-struct exclusion {
- ptr_t e_start;
- ptr_t e_end;
-};
-
-/* Data structure for list of root sets. */
-/* We keep a hash table, so that we can filter out duplicate additions. */
-/* Under Win32, we need to do a better job of filtering overlaps, so */
-/* we resort to sequential search, and pay the price. */
-struct roots {
- ptr_t r_start;
- ptr_t r_end;
-# ifndef MSWIN32
- struct roots * r_next;
-# endif
- GC_bool r_tmp;
- /* Delete before registering new dynamic libraries */
-};
-
-#ifndef MSWIN32
- /* Size of hash table index to roots. */
-# define LOG_RT_SIZE 6
-# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */
-#endif
-
-/* Lists of all heap blocks and free lists */
-/* as well as other random data structures */
-/* that should not be scanned by the */
-/* collector. */
-/* These are grouped together in a struct */
-/* so that they can be easily skipped by the */
-/* GC_mark routine. */
-/* The ordering is weird to make GC_malloc */
-/* faster by keeping the important fields */
-/* sufficiently close together that a */
-/* single load of a base register will do. */
-/* Scalars that could easily appear to */
-/* be pointers are also put here. */
-/* The main fields should precede any */
-/* conditionally included fields, so that */
-/* gc_inl.h will work even if a different set */
-/* of macros is defined when the client is */
-/* compiled. */
-
-struct _GC_arrays {
- word _heapsize;
- word _max_heapsize;
- word _requested_heapsize; /* Heap size due to explicit expansion */
- ptr_t _last_heap_addr;
- ptr_t _prev_heap_addr;
- word _large_free_bytes;
- /* Total bytes contained in blocks on large object free */
- /* list. */
- word _words_allocd_before_gc;
- /* Number of words allocated before this */
- /* collection cycle. */
- word _words_allocd;
- /* Number of words allocated during this collection cycle */
- word _words_wasted;
- /* Number of words wasted due to internal fragmentation */
- /* in large objects, or due to dropping blacklisted */
- /* blocks, since last gc. Approximate. */
- word _words_finalized;
- /* Approximate number of words in objects (and headers) */
- /* That became ready for finalization in the last */
- /* collection. */
- word _non_gc_bytes_at_gc;
- /* Number of explicitly managed bytes of storage */
- /* at last collection. */
- word _mem_freed;
- /* Number of explicitly deallocated words of memory */
- /* since last collection. */
- ptr_t _scratch_end_ptr;
- ptr_t _scratch_last_end_ptr;
- /* Used by headers.c, and can easily appear to point to */
- /* heap. */
- mark_proc _mark_procs[MAX_MARK_PROCS];
- /* Table of user-defined mark procedures. There is */
- /* a small number of these, which can be referenced */
- /* by DS_PROC mark descriptors. See gc_mark.h. */
- ptr_t _objfreelist[MAXOBJSZ+1];
- /* free list for objects */
- ptr_t _aobjfreelist[MAXOBJSZ+1];
- /* free list for atomic objs */
-
- ptr_t _uobjfreelist[MAXOBJSZ+1];
- /* uncollectable but traced objs */
- /* objects on this and auobjfreelist */
- /* are always marked, except during */
- /* garbage collections. */
-# ifdef ATOMIC_UNCOLLECTABLE
- ptr_t _auobjfreelist[MAXOBJSZ+1];
-# endif
- /* uncollectable but traced objs */
-
-# ifdef GATHERSTATS
- word _composite_in_use;
- /* Number of words in accessible composite */
- /* objects. */
- word _atomic_in_use;
- /* Number of words in accessible atomic */
- /* objects. */
-# endif
-# ifdef USE_MUNMAP
- word _unmapped_bytes;
-# endif
-# ifdef MERGE_SIZES
- unsigned _size_map[WORDS_TO_BYTES(MAXOBJSZ+1)];
- /* Number of words to allocate for a given allocation request in */
- /* bytes. */
-# endif
-
-# ifdef STUBBORN_ALLOC
- ptr_t _sobjfreelist[MAXOBJSZ+1];
-# endif
- /* free list for immutable objects */
- ptr_t _obj_map[MAXOBJSZ+1];
- /* If not NIL, then a pointer to a map of valid */
- /* object addresses. _obj_map[sz][i] is j if the */
- /* address block_start+i is a valid pointer */
- /* to an object at */
- /* block_start+i&~3 - WORDS_TO_BYTES(j). */
- /* (If ALL_INTERIOR_POINTERS is defined, then */
- /* instead ((short *)(hb_map[sz])[i] is j if */
- /* block_start+WORDS_TO_BYTES(i) is in the */
- /* interior of an object starting at */
- /* block_start+WORDS_TO_BYTES(i-j)). */
- /* It is OBJ_INVALID if */
- /* block_start+WORDS_TO_BYTES(i) is not */
- /* valid as a pointer to an object. */
- /* We assume all values of j <= OBJ_INVALID. */
- /* The zeroth entry corresponds to large objects.*/
-# ifdef ALL_INTERIOR_POINTERS
-# define map_entry_type short
-# define OBJ_INVALID 0x7fff
-# define MAP_ENTRY(map, bytes) \
- (((map_entry_type *)(map))[BYTES_TO_WORDS(bytes)])
-# define MAP_ENTRIES BYTES_TO_WORDS(HBLKSIZE)
-# define MAP_SIZE (MAP_ENTRIES * sizeof(map_entry_type))
-# define OFFSET_VALID(displ) TRUE
-# define CPP_MAX_OFFSET (HBLKSIZE - HDR_BYTES - 1)
-# define MAX_OFFSET ((word)CPP_MAX_OFFSET)
-# else
-# define map_entry_type char
-# define OBJ_INVALID 0x7f
-# define MAP_ENTRY(map, bytes) \
- (map)[bytes]
-# define MAP_ENTRIES HBLKSIZE
-# define MAP_SIZE MAP_ENTRIES
-# define CPP_MAX_OFFSET (WORDS_TO_BYTES(OBJ_INVALID) - 1)
-# define MAX_OFFSET ((word)CPP_MAX_OFFSET)
-# define VALID_OFFSET_SZ \
- (CPP_MAX_OFFSET > WORDS_TO_BYTES(CPP_MAXOBJSZ)? \
- CPP_MAX_OFFSET+1 \
- : WORDS_TO_BYTES(CPP_MAXOBJSZ)+1)
- char _valid_offsets[VALID_OFFSET_SZ];
- /* GC_valid_offsets[i] == TRUE ==> i */
- /* is registered as a displacement. */
-# define OFFSET_VALID(displ) GC_valid_offsets[displ]
- char _modws_valid_offsets[sizeof(word)];
- /* GC_valid_offsets[i] ==> */
- /* GC_modws_valid_offsets[i%sizeof(word)] */
-# endif
-# ifdef STUBBORN_ALLOC
- page_hash_table _changed_pages;
- /* Stubborn object pages that were changes since last call to */
- /* GC_read_changed. */
- page_hash_table _prev_changed_pages;
- /* Stubborn object pages that were changes before last call to */
- /* GC_read_changed. */
-# endif
-# if defined(PROC_VDB) || defined(MPROTECT_VDB)
- page_hash_table _grungy_pages; /* Pages that were dirty at last */
- /* GC_read_dirty. */
-# endif
-# ifdef MPROTECT_VDB
- VOLATILE page_hash_table _dirty_pages;
- /* Pages dirtied since last GC_read_dirty. */
-# endif
-# ifdef PROC_VDB
- page_hash_table _written_pages; /* Pages ever dirtied */
-# endif
-# ifdef LARGE_CONFIG
-# if CPP_WORDSZ > 32
-# define MAX_HEAP_SECTS 4096 /* overflows at roughly 64 GB */
-# else
-# define MAX_HEAP_SECTS 768 /* Separately added heap sections. */
-# endif
-# else
-# define MAX_HEAP_SECTS 256
-# endif
- struct HeapSect {
- ptr_t hs_start; word hs_bytes;
- } _heap_sects[MAX_HEAP_SECTS];
-# ifdef MSWIN32
- ptr_t _heap_bases[MAX_HEAP_SECTS];
- /* Start address of memory regions obtained from kernel. */
-# endif
- struct roots _static_roots[MAX_ROOT_SETS];
-# ifndef MSWIN32
- struct roots * _root_index[RT_SIZE];
-# endif
- struct exclusion _excl_table[MAX_EXCLUSIONS];
- /* Block header index; see gc_headers.h */
- bottom_index * _all_nils;
- bottom_index * _top_index [TOP_SZ];
-#ifdef SAVE_CALL_CHAIN
- struct callinfo _last_stack[NFRAMES]; /* Stack at last garbage collection.*/
- /* Useful for debugging mysterious */
- /* object disappearances. */
- /* In the multithreaded case, we */
- /* currently only save the calling */
- /* stack. */
-#endif
-};
-
-GC_API GC_FAR struct _GC_arrays GC_arrays;
-
-# define GC_objfreelist GC_arrays._objfreelist
-# define GC_aobjfreelist GC_arrays._aobjfreelist
-# define GC_uobjfreelist GC_arrays._uobjfreelist
-# ifdef ATOMIC_UNCOLLECTABLE
-# define GC_auobjfreelist GC_arrays._auobjfreelist
-# endif
-# define GC_sobjfreelist GC_arrays._sobjfreelist
-# define GC_valid_offsets GC_arrays._valid_offsets
-# define GC_modws_valid_offsets GC_arrays._modws_valid_offsets
-# ifdef STUBBORN_ALLOC
-# define GC_changed_pages GC_arrays._changed_pages
-# define GC_prev_changed_pages GC_arrays._prev_changed_pages
-# endif
-# define GC_obj_map GC_arrays._obj_map
-# define GC_last_heap_addr GC_arrays._last_heap_addr
-# define GC_prev_heap_addr GC_arrays._prev_heap_addr
-# define GC_words_allocd GC_arrays._words_allocd
-# define GC_words_wasted GC_arrays._words_wasted
-# define GC_large_free_bytes GC_arrays._large_free_bytes
-# define GC_words_finalized GC_arrays._words_finalized
-# define GC_non_gc_bytes_at_gc GC_arrays._non_gc_bytes_at_gc
-# define GC_mem_freed GC_arrays._mem_freed
-# define GC_scratch_end_ptr GC_arrays._scratch_end_ptr
-# define GC_scratch_last_end_ptr GC_arrays._scratch_last_end_ptr
-# define GC_mark_procs GC_arrays._mark_procs
-# define GC_heapsize GC_arrays._heapsize
-# define GC_max_heapsize GC_arrays._max_heapsize
-# define GC_requested_heapsize GC_arrays._requested_heapsize
-# define GC_words_allocd_before_gc GC_arrays._words_allocd_before_gc
-# define GC_heap_sects GC_arrays._heap_sects
-# define GC_last_stack GC_arrays._last_stack
-# ifdef USE_MUNMAP
-# define GC_unmapped_bytes GC_arrays._unmapped_bytes
-# endif
-# ifdef MSWIN32
-# define GC_heap_bases GC_arrays._heap_bases
-# endif
-# define GC_static_roots GC_arrays._static_roots
-# define GC_root_index GC_arrays._root_index
-# define GC_excl_table GC_arrays._excl_table
-# define GC_all_nils GC_arrays._all_nils
-# define GC_top_index GC_arrays._top_index
-# if defined(PROC_VDB) || defined(MPROTECT_VDB)
-# define GC_grungy_pages GC_arrays._grungy_pages
-# endif
-# ifdef MPROTECT_VDB
-# define GC_dirty_pages GC_arrays._dirty_pages
-# endif
-# ifdef PROC_VDB
-# define GC_written_pages GC_arrays._written_pages
-# endif
-# ifdef GATHERSTATS
-# define GC_composite_in_use GC_arrays._composite_in_use
-# define GC_atomic_in_use GC_arrays._atomic_in_use
-# endif
-# ifdef MERGE_SIZES
-# define GC_size_map GC_arrays._size_map
-# endif
-
-# define beginGC_arrays ((ptr_t)(&GC_arrays))
-# define endGC_arrays (((ptr_t)(&GC_arrays)) + (sizeof GC_arrays))
-
-#define USED_HEAP_SIZE (GC_heapsize - GC_large_free_bytes)
-
-/* Object kinds: */
-# define MAXOBJKINDS 16
-
-extern struct obj_kind {
- ptr_t *ok_freelist; /* Array of free listheaders for this kind of object */
- /* Point either to GC_arrays or to storage allocated */
- /* with GC_scratch_alloc. */
- struct hblk **ok_reclaim_list;
- /* List headers for lists of blocks waiting to be */
- /* swept. */
- word ok_descriptor; /* Descriptor template for objects in this */
- /* block. */
- GC_bool ok_relocate_descr;
- /* Add object size in bytes to descriptor */
- /* template to obtain descriptor. Otherwise */
- /* template is used as is. */
- GC_bool ok_init; /* Clear objects before putting them on the free list. */
-} GC_obj_kinds[MAXOBJKINDS];
-
-# define endGC_obj_kinds (((ptr_t)(&GC_obj_kinds)) + (sizeof GC_obj_kinds))
-
-# define end_gc_area ((ptr_t)endGC_arrays == (ptr_t)(&GC_obj_kinds) ? \
- endGC_obj_kinds : endGC_arrays)
-
-/* Predefined kinds: */
-# define PTRFREE 0
-# define NORMAL 1
-# define UNCOLLECTABLE 2
-# ifdef ATOMIC_UNCOLLECTABLE
-# define AUNCOLLECTABLE 3
-# define STUBBORN 4
-# define IS_UNCOLLECTABLE(k) (((k) & ~1) == UNCOLLECTABLE)
-# else
-# define STUBBORN 3
-# define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE)
-# endif
-
-extern int GC_n_kinds;
-
-GC_API word GC_fo_entries;
-
-extern word GC_n_heap_sects; /* Number of separately added heap */
- /* sections. */
-
-extern word GC_page_size;
-
-# ifdef MSWIN32
-extern word GC_n_heap_bases; /* See GC_heap_bases. */
-# endif
-
-extern word GC_total_stack_black_listed;
- /* Number of bytes on stack blacklist. */
-
-extern word GC_black_list_spacing;
- /* Average number of bytes between blacklisted */
- /* blocks. Approximate. */
- /* Counts only blocks that are */
- /* "stack-blacklisted", i.e. that are */
- /* problematic in the interior of an object. */
-
-extern char * GC_invalid_map;
- /* Pointer to the nowhere valid hblk map */
- /* Blocks pointing to this map are free. */
-
-extern struct hblk * GC_hblkfreelist[];
- /* List of completely empty heap blocks */
- /* Linked through hb_next field of */
- /* header structure associated with */
- /* block. */
-
-extern GC_bool GC_is_initialized; /* GC_init() has been run. */
-
-extern GC_bool GC_objects_are_marked; /* There are marked objects in */
- /* the heap. */
-
-#ifndef SMALL_CONFIG
- extern GC_bool GC_incremental;
- /* Using incremental/generational collection. */
-#else
-# define GC_incremental FALSE
- /* Hopefully allow optimizer to remove some code. */
-#endif
-
-extern GC_bool GC_dirty_maintained;
- /* Dirty bits are being maintained, */
- /* either for incremental collection, */
- /* or to limit the root set. */
-
-extern word GC_root_size; /* Total size of registered root sections */
-
-extern GC_bool GC_debugging_started; /* GC_debug_malloc has been called. */
-
-extern ptr_t GC_least_plausible_heap_addr;
-extern ptr_t GC_greatest_plausible_heap_addr;
- /* Bounds on the heap. Guaranteed valid */
- /* Likely to include future heap expansion. */
-
-/* Operations */
-# ifndef abs
-# define abs(x) ((x) < 0? (-(x)) : (x))
-# endif
-
-
-/* Marks are in a reserved area in */
-/* each heap block. Each word has one mark bit associated */
-/* with it. Only those corresponding to the beginning of an */
-/* object are used. */
-
-
-/* Mark bit operations */
-
-/*
- * Retrieve, set, clear the mark bit corresponding
- * to the nth word in a given heap block.
- *
- * (Recall that bit n corresponds to object beginning at word n
- * relative to the beginning of the block, including unused words)
- */
-
-# define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \
- >> (modWORDSZ(n))) & (word)1)
-# define set_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \
- |= (word)1 << modWORDSZ(n)
-
-# define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \
- &= ~((word)1 << modWORDSZ(n))
-
-/* Important internal collector routines */
-
-ptr_t GC_approx_sp();
-
-GC_bool GC_should_collect();
-
-void GC_apply_to_all_blocks(/*fn, client_data*/);
- /* Invoke fn(hbp, client_data) for each */
- /* allocated heap block. */
-struct hblk * GC_next_used_block(/* struct hblk * h */);
- /* Return first in-use block >= h */
-struct hblk * GC_prev_block(/* struct hblk * h */);
- /* Return last block <= h. Returned block */
- /* is managed by GC, but may or may not be in */
- /* use. */
-void GC_mark_init();
-void GC_clear_marks(); /* Clear mark bits for all heap objects. */
-void GC_invalidate_mark_state(); /* Tell the marker that marked */
- /* objects may point to unmarked */
- /* ones, and roots may point to */
- /* unmarked objects. */
- /* Reset mark stack. */
-void GC_mark_from_mark_stack(); /* Mark from everything on the mark stack. */
- /* Return after about one pages worth of */
- /* work. */
-GC_bool GC_mark_stack_empty();
-GC_bool GC_mark_some(/* cold_gc_frame */);
- /* Perform about one pages worth of marking */
- /* work of whatever kind is needed. Returns */
- /* quickly if no collection is in progress. */
- /* Return TRUE if mark phase finished. */
-void GC_initiate_gc(); /* initiate collection. */
- /* If the mark state is invalid, this */
- /* becomes full colleection. Otherwise */
- /* it's partial. */
-void GC_push_all(/*b,t*/); /* Push everything in a range */
- /* onto mark stack. */
-void GC_push_dirty(/*b,t*/); /* Push all possibly changed */
- /* subintervals of [b,t) onto */
- /* mark stack. */
-#ifndef SMALL_CONFIG
- void GC_push_conditional(/* ptr_t b, ptr_t t, GC_bool all*/);
-#else
-# define GC_push_conditional(b, t, all) GC_push_all(b, t)
-#endif
- /* Do either of the above, depending */
- /* on the third arg. */
-void GC_push_all_stack(/*b,t*/); /* As above, but consider */
- /* interior pointers as valid */
-void GC_push_all_eager(/*b,t*/); /* Same as GC_push_all_stack, but */
- /* ensures that stack is scanned */
- /* immediately, not just scheduled */
- /* for scanning. */
-#ifndef THREADS
- void GC_push_all_stack_partially_eager(/* bottom, top, cold_gc_frame */);
- /* Similar to GC_push_all_eager, but only the */
- /* part hotter than cold_gc_frame is scanned */
- /* immediately. Needed to endure that callee- */
- /* save registers are not missed. */
-#else
- /* In the threads case, we push part of the current thread stack */
- /* with GC_push_all_eager when we push the registers. This gets the */
- /* callee-save registers that may disappear. The remainder of the */
- /* stacks are scheduled for scanning in *GC_push_other_roots, which */
- /* is thread-package-specific. */
-#endif
-void GC_push_current_stack(/* ptr_t cold_gc_frame */);
- /* Push enough of the current stack eagerly to */
- /* ensure that callee-save registers saved in */
- /* GC frames are scanned. */
- /* In the non-threads case, schedule entire */
- /* stack for scanning. */
-void GC_push_roots(/* GC_bool all, ptr_t cold_gc_frame */);
- /* Push all or dirty roots. */
-extern void (*GC_push_other_roots)();
- /* Push system or application specific roots */
- /* onto the mark stack. In some environments */
- /* (e.g. threads environments) this is */
- /* predfined to be non-zero. A client supplied */
- /* replacement should also call the original */
- /* function. */
-extern void (*GC_start_call_back)(/* void */);
- /* Called at start of full collections. */
- /* Not called if 0. Called with allocation */
- /* lock held. */
- /* 0 by default. */
-void GC_push_regs(); /* Push register contents onto mark stack. */
- /* If NURSERY is defined, the default push */
- /* action can be overridden with GC_push_proc */
-void GC_remark(); /* Mark from all marked objects. Used */
- /* only if we had to drop something. */
-
-# ifdef NURSERY
- extern void (*GC_push_proc)(ptr_t);
-# endif
-# if defined(MSWIN32)
- void __cdecl GC_push_one();
-# else
- void GC_push_one(/*p*/); /* If p points to an object, mark it */
- /* and push contents on the mark stack */
-# endif
-void GC_push_one_checked(/*p*/); /* Ditto, omits plausibility test */
-void GC_push_marked(/* struct hblk h, hdr * hhdr */);
- /* Push contents of all marked objects in h onto */
- /* mark stack. */
-#ifdef SMALL_CONFIG
-# define GC_push_next_marked_dirty(h) GC_push_next_marked(h)
-#else
- struct hblk * GC_push_next_marked_dirty(/* h */);
- /* Invoke GC_push_marked on next dirty block above h. */
- /* Return a pointer just past the end of this block. */
-#endif /* !SMALL_CONFIG */
-struct hblk * GC_push_next_marked(/* h */);
- /* Ditto, but also mark from clean pages. */
-struct hblk * GC_push_next_marked_uncollectable(/* h */);
- /* Ditto, but mark only from uncollectable pages. */
-GC_bool GC_stopped_mark(); /* Stop world and mark from all roots */
- /* and rescuers. */
-void GC_clear_hdr_marks(/* hhdr */); /* Clear the mark bits in a header */
-void GC_set_hdr_marks(/* hhdr */); /* Set the mark bits in a header */
-void GC_add_roots_inner();
-GC_bool GC_is_static_root(/* ptr_t p */);
- /* Is the address p in one of the registered static */
- /* root sections? */
-void GC_register_dynamic_libraries();
- /* Add dynamic library data sections to the root set. */
-
-/* Machine dependent startup routines */
-ptr_t GC_get_stack_base();
-void GC_register_data_segments();
-
-/* Black listing: */
-void GC_bl_init();
-# ifndef ALL_INTERIOR_POINTERS
- void GC_add_to_black_list_normal(/* bits, maybe source */);
- /* Register bits as a possible future false */
- /* reference from the heap or static data */
-# ifdef PRINT_BLACK_LIST
-# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_normal(bits, source)
-# else
-# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_normal(bits)
-# endif
-# else
-# ifdef PRINT_BLACK_LIST
-# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_stack(bits, source)
-# else
-# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_stack(bits)
-# endif
-# endif
-
-void GC_add_to_black_list_stack(/* bits, maybe source */);
-struct hblk * GC_is_black_listed(/* h, len */);
- /* If there are likely to be false references */
- /* to a block starting at h of the indicated */
- /* length, then return the next plausible */
- /* starting location for h that might avoid */
- /* these false references. */
-void GC_promote_black_lists();
- /* Declare an end to a black listing phase. */
-void GC_unpromote_black_lists();
- /* Approximately undo the effect of the above. */
- /* This actually loses some information, but */
- /* only in a reasonably safe way. */
-word GC_number_stack_black_listed(/*struct hblk *start, struct hblk *endp1 */);
- /* Return the number of (stack) blacklisted */
- /* blocks in the range for statistical */
- /* purposes. */
-
-ptr_t GC_scratch_alloc(/*bytes*/);
- /* GC internal memory allocation for */
- /* small objects. Deallocation is not */
- /* possible. */
-
-/* Heap block layout maps: */
-void GC_invalidate_map(/* hdr */);
- /* Remove the object map associated */
- /* with the block. This identifies */
- /* the block as invalid to the mark */
- /* routines. */
-GC_bool GC_add_map_entry(/*sz*/);
- /* Add a heap block map for objects of */
- /* size sz to obj_map. */
- /* Return FALSE on failure. */
-void GC_register_displacement_inner(/*offset*/);
- /* Version of GC_register_displacement */
- /* that assumes lock is already held */
- /* and signals are already disabled. */
-
-/* hblk allocation: */
-void GC_new_hblk(/*size_in_words, kind*/);
- /* Allocate a new heap block, and build */
- /* a free list in it. */
-struct hblk * GC_allochblk(/*size_in_words, kind*/);
- /* Allocate a heap block, clear it if */
- /* for composite objects, inform */
- /* the marker that block is valid */
- /* for objects of indicated size. */
- /* sz < 0 ==> atomic. */
-void GC_freehblk(); /* Deallocate a heap block and mark it */
- /* as invalid. */
-
-/* Misc GC: */
-void GC_init_inner();
-GC_bool GC_expand_hp_inner();
-void GC_start_reclaim(/*abort_if_found*/);
- /* Restore unmarked objects to free */
- /* lists, or (if abort_if_found is */
- /* TRUE) report them. */
- /* Sweeping of small object pages is */
- /* largely deferred. */
-void GC_continue_reclaim(/*size, kind*/);
- /* Sweep pages of the given size and */
- /* kind, as long as possible, and */
- /* as long as the corr. free list is */
- /* empty. */
-void GC_reclaim_or_delete_all();
- /* Arrange for all reclaim lists to be */
- /* empty. Judiciously choose between */
- /* sweeping and discarding each page. */
-GC_bool GC_reclaim_all(/* GC_stop_func f*/);
- /* Reclaim all blocks. Abort (in a */
- /* consistent state) if f returns TRUE. */
-GC_bool GC_block_empty(/* hhdr */); /* Block completely unmarked? */
-GC_bool GC_never_stop_func(); /* Returns FALSE. */
-GC_bool GC_try_to_collect_inner(/* GC_stop_func f */);
- /* Collect; caller must have acquired */
- /* lock and disabled signals. */
- /* Collection is aborted if f returns */
- /* TRUE. Returns TRUE if it completes */
- /* successfully. */
-# define GC_gcollect_inner() \
- (void) GC_try_to_collect_inner(GC_never_stop_func)
-void GC_finish_collection(); /* Finish collection. Mark bits are */
- /* consistent and lock is still held. */
-GC_bool GC_collect_or_expand(/* needed_blocks */);
- /* Collect or expand heap in an attempt */
- /* make the indicated number of free */
- /* blocks available. Should be called */
- /* until the blocks are available or */
- /* until it fails by returning FALSE. */
-GC_API void GC_init(); /* Initialize collector. */
-void GC_collect_a_little_inner(/* int n */);
- /* Do n units worth of garbage */
- /* collection work, if appropriate. */
- /* A unit is an amount appropriate for */
- /* HBLKSIZE bytes of allocation. */
-ptr_t GC_generic_malloc(/* bytes, kind */);
- /* Allocate an object of the given */
- /* kind. By default, there are only */
- /* a few kinds: composite(pointerfree), */
- /* atomic, uncollectable, etc. */
- /* We claim it's possible for clever */
- /* client code that understands GC */
- /* internals to add more, e.g. to */
- /* communicate object layout info */
- /* to the collector. */
-ptr_t GC_generic_malloc_ignore_off_page(/* bytes, kind */);
- /* As above, but pointers past the */
- /* first page of the resulting object */
- /* are ignored. */
-ptr_t GC_generic_malloc_inner(/* bytes, kind */);
- /* Ditto, but I already hold lock, etc. */
-ptr_t GC_generic_malloc_words_small GC_PROTO((size_t words, int kind));
- /* As above, but size in units of words */
- /* Bypasses MERGE_SIZES. Assumes */
- /* words <= MAXOBJSZ. */
-ptr_t GC_generic_malloc_inner_ignore_off_page(/* bytes, kind */);
- /* Allocate an object, where */
- /* the client guarantees that there */
- /* will always be a pointer to the */
- /* beginning of the object while the */
- /* object is live. */
-ptr_t GC_allocobj(/* sz_inn_words, kind */);
- /* Make the indicated */
- /* free list nonempty, and return its */
- /* head. */
-
-void GC_init_headers();
-struct hblkhdr * GC_install_header(/*h*/);
- /* Install a header for block h. */
- /* Return 0 on failure, or the header */
- /* otherwise. */
-GC_bool GC_install_counts(/*h, sz*/);
- /* Set up forwarding counts for block */
- /* h of size sz. */
- /* Return FALSE on failure. */
-void GC_remove_header(/*h*/);
- /* Remove the header for block h. */
-void GC_remove_counts(/*h, sz*/);
- /* Remove forwarding counts for h. */
-hdr * GC_find_header(/*p*/); /* Debugging only. */
-
-void GC_finalize(); /* Perform all indicated finalization actions */
- /* on unmarked objects. */
- /* Unreachable finalizable objects are enqueued */
- /* for processing by GC_invoke_finalizers. */
- /* Invoked with lock. */
-
-void GC_add_to_heap(/*p, bytes*/);
- /* Add a HBLKSIZE aligned chunk to the heap. */
-
-void GC_print_obj(/* ptr_t p */);
- /* P points to somewhere inside an object with */
- /* debugging info. Print a human readable */
- /* description of the object to stderr. */
-extern void (*GC_check_heap)();
- /* Check that all objects in the heap with */
- /* debugging info are intact. Print */
- /* descriptions of any that are not. */
-extern void (*GC_print_heap_obj)(/* ptr_t p */);
- /* If possible print s followed by a more */
- /* detailed description of the object */
- /* referred to by p. */
-
-/* Memory unmapping: */
-#ifdef USE_MUNMAP
- void GC_unmap_old(void);
- void GC_merge_unmapped(void);
- void GC_unmap(ptr_t start, word bytes);
- void GC_remap(ptr_t start, word bytes);
- void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2);
-#endif
-
-/* Virtual dirty bit implementation: */
-/* Each implementation exports the following: */
-void GC_read_dirty(); /* Retrieve dirty bits. */
-GC_bool GC_page_was_dirty(/* struct hblk * h */);
- /* Read retrieved dirty bits. */
-GC_bool GC_page_was_ever_dirty(/* struct hblk * h */);
- /* Could the page contain valid heap pointers? */
-void GC_is_fresh(/* struct hblk * h, word number_of_blocks */);
- /* Assert the region currently contains no */
- /* valid pointers. */
-void GC_write_hint(/* struct hblk * h */);
- /* h is about to be written. */
-void GC_dirty_init();
-
-/* Slow/general mark bit manipulation: */
-GC_API GC_bool GC_is_marked();
-void GC_clear_mark_bit();
-void GC_set_mark_bit();
-
-/* Stubborn objects: */
-void GC_read_changed(); /* Analogous to GC_read_dirty */
-GC_bool GC_page_was_changed(/* h */); /* Analogous to GC_page_was_dirty */
-void GC_clean_changing_list(); /* Collect obsolete changing list entries */
-void GC_stubborn_init();
-
-/* Debugging print routines: */
-void GC_print_block_list();
-void GC_print_hblkfreelist();
-void GC_print_heap_sects();
-void GC_print_static_roots();
-void GC_dump();
-
-#ifdef KEEP_BACK_PTRS
- void GC_store_back_pointer(ptr_t source, ptr_t dest);
- void GC_marked_for_finalization(ptr_t dest);
-# define GC_STORE_BACK_PTR(source, dest) GC_store_back_pointer(source, dest)
-# define GC_MARKED_FOR_FINALIZATION(dest) GC_marked_for_finalization(dest)
-#else
-# define GC_STORE_BACK_PTR(source, dest)
-# define GC_MARKED_FOR_FINALIZATION(dest)
-#endif
-
-/* Make arguments appear live to compiler */
-# ifdef __WATCOMC__
- void GC_noop(void*, ...);
-# else
- GC_API void GC_noop();
-# endif
-
-void GC_noop1(/* word arg */);
-
-/* Logging and diagnostic output: */
-GC_API void GC_printf GC_PROTO((char * format, long, long, long, long, long, long));
- /* A version of printf that doesn't allocate, */
- /* is restricted to long arguments, and */
- /* (unfortunately) doesn't use varargs for */
- /* portability. Restricted to 6 args and */
- /* 1K total output length. */
- /* (We use sprintf. Hopefully that doesn't */
- /* allocate for long arguments.) */
-# define GC_printf0(f) GC_printf(f, 0l, 0l, 0l, 0l, 0l, 0l)
-# define GC_printf1(f,a) GC_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)
-# define GC_printf2(f,a,b) GC_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)
-# define GC_printf3(f,a,b,c) GC_printf(f, (long)a, (long)b, (long)c, 0l, 0l, 0l)
-# define GC_printf4(f,a,b,c,d) GC_printf(f, (long)a, (long)b, (long)c, \
- (long)d, 0l, 0l)
-# define GC_printf5(f,a,b,c,d,e) GC_printf(f, (long)a, (long)b, (long)c, \
- (long)d, (long)e, 0l)
-# define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \
- (long)d, (long)e, (long)g)
-
-void GC_err_printf(/* format, a, b, c, d, e, f */);
-# define GC_err_printf0(f) GC_err_puts(f)
-# define GC_err_printf1(f,a) GC_err_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)
-# define GC_err_printf2(f,a,b) GC_err_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)
-# define GC_err_printf3(f,a,b,c) GC_err_printf(f, (long)a, (long)b, (long)c, \
- 0l, 0l, 0l)
-# define GC_err_printf4(f,a,b,c,d) GC_err_printf(f, (long)a, (long)b, \
- (long)c, (long)d, 0l, 0l)
-# define GC_err_printf5(f,a,b,c,d,e) GC_err_printf(f, (long)a, (long)b, \
- (long)c, (long)d, \
- (long)e, 0l)
-# define GC_err_printf6(f,a,b,c,d,e,g) GC_err_printf(f, (long)a, (long)b, \
- (long)c, (long)d, \
- (long)e, (long)g)
- /* Ditto, writes to stderr. */
-
-void GC_err_puts(/* char *s */);
- /* Write s to stderr, don't buffer, don't add */
- /* newlines, don't ... */
-
-
-# ifdef GC_ASSERTIONS
-# define GC_ASSERT(expr) if(!(expr)) {\
- GC_err_printf2("Assertion failure: %s:%ld\n", \
- __FILE__, (unsigned long)__LINE__); \
- ABORT("assertion failure"); }
-# else
-# define GC_ASSERT(expr)
-# endif
-
-# endif /* GC_PRIVATE_H */
diff --git a/gc_private.h b/gc_private.h
deleted file mode 100644
index 3dd7c855..00000000
--- a/gc_private.h
+++ /dev/null
@@ -1 +0,0 @@
-# include "gc_priv.h"
diff --git a/gc_typed.h b/gc_typed.h
deleted file mode 100644
index 2e0598f2..00000000
--- a/gc_typed.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
- * Copyright 1996 Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/*
- * Some simple primitives for allocation with explicit type information.
- * Facilities for dynamic type inference may be added later.
- * Should be used only for extremely performance critical applications,
- * or if conservative collector leakage is otherwise a problem (unlikely).
- * Note that this is implemented completely separately from the rest
- * of the collector, and is not linked in unless referenced.
- * This does not currently support GC_DEBUG in any interesting way.
- */
-/* Boehm, May 19, 1994 2:13 pm PDT */
-
-#ifndef _GC_TYPED_H
-# define _GC_TYPED_H
-# ifndef _GC_H
-# include "gc.h"
-# endif
-
-typedef GC_word * GC_bitmap;
- /* The least significant bit of the first word is one if */
- /* the first word in the object may be a pointer. */
-
-# define GC_get_bit(bm, index) \
- (((bm)[divWORDSZ(index)] >> modWORDSZ(index)) & 1)
-# define GC_set_bit(bm, index) \
- (bm)[divWORDSZ(index)] |= (word)1 << modWORDSZ(index)
-
-typedef GC_word GC_descr;
-
-GC_API GC_descr GC_make_descriptor GC_PROTO((GC_bitmap bm, size_t len));
- /* Return a type descriptor for the object whose layout */
- /* is described by the argument. */
- /* The least significant bit of the first word is one */
- /* if the first word in the object may be a pointer. */
- /* The second argument specifies the number of */
- /* meaningful bits in the bitmap. The actual object */
- /* may be larger (but not smaller). Any additional */
- /* words in the object are assumed not to contain */
- /* pointers. */
- /* Returns a conservative approximation in the */
- /* (unlikely) case of insufficient memory to build */
- /* the descriptor. Calls to GC_make_descriptor */
- /* may consume some amount of a finite resource. This */
- /* is intended to be called once per type, not once */
- /* per allocation. */
-
-GC_API GC_PTR GC_malloc_explicitly_typed
- GC_PROTO((size_t size_in_bytes, GC_descr d));
- /* Allocate an object whose layout is described by d. */
- /* The resulting object MAY NOT BE PASSED TO REALLOC. */
- /* The returned object is cleared. */
-
-GC_API GC_PTR GC_malloc_explicitly_typed_ignore_off_page
- GC_PROTO((size_t size_in_bytes, GC_descr d));
-
-GC_API GC_PTR GC_calloc_explicitly_typed
- GC_PROTO((size_t nelements,
- size_t element_size_in_bytes,
- GC_descr d));
- /* Allocate an array of nelements elements, each of the */
- /* given size, and with the given descriptor. */
- /* The elemnt size must be a multiple of the byte */
- /* alignment required for pointers. E.g. on a 32-bit */
- /* machine with 16-bit aligned pointers, size_in_bytes */
- /* must be a multiple of 2. */
- /* Returned object is cleared. */
-
-#ifdef GC_DEBUG
-# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) GC_MALLOC(bytes)
-# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) GC_MALLOC(n*bytes)
-#else
-# define GC_MALLOC_EXPLICTLY_TYPED(bytes, d) \
- GC_malloc_explicitly_typed(bytes, d)
-# define GC_CALLOC_EXPLICTLY_TYPED(n, bytes, d) \
- GC_calloc_explicitly_typed(n, bytes, d)
-#endif /* !GC_DEBUG */
-
-
-#endif /* _GC_TYPED_H */
-
diff --git a/gcconfig.h b/gcconfig.h
deleted file mode 100644
index 221983ca..00000000
--- a/gcconfig.h
+++ /dev/null
@@ -1,1327 +0,0 @@
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
- * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#ifndef GCCONFIG_H
-
-# define GCCONFIG_H
-
-/* Machine dependent parameters. Some tuning parameters can be found */
-/* near the top of gc_private.h. */
-
-/* Machine specific parts contributed by various people. See README file. */
-
-/* First a unified test for Linux: */
-# if defined(linux) || defined(__linux__)
-# define LINUX
-# endif
-
-/* Determine the machine type: */
-# if defined(sun) && defined(mc68000)
-# define M68K
-# define SUNOS4
-# define mach_type_known
-# endif
-# if defined(hp9000s300)
-# define M68K
-# define HP
-# define mach_type_known
-# endif
-# if defined(__OpenBSD__) && defined(m68k)
-# define M68K
-# define OPENBSD
-# define mach_type_known
-# endif
-# if defined(__OpenBSD__) && defined(__sparc__)
-# define SPARC
-# define OPENBSD
-# define mach_type_known
-# endif
-# if defined(__NetBSD__) && defined(m68k)
-# define M68K
-# define NETBSD
-# define mach_type_known
-# endif
-# if defined(__NetBSD__) && defined(arm32)
-# define ARM32
-# define NETBSD
-# define mach_type_known
-# endif
-# if defined(vax)
-# define VAX
-# ifdef ultrix
-# define ULTRIX
-# else
-# define BSD
-# endif
-# define mach_type_known
-# endif
-# if defined(mips) || defined(__mips)
-# define MIPS
-# if !defined(LINUX)
-# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
-# define ULTRIX
-# else
-# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
- || defined(__SYSTYPE_SVR4__)
-# define IRIX5 /* or IRIX 6.X */
-# else
-# define RISCOS /* or IRIX 4.X */
-# endif
-# endif
-# endif /* !LINUX */
-# define mach_type_known
-# endif
-# if defined(sequent) && defined(i386)
-# define I386
-# define SEQUENT
-# define mach_type_known
-# endif
-# if defined(sun) && defined(i386)
-# define I386
-# define SUNOS5
-# define mach_type_known
-# endif
-# if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
-# define I386
-# define OS2
-# define mach_type_known
-# endif
-# if defined(ibm032)
-# define RT
-# define mach_type_known
-# endif
-# if defined(sun) && (defined(sparc) || defined(__sparc))
-# define SPARC
- /* Test for SunOS 5.x */
-# include <errno.h>
-# ifdef ECHRNG
-# define SUNOS5
-# else
-# define SUNOS4
-# endif
-# define mach_type_known
-# endif
-# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
- && !defined(__OpenBSD__)
-# define SPARC
-# define DRSNX
-# define mach_type_known
-# endif
-# if defined(_IBMR2)
-# define RS6000
-# define mach_type_known
-# endif
-# if defined(_M_XENIX) && defined(_M_SYSV) && defined(_M_I386)
- /* The above test may need refinement */
-# define I386
-# if defined(_SCO_ELF)
-# define SCO_ELF
-# else
-# define SCO
-# endif
-# define mach_type_known
-# endif
-# if defined(_AUX_SOURCE)
-# define M68K
-# define SYSV
-# define mach_type_known
-# endif
-# if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
- || defined(hppa) || defined(__hppa__)
-# define HP_PA
-# ifndef LINUX
-# define HPUX
-# endif
-# define mach_type_known
-# endif
-# if defined(LINUX) && (defined(i386) || defined(__i386__))
-# define I386
-# define mach_type_known
-# endif
-# if defined(LINUX) && (defined(__ia64__) || defined(__ia64))
-# define IA64
-# define mach_type_known
-# endif
-# if defined(LINUX) && defined(powerpc)
-# define POWERPC
-# define mach_type_known
-# endif
-# if defined(LINUX) && defined(__mc68000__)
-# define M68K
-# define mach_type_known
-# endif
-# if defined(LINUX) && (defined(sparc) || defined(__sparc__))
-# define SPARC
-# define mach_type_known
-# endif
-# if defined(LINUX) && defined(arm)
-# define ARM32
-# define mach_type_known
-# endif
-# if defined(__alpha) || defined(__alpha__)
-# define ALPHA
-# if !defined(LINUX)
-# define OSF1 /* a.k.a Digital Unix */
-# endif
-# define mach_type_known
-# endif
-# if defined(_AMIGA) && !defined(AMIGA)
-# define AMIGA
-# endif
-# ifdef AMIGA
-# define M68K
-# define mach_type_known
-# endif
-# if defined(THINK_C) || defined(__MWERKS__) && !defined(__powerc)
-# define M68K
-# define MACOS
-# define mach_type_known
-# endif
-# if defined(__MWERKS__) && defined(__powerc)
-# define POWERPC
-# define MACOS
-# define mach_type_known
-# endif
-# if defined(macosx)
-# define MACOSX
-# define POWERPC
-# define mach_type_known
-# endif
-# if defined(NeXT) && defined(mc68000)
-# define M68K
-# define NEXT
-# define mach_type_known
-# endif
-# if defined(NeXT) && defined(i386)
-# define I386
-# define NEXT
-# define mach_type_known
-# endif
-# if defined(__OpenBSD__) && defined(i386)
-# define I386
-# define OPENBSD
-# define mach_type_known
-# endif
-# if defined(__FreeBSD__) && defined(i386)
-# define I386
-# define FREEBSD
-# define mach_type_known
-# endif
-# if defined(__NetBSD__) && defined(i386)
-# define I386
-# define NETBSD
-# define mach_type_known
-# endif
-# if defined(bsdi) && defined(i386)
-# define I386
-# define BSDI
-# define mach_type_known
-# endif
-# if !defined(mach_type_known) && defined(__386BSD__)
-# define I386
-# define THREE86BSD
-# define mach_type_known
-# endif
-# if defined(_CX_UX) && defined(_M88K)
-# define M88K
-# define CX_UX
-# define mach_type_known
-# endif
-# if defined(DGUX)
-# define M88K
- /* DGUX defined */
-# define mach_type_known
-# endif
-# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
-# define I386
-# define MSWIN32 /* or Win32s */
-# define mach_type_known
-# endif
-# if defined(__DJGPP__)
-# define I386
-# ifndef DJGPP
-# define DJGPP /* MSDOS running the DJGPP port of GCC */
-# endif
-# define mach_type_known
-# endif
-# if defined(__CYGWIN32__) || defined(__CYGWIN__)
-# define I386
-# define CYGWIN32
-# define mach_type_known
-# endif
-# if defined(__MINGW32__)
-# define I386
-# define MSWIN32
-# define mach_type_known
-# endif
-# if defined(__BORLANDC__)
-# define I386
-# define MSWIN32
-# define mach_type_known
-# endif
-# if defined(_UTS) && !defined(mach_type_known)
-# define S370
-# define UTS4
-# define mach_type_known
-# endif
-# if defined(__pj__)
-# define PJ
-# define mach_type_known
-# endif
-/* Ivan Demakov */
-# if defined(__WATCOMC__) && defined(__386__)
-# define I386
-# if !defined(OS2) && !defined(MSWIN32) && !defined(DOS4GW)
-# if defined(__OS2__)
-# define OS2
-# else
-# if defined(__WINDOWS_386__) || defined(__NT__)
-# define MSWIN32
-# else
-# define DOS4GW
-# endif
-# endif
-# endif
-# define mach_type_known
-# endif
-
-/* Feel free to add more clauses here */
-
-/* Or manually define the machine type here. A machine type is */
-/* characterized by the architecture. Some */
-/* machine types are further subdivided by OS. */
-/* the macros ULTRIX, RISCOS, and BSD to distinguish. */
-/* Note that SGI IRIX is treated identically to RISCOS. */
-/* SYSV on an M68K actually means A/UX. */
-/* The distinction in these cases is usually the stack starting address */
-# ifndef mach_type_known
- --> unknown machine type
-# endif
- /* Mapping is: M68K ==> Motorola 680X0 */
- /* (SUNOS4,HP,NEXT, and SYSV (A/UX), */
- /* MACOS and AMIGA variants) */
- /* I386 ==> Intel 386 */
- /* (SEQUENT, OS2, SCO, LINUX, NETBSD, */
- /* FREEBSD, THREE86BSD, MSWIN32, */
- /* BSDI,SUNOS5, NEXT, other variants) */
- /* NS32K ==> Encore Multimax */
- /* MIPS ==> R2000 or R3000 */
- /* (RISCOS, ULTRIX variants) */
- /* VAX ==> DEC VAX */
- /* (BSD, ULTRIX variants) */
- /* RS6000 ==> IBM RS/6000 AIX3.X */
- /* RT ==> IBM PC/RT */
- /* HP_PA ==> HP9000/700 & /800 */
- /* HP/UX */
- /* SPARC ==> SPARC under SunOS */
- /* (SUNOS4, SUNOS5, */
- /* DRSNX variants) */
- /* ALPHA ==> DEC Alpha */
- /* (OSF1 and LINUX variants) */
- /* M88K ==> Motorola 88XX0 */
- /* (CX_UX and DGUX) */
- /* S370 ==> 370-like machine */
- /* running Amdahl UTS4 */
- /* ARM32 ==> Intel StrongARM */
- /* IA64 ==> Intel IA64 */
- /* (e.g. Itanium) */
-
-
-/*
- * For each architecture and OS, the following need to be defined:
- *
- * CPP_WORD_SZ is a simple integer constant representing the word size.
- * in bits. We assume byte addressibility, where a byte has 8 bits.
- * We also assume CPP_WORD_SZ is either 32 or 64.
- * (We care about the length of pointers, not hardware
- * bus widths. Thus a 64 bit processor with a C compiler that uses
- * 32 bit pointers should use CPP_WORD_SZ of 32, not 64. Default is 32.)
- *
- * MACH_TYPE is a string representation of the machine type.
- * OS_TYPE is analogous for the OS.
- *
- * ALIGNMENT is the largest N, such that
- * all pointer are guaranteed to be aligned on N byte boundaries.
- * defining it to be 1 will always work, but perform poorly.
- *
- * DATASTART is the beginning of the data segment.
- * On UNIX systems, the collector will scan the area between DATASTART
- * and DATAEND for root pointers.
- *
- * DATAEND, if not &end.
- *
- * ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
- * the pointer size.
- *
- * STACKBOTTOM is the cool end of the stack, which is usually the
- * highest address in the stack.
- * Under PCR or OS/2, we have other ways of finding thread stacks.
- * For each machine, the following should:
- * 1) define STACK_GROWS_UP if the stack grows toward higher addresses, and
- * 2) define exactly one of
- * STACKBOTTOM (should be defined to be an expression)
- * HEURISTIC1
- * HEURISTIC2
- * If either of the last two macros are defined, then STACKBOTTOM is computed
- * during collector startup using one of the following two heuristics:
- * HEURISTIC1: Take an address inside GC_init's frame, and round it up to
- * the next multiple of STACK_GRAN.
- * HEURISTIC2: Take an address inside GC_init's frame, increment it repeatedly
- * in small steps (decrement if STACK_GROWS_UP), and read the value
- * at each location. Remember the value when the first
- * Segmentation violation or Bus error is signalled. Round that
- * to the nearest plausible page boundary, and use that instead
- * of STACKBOTTOM.
- *
- * Gustavo Rodriguez-Rivera points out that on most (all?) Unix machines,
- * the value of environ is a pointer that can serve as STACKBOTTOM.
- * I expect that HEURISTIC2 can be replaced by this approach, which
- * interferes far less with debugging.
- *
- * If no expression for STACKBOTTOM can be found, and neither of the above
- * heuristics are usable, the collector can still be used with all of the above
- * undefined, provided one of the following is done:
- * 1) GC_mark_roots can be changed to somehow mark from the correct stack(s)
- * without reference to STACKBOTTOM. This is appropriate for use in
- * conjunction with thread packages, since there will be multiple stacks.
- * (Allocating thread stacks in the heap, and treating them as ordinary
- * heap data objects is also possible as a last resort. However, this is
- * likely to introduce significant amounts of excess storage retention
- * unless the dead parts of the thread stacks are periodically cleared.)
- * 2) Client code may set GC_stackbottom before calling any GC_ routines.
- * If the author of the client code controls the main program, this is
- * easily accomplished by introducing a new main program, setting
- * GC_stackbottom to the address of a local variable, and then calling
- * the original main program. The new main program would read something
- * like:
- *
- * # include "gc_private.h"
- *
- * main(argc, argv, envp)
- * int argc;
- * char **argv, **envp;
- * {
- * int dummy;
- *
- * GC_stackbottom = (ptr_t)(&dummy);
- * return(real_main(argc, argv, envp));
- * }
- *
- *
- * Each architecture may also define the style of virtual dirty bit
- * implementation to be used:
- * MPROTECT_VDB: Write protect the heap and catch faults.
- * PROC_VDB: Use the SVR4 /proc primitives to read dirty bits.
- *
- * An architecture may define DYNAMIC_LOADING if dynamic_load.c
- * defined GC_register_dynamic_libraries() for the architecture.
- *
- * An architecture may define PREFETCH(x) to preload the cache with *x.
- * This defaults to a no-op.
- *
- * PREFETCH_FOR_WRITE(x) is used if *x is about to be written.
- *
- * An architecture may also define CLEAR_DOUBLE(x) to be a fast way to
- * clear the two words at GC_malloc-aligned address x. By default,
- * word stores of 0 are used instead.
- */
-
-
-# define STACK_GRAN 0x1000000
-# ifdef M68K
-# define MACH_TYPE "M68K"
-# define ALIGNMENT 2
-# ifdef OPENBSD
-# define OS_TYPE "OPENBSD"
-# define HEURISTIC2
- extern char etext;
-# define DATASTART ((ptr_t)(&etext))
-# endif
-# ifdef NETBSD
-# define OS_TYPE "NETBSD"
-# define HEURISTIC2
- extern char etext;
-# define DATASTART ((ptr_t)(&etext))
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# define STACKBOTTOM ((ptr_t)0xf0000000)
-# define MPROTECT_VDB
-# ifdef __ELF__
-# define DYNAMIC_LOADING
- extern char **__environ;
-# define DATASTART ((ptr_t)(&__environ))
- /* hideous kludge: __environ is the first */
- /* word in crt0.o, and delimits the start */
- /* of the data segment, no matter which */
- /* ld options were passed through. */
- /* We could use _etext instead, but that */
- /* would include .rodata, which may */
- /* contain large read-only data tables */
- /* that we'd rather not scan. */
- extern int _end;
-# define DATAEND (&_end)
-# else
- extern int etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
-# endif
-# endif
-# ifdef SUNOS4
-# define OS_TYPE "SUNOS4"
- extern char etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ffff) & ~0x1ffff))
-# define HEURISTIC1 /* differs */
-# define DYNAMIC_LOADING
-# endif
-# ifdef HP
-# define OS_TYPE "HP"
- extern char etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
-# define STACKBOTTOM ((ptr_t) 0xffeffffc)
- /* empirically determined. seems to work. */
-# include <unistd.h>
-# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
-# endif
-# ifdef SYSV
-# define OS_TYPE "SYSV"
- extern etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
- & ~0x3fffff) \
- +((word)&etext & 0x1fff))
- /* This only works for shared-text binaries with magic number 0413.
- The other sorts of SysV binaries put the data at the end of the text,
- in which case the default of &etext would work. Unfortunately,
- handling both would require having the magic-number available.
- -- Parag
- */
-# define STACKBOTTOM ((ptr_t)0xFFFFFFFE)
- /* The stack starts at the top of memory, but */
- /* 0x0 cannot be used as setjump_test complains */
- /* that the stack direction is incorrect. Two */
- /* bytes down from 0x0 should be safe enough. */
- /* --Parag */
-# include <sys/mmu.h>
-# define GETPAGESIZE() PAGESIZE /* Is this still right? */
-# endif
-# ifdef AMIGA
-# define OS_TYPE "AMIGA"
- /* STACKBOTTOM and DATASTART handled specially */
- /* in os_dep.c */
-# define DATAEND /* not needed */
-# define GETPAGESIZE() 4096
-# endif
-# ifdef MACOS
-# ifndef __LOWMEM__
-# include <LowMem.h>
-# endif
-# define OS_TYPE "MACOS"
- /* see os_dep.c for details of global data segments. */
-# define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
-# define DATAEND /* not needed */
-# define GETPAGESIZE() 4096
-# endif
-# ifdef NEXT
-# define OS_TYPE "NEXT"
-# define DATASTART ((ptr_t) get_etext())
-# define STACKBOTTOM ((ptr_t) 0x4000000)
-# define DATAEND /* not needed */
-# endif
-# endif
-
-# ifdef POWERPC
-# define MACH_TYPE "POWERPC"
-# ifdef MACOS
-# define ALIGNMENT 2 /* Still necessary? Could it be 4? */
-# ifndef __LOWMEM__
-# include <LowMem.h>
-# endif
-# define OS_TYPE "MACOS"
- /* see os_dep.c for details of global data segments. */
-# define STACKBOTTOM ((ptr_t) LMGetCurStackBase())
-# define DATAEND /* not needed */
-# endif
-# ifdef LINUX
-# define ALIGNMENT 4 /* Guess. Can someone verify? */
- /* This was 2, but that didn't sound right. */
-# define OS_TYPE "LINUX"
-# define HEURISTIC1
-# define DYNAMIC_LOADING
-# undef STACK_GRAN
-# define STACK_GRAN 0x10000000
- /* Stack usually starts at 0x80000000 */
-# define LINUX_DATA_START
- extern int _end;
-# define DATAEND (&_end)
-# endif
-# ifdef MACOSX
-# define ALIGNMENT 4
-# define OS_TYPE "MACOSX"
-# define DATASTART ((ptr_t) get_etext())
-# define STACKBOTTOM ((ptr_t) 0xc0000000)
-# define DATAEND /* not needed */
-# endif
-# endif
-
-# ifdef VAX
-# define MACH_TYPE "VAX"
-# define ALIGNMENT 4 /* Pointers are longword aligned by 4.2 C compiler */
- extern char etext;
-# define DATASTART ((ptr_t)(&etext))
-# ifdef BSD
-# define OS_TYPE "BSD"
-# define HEURISTIC1
- /* HEURISTIC2 may be OK, but it's hard to test. */
-# endif
-# ifdef ULTRIX
-# define OS_TYPE "ULTRIX"
-# define STACKBOTTOM ((ptr_t) 0x7fffc800)
-# endif
-# endif
-
-# ifdef RT
-# define MACH_TYPE "RT"
-# define ALIGNMENT 4
-# define DATASTART ((ptr_t) 0x10000000)
-# define STACKBOTTOM ((ptr_t) 0x1fffd800)
-# endif
-
-# ifdef SPARC
-# define MACH_TYPE "SPARC"
-# define ALIGNMENT 4 /* Required by hardware */
-# define ALIGN_DOUBLE
- extern int etext;
-# ifdef SUNOS5
-# define OS_TYPE "SUNOS5"
- extern int _etext;
- extern int _end;
- extern char * GC_SysVGetDataStart();
-# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
-# define DATAEND (&_end)
-# ifndef USE_MMAP
-# define USE_MMAP
-# endif
-# ifdef USE_MMAP
-# define HEAP_START (ptr_t)0x40000000
-# else
-# define HEAP_START DATAEND
-# endif
-# define PROC_VDB
-/* HEURISTIC1 reportedly no longer works under 2.7. Thus we */
-/* switched to HEURISTIC2, eventhough it creates some debugging */
-/* issues. */
-# define HEURISTIC2
-# include <unistd.h>
-# define GETPAGESIZE() sysconf(_SC_PAGESIZE)
- /* getpagesize() appeared to be missing from at least one */
- /* Solaris 5.4 installation. Weird. */
-# define DYNAMIC_LOADING
-# endif
-# ifdef SUNOS4
-# define OS_TYPE "SUNOS4"
- /* [If you have a weak stomach, don't read this.] */
- /* We would like to use: */
-/* # define DATASTART ((ptr_t)((((word) (&etext)) + 0x1fff) & ~0x1fff)) */
- /* This fails occasionally, due to an ancient, but very */
- /* persistent ld bug. &etext is set 32 bytes too high. */
- /* We instead read the text segment size from the a.out */
- /* header, which happens to be mapped into our address space */
- /* at the start of the text segment. The detective work here */
- /* was done by Robert Ehrlich, Manuel Serrano, and Bernard */
- /* Serpette of INRIA. */
- /* This assumes ZMAGIC, i.e. demand-loadable executables. */
-# define TEXTSTART 0x2000
-# define DATASTART ((ptr_t)(*(int *)(TEXTSTART+0x4)+TEXTSTART))
-# define MPROTECT_VDB
-# define HEURISTIC1
-# define DYNAMIC_LOADING
-# endif
-# ifdef DRSNX
-# define CPP_WORDSZ 32
-# define OS_TYPE "DRSNX"
- extern char * GC_SysVGetDataStart();
- extern int etext;
-# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
-# define MPROTECT_VDB
-# define STACKBOTTOM ((ptr_t) 0xdfff0000)
-# define DYNAMIC_LOADING
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# ifdef __ELF__
-# define LINUX_DATA_START
-# define DYNAMIC_LOADING
-# else
- Linux Sparc non elf ?
-# endif
- extern int _end;
-# define DATAEND (&_end)
-# define SVR4
-# define STACKBOTTOM ((ptr_t) 0xf0000000)
-# endif
-# ifdef OPENBSD
-# define OS_TYPE "OPENBSD"
-# define STACKBOTTOM ((ptr_t) 0xf8000000)
-# define DATASTART ((ptr_t)(&etext))
-# endif
-# endif
-
-# ifdef I386
-# define MACH_TYPE "I386"
-# define ALIGNMENT 4 /* Appears to hold for all "32 bit" compilers */
- /* except Borland. The -a4 option fixes */
- /* Borland. */
- /* Ivan Demakov: For Watcom the option is -zp4. */
-# ifndef SMALL_CONFIG
-# define ALIGN_DOUBLE /* Not strictly necessary, but may give speed */
- /* improvement on Pentiums. */
-# endif
-# ifdef SEQUENT
-# define OS_TYPE "SEQUENT"
- extern int etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
-# define STACKBOTTOM ((ptr_t) 0x3ffff000)
-# endif
-# ifdef SUNOS5
-# define OS_TYPE "SUNOS5"
- extern int etext, _start;
- extern char * GC_SysVGetDataStart();
-# define DATASTART GC_SysVGetDataStart(0x1000, &etext)
-# define STACKBOTTOM ((ptr_t)(&_start))
-/** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */
-/*# define PROC_VDB*/
-# define DYNAMIC_LOADING
-# ifndef USE_MMAP
-# define USE_MMAP
-# endif
-# ifdef USE_MMAP
-# define HEAP_START (ptr_t)0x40000000
-# else
-# define HEAP_START DATAEND
-# endif
-# endif
-# ifdef SCO
-# define OS_TYPE "SCO"
- extern int etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0x3fffff) \
- & ~0x3fffff) \
- +((word)&etext & 0xfff))
-# define STACKBOTTOM ((ptr_t) 0x7ffffffc)
-# endif
-# ifdef SCO_ELF
-# define OS_TYPE "SCO_ELF"
- extern int etext;
-# define DATASTART ((ptr_t)(&etext))
-# define STACKBOTTOM ((ptr_t) 0x08048000)
-# define DYNAMIC_LOADING
-# define ELF_CLASS ELFCLASS32
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# define LINUX_STACKBOTTOM
-# if 0
-# define HEURISTIC1
-# undef STACK_GRAN
-# define STACK_GRAN 0x10000000
- /* STACKBOTTOM is usually 0xc0000000, but this changes with */
- /* different kernel configurations. In particular, systems */
- /* with 2GB physical memory will usually move the user */
- /* address space limit, and hence initial SP to 0x80000000. */
-# endif
-# if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC)
-# define MPROTECT_VDB
-# else
- /* We seem to get random errors in incremental mode, */
- /* possibly because Linux threads is itself a malloc client */
- /* and can't deal with the signals. */
-# endif
-# ifdef __ELF__
-# define DYNAMIC_LOADING
-# ifdef UNDEFINED /* includes ro data */
- extern int _etext;
-# define DATASTART ((ptr_t)((((word) (&_etext)) + 0xfff) & ~0xfff))
-# endif
-# include <features.h>
-# if defined(__GLIBC__) && __GLIBC__ >= 2
-# define LINUX_DATA_START
-# else
- extern char **__environ;
-# define DATASTART ((ptr_t)(&__environ))
- /* hideous kludge: __environ is the first */
- /* word in crt0.o, and delimits the start */
- /* of the data segment, no matter which */
- /* ld options were passed through. */
- /* We could use _etext instead, but that */
- /* would include .rodata, which may */
- /* contain large read-only data tables */
- /* that we'd rather not scan. */
-# endif
- extern int _end;
-# define DATAEND (&_end)
-# else
- extern int etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
-# endif
-# ifdef USE_I686_PREFETCH
-# define PREFETCH(x) \
- __asm__ __volatile__ (" prefetchnta %0": : "m"(*(char *)(x)))
- /* Empirically prefetcht0 is much more effective at reducing */
- /* cache miss stalls for the targetted load instructions. But it */
- /* seems to interfere enough with other cache traffic that the net */
- /* result is worse than prefetchnta. */
-# if 0
- /* Using prefetches for write seems to have a slight negative */
- /* impact on performance, at least for a PIII/500. */
-# define PREFETCH_FOR_WRITE(x) \
- __asm__ __volatile__ (" prefetcht0 %0": : "m"(*(char *)(x)))
-# endif
-# endif
-# ifdef USE_3DNOW_PREFETCH
-# define PREFETCH(x) \
- __asm__ __volatile__ (" prefetch %0": : "m"(*(char *)(x)))
-# define PREFETCH_FOR_WRITE(x)
- __asm__ __volatile__ (" prefetchw %0": : "m"(*(char *)(x)))
-# endif
-# endif
-# ifdef CYGWIN32
-# define OS_TYPE "CYGWIN32"
- extern int _data_start__;
- extern int _data_end__;
- extern int _bss_start__;
- extern int _bss_end__;
- /* For binutils 2.9.1, we have */
- /* DATASTART = _data_start__ */
- /* DATAEND = _bss_end__ */
- /* whereas for some earlier versions it was */
- /* DATASTART = _bss_start__ */
- /* DATAEND = _data_end__ */
- /* To get it right for both, we take the */
- /* minumum/maximum of the two. */
-# define MAX(x,y) ((x) > (y) ? (x) : (y))
-# define MIN(x,y) ((x) < (y) ? (x) : (y))
-# define DATASTART ((ptr_t) MIN(&_data_start__, &_bss_start__))
-# define DATAEND ((ptr_t) MAX(&_data_end__, &_bss_end__))
-# undef STACK_GRAN
-# define STACK_GRAN 0x10000
-# define HEURISTIC1
-# endif
-# ifdef OS2
-# define OS_TYPE "OS2"
- /* STACKBOTTOM and DATASTART are handled specially in */
- /* os_dep.c. OS2 actually has the right */
- /* system call! */
-# define DATAEND /* not needed */
-# endif
-# ifdef MSWIN32
-# define OS_TYPE "MSWIN32"
- /* STACKBOTTOM and DATASTART are handled specially in */
- /* os_dep.c. */
-# ifndef __WATCOMC__
-# define MPROTECT_VDB
-# endif
-# define DATAEND /* not needed */
-# endif
-# ifdef DJGPP
-# define OS_TYPE "DJGPP"
-# include "stubinfo.h"
- extern int etext;
- extern int _stklen;
- extern int __djgpp_stack_limit;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0x1ff) & ~0x1ff))
-/* # define STACKBOTTOM ((ptr_t)((word) _stubinfo + _stubinfo->size \
- + _stklen)) */
-# define STACKBOTTOM ((ptr_t)((word) __djgpp_stack_limit + _stklen))
- /* This may not be right. */
-# endif
-# ifdef OPENBSD
-# define OS_TYPE "OPENBSD"
-# endif
-# ifdef FREEBSD
-# define OS_TYPE "FREEBSD"
-# define MPROTECT_VDB
-# endif
-# ifdef NETBSD
-# define OS_TYPE "NETBSD"
-# endif
-# ifdef THREE86BSD
-# define OS_TYPE "THREE86BSD"
-# endif
-# ifdef BSDI
-# define OS_TYPE "BSDI"
-# endif
-# if defined(OPENBSD) || defined(FREEBSD) || defined(NETBSD) \
- || defined(THREE86BSD) || defined(BSDI)
-# define HEURISTIC2
- extern char etext;
-# define DATASTART ((ptr_t)(&etext))
-# endif
-# ifdef NEXT
-# define OS_TYPE "NEXT"
-# define DATASTART ((ptr_t) get_etext())
-# define STACKBOTTOM ((ptr_t)0xc0000000)
-# define DATAEND /* not needed */
-# endif
-# ifdef DOS4GW
-# define OS_TYPE "DOS4GW"
- extern long __nullarea;
- extern char _end;
- extern char *_STACKTOP;
- /* Depending on calling conventions Watcom C either precedes
- or does not precedes with undescore names of C-variables.
- Make sure startup code variables always have the same names. */
- #pragma aux __nullarea "*";
- #pragma aux _end "*";
-# define STACKBOTTOM ((ptr_t) _STACKTOP)
- /* confused? me too. */
-# define DATASTART ((ptr_t) &__nullarea)
-# define DATAEND ((ptr_t) &_end)
-# endif
-# endif
-
-# ifdef NS32K
-# define MACH_TYPE "NS32K"
-# define ALIGNMENT 4
- extern char **environ;
-# define DATASTART ((ptr_t)(&environ))
- /* hideous kludge: environ is the first */
- /* word in crt0.o, and delimits the start */
- /* of the data segment, no matter which */
- /* ld options were passed through. */
-# define STACKBOTTOM ((ptr_t) 0xfffff000) /* for Encore */
-# endif
-
-# ifdef MIPS
-# define MACH_TYPE "MIPS"
-/* # define STACKBOTTOM ((ptr_t)0x7fff8000) sometimes also works. */
-# ifdef LINUX
- /* This was developed for a linuxce style platform. Probably */
- /* needs to be tweaked for workstation class machines. */
-# define OS_TYPE "LINUX"
- extern int __data_start;
-# define DATASTART ((ptr_t)(&__data_start))
-# define ALIGNMENT 4
-# define USE_GENERIC_PUSH_REGS 1
-# define STACKBOTTOM 0x80000000
- /* In many cases, this should probably use LINUX_STACKBOTTOM */
- /* instead. But some kernel versions seem to give the wrong */
- /* value from /proc. */
-# endif /* Linux */
-# ifdef ULTRIX
-# define HEURISTIC2
-# define DATASTART (ptr_t)0x10000000
- /* Could probably be slightly higher since */
- /* startup code allocates lots of stuff. */
-# define OS_TYPE "ULTRIX"
-# define ALIGNMENT 4
-# endif
-# ifdef RISCOS
-# define HEURISTIC2
-# define DATASTART (ptr_t)0x10000000
-# define OS_TYPE "RISCOS"
-# define ALIGNMENT 4 /* Required by hardware */
-# endif
-# ifdef IRIX5
-# define HEURISTIC2
- extern int _fdata;
-# define DATASTART ((ptr_t)(&_fdata))
-# ifdef USE_MMAP
-# define HEAP_START (ptr_t)0x30000000
-# else
-# define HEAP_START DATASTART
-# endif
- /* Lowest plausible heap address. */
- /* In the MMAP case, we map there. */
- /* In either case it is used to identify */
- /* heap sections so they're not */
- /* considered as roots. */
-# define OS_TYPE "IRIX5"
-# define MPROTECT_VDB
-# ifdef _MIPS_SZPTR
-# define CPP_WORDSZ _MIPS_SZPTR
-# define ALIGNMENT (_MIPS_SZPTR/8)
-# if CPP_WORDSZ != 64
-# define ALIGN_DOUBLE
-# endif
-# else
-# define ALIGNMENT 4
-# define ALIGN_DOUBLE
-# endif
-# define DYNAMIC_LOADING
-# endif
-# endif
-
-# ifdef RS6000
-# define MACH_TYPE "RS6000"
-# define ALIGNMENT 4
-# define DATASTART ((ptr_t)0x20000000)
- extern int errno;
-# define STACKBOTTOM ((ptr_t)((ulong)&errno))
-# define DYNAMIC_LOADING
- /* For really old versions of AIX, this may have to be removed. */
-# endif
-
-# ifdef HP_PA
- /* OS is assumed to be HP/UX */
-# define MACH_TYPE "HP_PA"
-# define OS_TYPE "HPUX"
-# ifdef __LP64__
-# define CPP_WORDSZ 64
-# define ALIGNMENT 8
-# else
-# define CPP_WORDSZ 32
-# define ALIGNMENT 4
-# define ALIGN_DOUBLE
-# endif
- extern int __data_start;
-# define DATASTART ((ptr_t)(&__data_start))
-# if 0
- /* The following appears to work for 7xx systems running HP/UX */
- /* 9.xx Furthermore, it might result in much faster */
- /* collections than HEURISTIC2, which may involve scanning */
- /* segments that directly precede the stack. It is not the */
- /* default, since it may not work on older machine/OS */
- /* combinations. (Thanks to Raymond X.T. Nijssen for uncovering */
- /* this.) */
-# define STACKBOTTOM ((ptr_t) 0x7b033000) /* from /etc/conf/h/param.h */
-# else
- /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */
- /* to this. We'll probably do this on other platforms, too. */
- /* For now I'll use it where I can test it. */
- extern char ** environ;
-# define STACKBOTTOM ((ptr_t)environ)
-# endif
-# define STACK_GROWS_UP
-# define DYNAMIC_LOADING
-# ifndef HPUX_THREADS
-# define MPROTECT_VDB
-# endif
-# include <unistd.h>
-# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
-# endif
-
-# ifdef ALPHA
-# define MACH_TYPE "ALPHA"
-# define ALIGNMENT 8
-# define USE_GENERIC_PUSH_REGS
- /* Gcc and probably the DEC/Compaq compiler spill pointers to preserved */
- /* fp registers in some cases when the target is a 21264. The assembly */
- /* code doesn't handle that yet, and version dependencies make that a */
- /* bit tricky. Do the easy thing for now. */
-# ifdef OSF1
-# define OS_TYPE "OSF1"
-# define DATASTART ((ptr_t) 0x140000000)
- extern int _end;
-# define DATAEND ((ptr_t) &_end)
-# define HEURISTIC2
- /* Normally HEURISTIC2 is too conervative, since */
- /* the text segment immediately follows the stack. */
- /* Hence we give an upper pound. */
- extern int __start;
-# define HEURISTIC2_LIMIT ((ptr_t)((word)(&__start) & ~(getpagesize()-1)))
-# define CPP_WORDSZ 64
-# define MPROTECT_VDB
-# define DYNAMIC_LOADING
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# define CPP_WORDSZ 64
-# define STACKBOTTOM ((ptr_t) 0x120000000)
-# ifdef __ELF__
-# define LINUX_DATA_START
-# define DYNAMIC_LOADING
- /* This doesn't work if the collector is in a dynamic library. */
-# else
-# define DATASTART ((ptr_t) 0x140000000)
-# endif
- extern int _end;
-# define DATAEND (&_end)
-# define MPROTECT_VDB
- /* Has only been superficially tested. May not */
- /* work on all versions. */
-# endif
-# endif
-
-# ifdef IA64
-# define MACH_TYPE "IA64"
-# define ALIGN_DOUBLE
- /* Requires 16 byte alignment for malloc */
-# define ALIGNMENT 8
-# define USE_GENERIC_PUSH_REGS
- /* We need to get preserved registers in addition to register windows. */
- /* That's easiest to do with setjmp. */
-# ifdef HPUX
- --> needs work
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# define CPP_WORDSZ 64
- /* This should really be done through /proc, but that */
- /* requires we run on an IA64 kernel. */
-# define STACKBOTTOM ((ptr_t) 0xa000000000000000l)
- /* We also need the base address of the register stack */
- /* backing store. There is probably a better way to */
- /* get that, too ... */
-# define BACKING_STORE_BASE ((ptr_t) 0x9fffffff80000000l)
-# if 1
-# define SEARCH_FOR_DATA_START
-# define DATASTART GC_data_start
-# else
- extern int data_start;
-# define DATASTART ((ptr_t)(&data_start))
-# endif
-# define DYNAMIC_LOADING
-# define MPROTECT_VDB
- /* Requires Linux 2.3.47 or later. */
- extern int _end;
-# define DATAEND (&_end)
-# define PREFETCH(x) \
- __asm__ (" lfetch [%0]": : "r"((void *)(x)))
-# define PREFETCH_FOR_WRITE(x) \
- __asm__ (" lfetch.excl [%0]": : "r"((void *)(x)))
-# define CLEAR_DOUBLE(x) \
- __asm__ (" stf.spill [%0]=f0": : "r"((void *)(x)))
-# endif
-# endif
-
-# ifdef M88K
-# define MACH_TYPE "M88K"
-# define ALIGNMENT 4
-# define ALIGN_DOUBLE
- extern int etext;
-# ifdef CX_UX
-# define OS_TYPE "CX_UX"
-# define DATASTART ((((word)&etext + 0x3fffff) & ~0x3fffff) + 0x10000)
-# endif
-# ifdef DGUX
-# define OS_TYPE "DGUX"
- extern char * GC_SysVGetDataStart();
-# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &etext)
-# endif
-# define STACKBOTTOM ((char*)0xf0000000) /* determined empirically */
-# endif
-
-# ifdef S370
-# define MACH_TYPE "S370"
-# define OS_TYPE "UTS4"
-# define ALIGNMENT 4 /* Required by hardware */
- extern int etext;
- extern int _etext;
- extern int _end;
- extern char * GC_SysVGetDataStart();
-# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
-# define DATAEND (&_end)
-# define HEURISTIC2
-# endif
-
-# if defined(PJ)
-# define ALIGNMENT 4
- extern int _etext;
-# define DATASTART ((ptr_t)(&_etext))
-# define HEURISTIC1
-# endif
-
-# ifdef ARM32
-# define CPP_WORDSZ 32
-# define MACH_TYPE "ARM32"
-# define ALIGNMENT 4
-# ifdef NETBSD
-# define OS_TYPE "NETBSD"
-# define HEURISTIC2
- extern char etext;
-# define DATASTART ((ptr_t)(&etext))
-# define USE_GENERIC_PUSH_REGS
-# endif
-# ifdef LINUX
-# define OS_TYPE "LINUX"
-# define HEURISTIC1
-# undef STACK_GRAN
-# define STACK_GRAN 0x10000000
-# define USE_GENERIC_PUSH_REGS
-# ifdef __ELF__
-# define DYNAMIC_LOADING
-# include <features.h>
-# if defined(__GLIBC__) && __GLIBC__ >= 2
-# define LINUX_DATA_START
-# else
- extern char **__environ;
-# define DATASTART ((ptr_t)(&__environ))
- /* hideous kludge: __environ is the first */
- /* word in crt0.o, and delimits the start */
- /* of the data segment, no matter which */
- /* ld options were passed through. */
- /* We could use _etext instead, but that */
- /* would include .rodata, which may */
- /* contain large read-only data tables */
- /* that we'd rather not scan. */
-# endif
- extern int _end;
-# define DATAEND (&_end)
-# else
- extern int etext;
-# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
-# endif
-# endif
-#endif
-
-#ifdef LINUX_DATA_START
- /* Some Linux distributions arrange to define __data_start. Some */
- /* define data_start as a weak symbol. The latter is technically */
- /* broken, since the user program may define data_start, in which */
- /* case we lose. Nonetheless, we try both, prefering __data_start. */
- /* We assume gcc. */
-# pragma weak __data_start
- extern int __data_start;
-# pragma weak data_start
- extern int data_start;
-# define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
-#endif
-
-# ifndef STACK_GROWS_UP
-# define STACK_GROWS_DOWN
-# endif
-
-# ifndef CPP_WORDSZ
-# define CPP_WORDSZ 32
-# endif
-
-# ifndef OS_TYPE
-# define OS_TYPE ""
-# endif
-
-# ifndef DATAEND
- extern int end;
-# define DATAEND (&end)
-# endif
-
-# if defined(SVR4) && !defined(GETPAGESIZE)
-# include <unistd.h>
-# define GETPAGESIZE() sysconf(_SC_PAGESIZE)
-# endif
-
-# ifndef GETPAGESIZE
-# if defined(SUNOS5) || defined(IRIX5)
-# include <unistd.h>
-# endif
-# define GETPAGESIZE() getpagesize()
-# endif
-
-# if defined(SUNOS5) || defined(DRSNX) || defined(UTS4)
- /* OS has SVR4 generic features. Probably others also qualify. */
-# define SVR4
-# endif
-
-# if defined(SUNOS5) || defined(DRSNX)
- /* OS has SUNOS5 style semi-undocumented interface to dynamic */
- /* loader. */
-# define SUNOS5DL
- /* OS has SUNOS5 style signal handlers. */
-# define SUNOS5SIGS
-# endif
-
-# if defined(HPUX)
-# define SUNOS5SIGS
-# endif
-
-# if CPP_WORDSZ != 32 && CPP_WORDSZ != 64
- -> bad word size
-# endif
-
-# ifdef PCR
-# undef DYNAMIC_LOADING
-# undef STACKBOTTOM
-# undef HEURISTIC1
-# undef HEURISTIC2
-# undef PROC_VDB
-# undef MPROTECT_VDB
-# define PCR_VDB
-# endif
-
-# ifdef SRC_M3
-/* Postponed for now. */
-# undef PROC_VDB
-# undef MPROTECT_VDB
-# endif
-
-# ifdef SMALL_CONFIG
-/* Presumably not worth the space it takes. */
-# undef PROC_VDB
-# undef MPROTECT_VDB
-# endif
-
-# ifdef USE_MUNMAP
-# undef MPROTECT_VDB /* Can't deal with address space holes. */
-# endif
-
-# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
-# define DEFAULT_VDB
-# endif
-
-# ifndef PREFETCH
-# define PREFETCH(x)
-# define NO_PREFETCH
-# endif
-
-# ifndef PREFETCH_FOR_WRITE
-# define PREFETCH_FOR_WRITE(x)
-# define NO_PREFETCH_FOR_WRITE
-# endif
-
-# ifndef CACHE_LINE_SIZE
-# define CACHE_LINE_SIZE 32 /* Wild guess */
-# endif
-
-# ifndef CLEAR_DOUBLE
-# define CLEAR_DOUBLE(x) \
- ((word*)x)[0] = 0; \
- ((word*)x)[1] = 0;
-# endif /* CLEAR_DOUBLE */
-
-# if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
-# define SOLARIS_THREADS
-# endif
-# if defined(IRIX_THREADS) && !defined(IRIX5)
---> inconsistent configuration
-# endif
-# if defined(IRIX_JDK_THREADS) && !defined(IRIX5)
---> inconsistent configuration
-# endif
-# if defined(LINUX_THREADS) && !defined(LINUX)
---> inconsistent configuration
-# endif
-# if defined(SOLARIS_THREADS) && !defined(SUNOS5)
---> inconsistent configuration
-# endif
-# if defined(HPUX_THREADS) && !defined(HPUX)
---> inconsistent configuration
-# endif
-# if defined(PCR) || defined(SRC_M3) || \
- defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
- defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
- defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
-# define THREADS
-# endif
-
-# if defined(HP_PA) || defined(M88K) || defined(POWERPC) \
- || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT)
- /* Use setjmp based hack to mark from callee-save registers. */
-# define USE_GENERIC_PUSH_REGS
-# endif
-# if defined(SPARC) && !defined(LINUX)
-# define SAVE_CALL_CHAIN
-# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
- /* include assembly code to do it well. */
-# endif
-
-# endif /* GCCONFIG_H */
diff --git a/gcj_mlc.c b/gcj_mlc.c
index eb67eac1..74bdf570 100644
--- a/gcj_mlc.c
+++ b/gcj_mlc.c
@@ -36,10 +36,10 @@
* 3) FASTLOCK is not a significant win.
*/
-#include "gc_priv.h"
-#include "gc_mark.h"
-#include "include/gc_gcj.h"
-#include "dbg_mlc.h"
+#include "private/gc_priv.h"
+#include "private/gc_mark.h"
+#include "gc_gcj.h"
+#include "private/dbg_mlc.h"
GC_bool GC_gcj_malloc_initialized = FALSE;
@@ -51,10 +51,6 @@ int GC_gcj_debug_kind; /* The kind of objects that is always marked */
ptr_t * GC_gcjobjfreelist;
ptr_t * GC_gcjdebugobjfreelist;
-void * GC_default_oom_action(void) { return 0; }
-
-void * (*GC_oom_action)(void) = GC_default_oom_action;
-
/* Caller does not hold allocation lock. */
void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
{
@@ -74,7 +70,7 @@ void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
if (mp_index >= GC_n_mark_procs) ABORT("GC_init_gcj_malloc: bad index");
/* Set up object kind gcj-style indirect descriptor. */
GC_gcjobjfreelist = (ptr_t *)
- GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
+ GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
if (GC_gcjobjfreelist == 0) ABORT("Couldn't allocate GC_gcjobjfreelist");
BZERO(GC_gcjobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
GC_gcj_kind = GC_n_kinds++;
@@ -86,7 +82,7 @@ void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp)
GC_obj_kinds[GC_gcj_kind].ok_init = TRUE;
/* Set up object kind for objects that require mark proc call. */
GC_gcjdebugobjfreelist = (ptr_t *)
- GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
+ GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
if (GC_gcjdebugobjfreelist == 0)
ABORT("Couldn't allocate GC_gcjdebugobjfreelist");
BZERO(GC_gcjdebugobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
@@ -131,7 +127,7 @@ DCL_LOCK_STATE;
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_gcj_kind);
if (0 == op) {
UNLOCK();
- return(GC_oom_action());
+ return(GC_oom_fn(lb));
}
# ifdef MERGE_SIZES
lw = GC_size_map[lb]; /* May have been uninitialized. */
@@ -139,7 +135,6 @@ DCL_LOCK_STATE;
} else {
*opp = obj_link(op);
GC_words_allocd += lw;
- FASTUNLOCK();
}
*(void **)op = ptr_to_struct_containing_descr;
UNLOCK();
@@ -148,7 +143,7 @@ DCL_LOCK_STATE;
op = (ptr_t)GENERAL_MALLOC((word)lb, GC_gcj_kind);
if (0 == op) {
UNLOCK();
- return(GC_oom_action());
+ return(GC_oom_fn(lb));
}
*(void **)op = ptr_to_struct_containing_descr;
UNLOCK();
@@ -175,7 +170,7 @@ GC_PTR GC_debug_gcj_malloc(size_t lb, void * ptr_to_struct_containing_descr,
(unsigned long) ptr_to_struct_containing_descr);
GC_err_puts(s);
GC_err_printf1(":%ld)\n", (unsigned long)i);
- return(GC_oom_action());
+ return(GC_oom_fn(lb));
}
*((void **)((ptr_t)result + sizeof(oh))) = ptr_to_struct_containing_descr;
UNLOCK();
@@ -202,7 +197,7 @@ DCL_LOCK_STATE;
GC_generic_malloc_words_small_inner(lw, GC_gcj_kind));
if (0 == op) {
UNLOCK();
- return(GC_oom_action());
+ return GC_oom_fn(WORDS_TO_BYTES(lw));
}
} else {
*opp = obj_link(op);
@@ -233,7 +228,7 @@ void * GC_debug_gcj_fast_malloc(size_t lw,
(unsigned long) ptr_to_struct_containing_descr);
GC_err_puts(s);
GC_err_printf1(":%ld)\n", (unsigned long)i);
- return(GC_oom_action());
+ return GC_oom_fn(WORDS_TO_BYTES(lw));
}
*((void **)((ptr_t)result + sizeof(oh))) = ptr_to_struct_containing_descr;
UNLOCK();
diff --git a/headers.c b/headers.c
index 6e47bba8..0aa51397 100644
--- a/headers.c
+++ b/headers.c
@@ -22,7 +22,7 @@
* level tree.
*/
-# include "gc_priv.h"
+# include "private/gc_priv.h"
bottom_index * GC_all_bottom_indices = 0;
/* Pointer to first (lowest addr) */
@@ -260,7 +260,7 @@ register word sz; /* bytes */
/* Apply fn to all allocated blocks */
/*VARARGS1*/
void GC_apply_to_all_blocks(fn, client_data)
-void (*fn)(/* struct hblk *h, word client_data */);
+void (*fn) GC_PROTO((struct hblk *h, word client_data));
word client_data;
{
register int j;
diff --git a/hpux_irix_threads.c b/hpux_irix_threads.c
index f6e74365..b63f31a6 100644
--- a/hpux_irix_threads.c
+++ b/hpux_irix_threads.c
@@ -25,13 +25,13 @@
* there too.
*/
-# if defined(IRIX_THREADS) || defined(HPUX_THREADS)
+# if defined(GC_IRIX_THREADS) || defined(GC_HPUX_THREADS) \
+ || defined(IRIX_THREADS) || defined(HPUX_THREADS)
+# include "private/gc_priv.h"
# if defined(HPUX_THREADS)
# include <sys/semaphore.h>
# endif
-
-# include "gc_priv.h"
# include <pthread.h>
# include <semaphore.h>
# include <time.h>
@@ -223,7 +223,7 @@ GC_thread GC_new_thread(pthread_t id)
/* Dont acquire allocation lock, since we may already hold it. */
} else {
result = (struct GC_Thread_Rep *)
- GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
+ GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
}
if (result == 0) return(0);
result -> id = id;
diff --git a/if_mach.c b/if_mach.c
index af013637..9f32ceac 100644
--- a/if_mach.c
+++ b/if_mach.c
@@ -1,7 +1,9 @@
/* Conditionally execute a command based on machine and OS from gcconfig.h */
-# include "gcconfig.h"
+# include "private/gcconfig.h"
# include <stdio.h>
+# include <string.h>
+# include <unistd.h>
int main(argc, argv, envp)
int argc;
diff --git a/if_not_there.c b/if_not_there.c
index a93795f1..2bb15833 100644
--- a/if_not_there.c
+++ b/if_not_there.c
@@ -1,7 +1,9 @@
/* Conditionally execute a command based if the file argv[1] doesn't exist */
/* Except for execvp, we stick to ANSI C. */
-# include "gcconfig.h"
+# include "private/gcconfig.h"
# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
int main(argc, argv, envp)
int argc;
diff --git a/include/backptr.h b/include/backptr.h
deleted file mode 100644
index f5b7c5aa..00000000
--- a/include/backptr.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * This is a simple API to implement pointer back tracing, i.e.
- * to answer questions such as "who is pointing to this" or
- * "why is this object being retained by the collector"
- *
- * This API assumes that we have an ANSI C compiler.
- *
- * Most of these calls yield useful information on only after
- * a garbage collection. Usually the client will first force
- * a full collection and then gather information, preferably
- * before much intervening allocation.
- *
- * The implementation of the interface is only about 99.9999%
- * correct. It is intended to be good enough for profiling,
- * but is not intended to be used with production code.
- *
- * Results are likely to be much more useful if all allocation is
- * accomplished through the debugging allocators.
- *
- * The implementation idea is due to A. Demers.
- */
-
-/* Store information about the object referencing dest in *base_p */
-/* and *offset_p. */
-/* If multiple objects or roots point to dest, the one reported */
-/* will be the last on used by the garbage collector to trace the */
-/* object. */
-/* source is root ==> *base_p = address, *offset_p = 0 */
-/* source is heap object ==> *base_p != 0, *offset_p = offset */
-/* Returns 1 on success, 0 if source couldn't be determined. */
-/* Dest can be any address within a heap object. */
-typedef enum { GC_UNREFERENCED, /* No reference info available. */
- GC_NO_SPACE, /* Dest not allocated with debug alloc */
- GC_REFD_FROM_ROOT, /* Referenced directly by root *base_p */
- GC_REFD_FROM_REG, /* Referenced from a register, i.e. */
- /* a root without an address. */
- GC_REFD_FROM_HEAP, /* Referenced from another heap obj. */
- GC_FINALIZER_REFD /* Finalizable and hence accessible. */
-} GC_ref_kind;
-
-GC_ref_kind GC_get_back_ptr_info(void *dest, void **base_p, size_t *offset_p);
-
-/* Generate a random heap address. */
-/* The resulting address is in the heap, but */
-/* not necessarily inside a valid object. */
-void * GC_generate_random_heap_address(void);
-
-/* Generate a random address inside a valid marked heap object. */
-void * GC_generate_random_valid_address(void);
-
-/* Force a garbage collection and generate a backtrace from a */
-/* random heap address. */
-/* This uses the GC logging mechanism (GC_printf) to produce */
-/* output. It can often be called from a debugger. The */
-/* source in dbg_mlc.c also serves as a sample client. */
-void GC_generate_random_backtrace(void);
-
-/* Print a backtrace from a specific address. Used by the */
-/* above. The client should call GC_gcollect() immediately */
-/* before invocation. */
-void GC_print_backtrace(void *);
-
-
diff --git a/include/gc.h b/include/gc.h
index d7cd8996..eda868ff 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -31,6 +31,11 @@
# define _GC_H
# define __GC
# include <stddef.h>
+# ifdef _WIN32_WCE
+/* Yet more kluges for WinCE */
+# include <stdlib.h> /* size_t is defined here */
+ typedef long ptrdiff_t; /* ptrdiff_t is not defined */
+# endif
#if defined(__CYGWIN32__) && defined(GC_USE_DLL)
#include "libgc_globals.h"
@@ -44,7 +49,7 @@
# endif
#endif
-#if defined(_MSC_VER) && defined(_DLL)
+#if defined(_MSC_VER) && (defined(_DLL) || defined(GC_DLL))
# ifdef GC_BUILD
# define GC_API __declspec(dllexport)
# else
@@ -94,6 +99,16 @@ typedef long GC_signed_word;
GC_API GC_word GC_gc_no;/* Counter incremented per collection. */
/* Includes empty GCs at startup. */
+
+GC_API int GC_parallel; /* GC is parallelized for performance on */
+ /* multiprocessors. Currently set only */
+ /* implicitly if collector is built with */
+ /* -DPARALLEL_MARK and if either: */
+ /* Env variable GC_NPROC is set to > 1, or */
+ /* GC_NPROC is not set and this is an MP. */
+ /* If GC_parallel is set, incremental */
+ /* collection is aonly partially functional, */
+ /* and may not be desirable. */
/* Public R/W variables */
@@ -120,7 +135,7 @@ GC_API int GC_quiet; /* Disable statistics output. Only matters if */
GC_API int GC_finalize_on_demand;
/* If nonzero, finalizers will only be run in */
- /* response to an eplit GC_invoke_finalizers */
+ /* response to an explicit GC_invoke_finalizers */
/* call. The default is determined by whether */
/* the FINALIZE_ON_DEMAND macro is defined */
/* when the collector is built. */
@@ -337,6 +352,8 @@ GC_API size_t GC_get_bytes_since_gc GC_PROTO((void));
/* pointerfree(atomic) or immutable. */
/* Don't use in leak finding mode. */
/* Ignored if GC_dont_gc is true. */
+/* Only the generational piece of this is */
+/* functional if GC_parallel is TRUE. */
GC_API void GC_enable_incremental GC_PROTO((void));
/* Perform some garbage collection work, if appropriate. */
@@ -697,7 +714,34 @@ GC_API void (*GC_is_visible_print_proc)
# define SOLARIS_THREADS
#endif
-#ifdef SOLARIS_THREADS
+/*
+ * Some tests for old macros. These violate our namespace rules and will
+ * disappear shortly.
+ */
+#if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS)
+# define GC_SOLARIS_THREADS
+#endif
+#if defined(_SOLARIS_PTHREADS)
+# define GC_SOLARIS_PTHREADS
+#endif
+#if defined(IRIX_THREADS)
+# define GC_IRIX_THREADS
+#endif
+#if defined(HPUX_THREADS)
+ --> Please use GC_HPUX_THREADS.
+ Unfortunately that doesnt work reliably, yet.
+#endif
+#if defined(LINUX_THREADS)
+# define GC_LINUX_THREADS
+#endif
+#if defined(WIN32_THREADS)
+# define GC_WIN32_THREADS
+#endif
+#if defined(USE_LD_WRAP)
+# define GC_USE_LD_WRAP
+#endif
+
+#if defined(GC_SOLARIS_THREADS)
/* We need to intercept calls to many of the threads primitives, so */
/* that we can locate thread stacks and stop the world. */
/* Note also that the collector cannot see thread specific data. */
@@ -705,7 +749,6 @@ GC_API void (*GC_is_visible_print_proc)
/* uncollectable objects, which are deallocated using the destructor */
/* facility in thr_keycreate. */
# include <thread.h>
-# include <signal.h>
int GC_thr_create(void *stack_base, size_t stack_size,
void *(*start_routine)(void *), void *arg, long flags,
thread_t *new_thread);
@@ -713,31 +756,30 @@ GC_API void (*GC_is_visible_print_proc)
int GC_thr_suspend(thread_t target_thread);
int GC_thr_continue(thread_t target_thread);
void * GC_dlopen(const char *path, int mode);
+# define thr_create GC_thr_create
+# define thr_join GC_thr_join
+# define thr_suspend GC_thr_suspend
+# define thr_continue GC_thr_continue
+#endif /* GC_SOLARIS_THREADS */
-# ifdef _SOLARIS_PTHREADS
-# include <pthread.h>
- extern int GC_pthread_create(pthread_t *new_thread,
+#if defined(GC_SOLARIS_PTHREADS)
+# include <pthread.h>
+# include <signal.h>
+ extern int GC_pthread_create(pthread_t *new_thread,
const pthread_attr_t *attr,
void * (*thread_execp)(void *), void *arg);
- extern int GC_pthread_join(pthread_t wait_for, void **status);
-
-# undef thread_t
-
-# define pthread_join GC_pthread_join
-# define pthread_create GC_pthread_create
+ extern int GC_pthread_join(pthread_t wait_for, void **status);
+# define pthread_join GC_pthread_join
+# define pthread_create GC_pthread_create
#endif
-# define thr_create GC_thr_create
-# define thr_join GC_thr_join
-# define thr_suspend GC_thr_suspend
-# define thr_continue GC_thr_continue
+#if defined(GC_SOLARIS_PTHREADS) || defined(GC_SOLARIS_THREADS)
# define dlopen GC_dlopen
-
-# endif /* SOLARIS_THREADS */
+#endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */
-#if !defined(USE_LD_WRAP) && \
- (defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS))
+#if !defined(GC_USE_LD_WRAP) && \
+ (defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS))
/* We treat these similarly. */
# include <pthread.h>
# include <signal.h>
@@ -753,11 +795,12 @@ GC_API void (*GC_is_visible_print_proc)
# define pthread_join GC_pthread_join
# define dlopen GC_dlopen
-#endif /* xxxxx_THREADS */
+#endif /* GC_xxxxx_THREADS */
-# if defined(PCR) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
- defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
- defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
+# if defined(PCR) || defined(GC_SOLARIS_THREADS) || \
+ defined(GC_SOLARIS_PTHREADS) || defined(GC_WIN32_THREADS) || \
+ defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \
+ defined(GC_HPUX_THREADS)
/* Any flavor of threads except SRC_M3. */
/* This returns a list of objects, linked through their first */
/* word. Its use can greatly reduce lock contention problems, since */
@@ -770,6 +813,35 @@ extern void GC_thr_init(); /* Needed for Solaris/X86 */
#endif /* THREADS && !SRC_M3 */
+#if defined(WIN32_THREADS) && defined(_WIN32_WCE)
+# include <windows.h>
+
+ /*
+ * win32_threads.c implements the real WinMain, which will start a new thread
+ * to call GC_WinMain after initializing the garbage collector.
+ */
+ int WINAPI GC_WinMain(
+ HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPWSTR lpCmdLine,
+ int nCmdShow );
+
+ /*
+ * All threads must be created using GC_CreateThread, so that they will be
+ * recorded in the thread table.
+ */
+ HANDLE WINAPI GC_CreateThread(
+ LPSECURITY_ATTRIBUTES lpThreadAttributes,
+ DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
+ LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
+
+# ifndef GC_BUILD
+# define WinMain GC_WinMain
+# define CreateThread GC_CreateThread
+# endif
+
+#endif
+
/*
* If you are planning on putting
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
@@ -790,13 +862,18 @@ extern void GC_thr_init(); /* Needed for Solaris/X86 */
# endif
#endif
-#if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32)
+#if !defined(_WIN32_WCE) \
+ && ((defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
+ || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__))
/* win32S may not free all resources on process exit. */
/* This explicitly deallocates the heap. */
GC_API void GC_win32_free_heap ();
#endif
+#if defined(GC_REDIRECT_TO_LOCAL) && !defined(GC_LOCAL_ALLOC_H)
+# include "gc_local_alloc.h"
+#endif
+
#ifdef __cplusplus
} /* end of extern "C" */
#endif
diff --git a/include/gc_alloc.h b/include/gc_alloc.h
index 1f1d54af..c50a7589 100644
--- a/include/gc_alloc.h
+++ b/include/gc_alloc.h
@@ -25,6 +25,9 @@
// This uses template classes with static members, and hence does not work
// with g++ 2.7.2 and earlier.
//
+// This code assumes that the collector itself has been compiled with a
+// compiler that defines __STDC__ .
+//
#include "gc.h"
diff --git a/backptr.h b/include/gc_backptr.h
index f5b7c5aa..5899496e 100644
--- a/backptr.h
+++ b/include/gc_backptr.h
@@ -20,6 +20,8 @@
* The implementation idea is due to A. Demers.
*/
+#ifndef GC_BACKPTR_H
+#define GC_BACKPTR_H
/* Store information about the object referencing dest in *base_p */
/* and *offset_p. */
/* If multiple objects or roots point to dest, the one reported */
@@ -60,4 +62,4 @@ void GC_generate_random_backtrace(void);
/* before invocation. */
void GC_print_backtrace(void *);
-
+#endif /* GC_BACKPTR_H */
diff --git a/include/gc_copy_descr.h b/include/gc_copy_descr.h
deleted file mode 100644
index 212c99e2..00000000
--- a/include/gc_copy_descr.h
+++ /dev/null
@@ -1,26 +0,0 @@
-
-/*
- * Copyright (c) 1999 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/* Descriptor for allocation request. May be redefined by client. */
-typedef struct {
- GC_word bitmap; /* Bitmap describing pointer locations. */
- /* High order bit correspond to 0th */
- /* word. 2 lsbs must be 0. */
- size_t length; /* In bytes, must be multiple of word */
- /* size. Must be >0, <= 512 */
-} * GC_copy_descriptor;
-
-/* The collector accesses descriptors only through these two macros. */
-#define GC_SIZE_FROM_DESCRIPTOR(d) ((d) -> length)
-#define GC_BIT_MAP_FROM_DESCRIPTOR(d) ((d) -> bitmap)
-
diff --git a/include/gc_cpp.h b/include/gc_cpp.h
index 3b86824c..a5cb5711 100644
--- a/include/gc_cpp.h
+++ b/include/gc_cpp.h
@@ -139,7 +139,7 @@ by UseGC. GC is an alias for UseGC, unless GC_NAME_CONFLICT is defined.
#if ! defined( OPERATOR_NEW_ARRAY ) \
&& (__BORLANDC__ >= 0x450 || (__GNUC__ >= 2 && __GNUC_MINOR__ >= 6) \
- || __WATCOMC__ >= 1050 || _MSC_VER >= 1100)
+ || __WATCOMC__ >= 1050 || _MSC_VER >= 1100)
# define OPERATOR_NEW_ARRAY
#endif
@@ -179,6 +179,12 @@ private:
extern "C" {typedef void (*GCCleanUpFunc)( void* obj, void* clientData );}
+#ifdef _MSC_VER
+ // Disable warning that "no matching operator delete found; memory will
+ // not be freed if initialization throws an exception"
+# pragma warning(disable:4291)
+#endif
+
inline void* operator new(
size_t size,
GCPlacement gcp,
diff --git a/include/gc_gcj.h b/include/gc_gcj.h
index 1dede515..9123a28b 100644
--- a/include/gc_gcj.h
+++ b/include/gc_gcj.h
@@ -24,6 +24,10 @@
* may be marked by the mark procedure passed to GC_init_gcj_malloc.
*/
+#ifndef GC_GCJ_H
+
+#define GC_GCJ_H
+
#ifndef MARK_DESCR_OFFSET
# define MARK_DESCR_OFFSET sizeof(word)
#endif
@@ -41,10 +45,7 @@
#endif
/* The following allocators signal an out of memory condition with */
-/* return GC_oom_action(); */
-/* The default GC_oom_action returns 0. */
-/* This functionality is currently restricted to the gcj allocators. */
-/* We may want to extend it to the others. */
+/* return GC_oom_fn(bytes); */
extern void * (*GC_oom_action)(void);
@@ -58,8 +59,6 @@ extern void * (*GC_oom_action)(void);
/* to use the same mark_proc for some of its generated mark descriptors.*/
/* In that case, it should use a different "environment" value to */
/* detect the presence or absence of the debug header. */
-
-/* the debugging interface. */
/* Mp is really of type mark_proc, as defined in gc_mark.h. We don't */
/* want to include that here for namespace pollution reasons. */
extern void GC_init_gcj_malloc(int mp_index, void * /* really mark_proc */mp);
@@ -77,6 +76,9 @@ extern void * GC_debug_gcj_malloc(size_t lb,
/* Similar to the above, but the size is in words, and we don't */
/* adjust it. The size is assumed to be such that it can be */
/* allocated as a small object. */
+/* Unless it is known that the collector is not configured */
+/* with USE_MARK_BYTES and unless it is known that the object */
+/* has weak alignment requirements, lw must be even. */
extern void * GC_gcj_fast_malloc(size_t lw,
void * ptr_to_struct_containing_descr);
extern void * GC_debug_gcj_fast_malloc(size_t lw,
@@ -91,11 +93,12 @@ extern void * GC_gcj_malloc_ignore_off_page(size_t lb,
# ifdef GC_DEBUG
# define GC_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
# define GC_GCJ_FAST_MALLOC(s,d) GC_debug_gcj_fast_malloc(s,d,GC_EXTRAS)
-# define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_gcj_debug_malloc(s,d,GC_EXTRAS)
+# define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
# else
# define GC_GCJ_MALLOC(s,d) GC_gcj_malloc(s,d)
# define GC_GCJ_FAST_MALLOC(s,d) GC_gcj_fast_malloc(s,d)
# define GC_GCJ_MALLOC_IGNORE_OFF_PAGE(s,d) \
- GC_gcj_debug_malloc_ignore_off_page(s,d)
+ GC_gcj_malloc_ignore_off_page(s,d)
# endif
+#endif /* GC_GCJ_H */
diff --git a/include/gc_inl.h b/include/gc_inl.h
index 700843bb..c14364dc 100644
--- a/include/gc_inl.h
+++ b/include/gc_inl.h
@@ -28,7 +28,11 @@
/* Allocate n words (NOT BYTES). X is made to point to the result. */
/* It is assumed that n < MAXOBJSZ, and */
/* that n > 0. On machines requiring double word alignment of some */
-/* data, we also assume that n is 1 or even. This bypasses the */
+/* data, we also assume that n is 1 or even. */
+/* If the collector is built with -DUSE_MARK_BYTES or -DPARALLEL_MARK, */
+/* the n = 1 case is also disallowed. */
+/* Effectively this means that portable code should make sure n is even.*/
+/* This bypasses the */
/* MERGE_SIZES mechanism. In order to minimize the number of distinct */
/* free lists that are maintained, the caller should ensure that a */
/* small number of distinct values of n are used. (The MERGE_SIZES */
diff --git a/include/gc_local_alloc.h b/include/gc_local_alloc.h
new file mode 100644
index 00000000..987836c3
--- /dev/null
+++ b/include/gc_local_alloc.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+/*
+ * Interface for thread local allocation. Memory obtained
+ * this way can be used by all threads, as though it were obtained
+ * from an allocator like GC_malloc. The difference is that GC_local_malloc
+ * counts the number of allocations of a given size from the current thread,
+ * and uses GC_malloc_many to perform the allocations once a threashold
+ * is exceeded. Thus far less synchronization may be needed.
+ * Allocation of known large objects should not use this interface.
+ * This interface is designed primarily for fast allocation of small
+ * objects on multiprocessors, e.g. for a JVM running on an MP server.
+ *
+ * If this file is included with GC_GCJ_SUPPORT defined, GCJ-style
+ * bitmap allocation primitives will also be included.
+ *
+ * If this file is included with GC_REDIRECT_TO_LOCAL defined, then
+ * GC_MALLOC, GC_MALLOC_ATOMIC, and possibly GC_GCJ_MALLOC will
+ * be redefined to use the thread local allocatoor.
+ *
+ * The interface is available only if the collector is built with
+ * -DTHREAD_LOCAL_ALLOC, which is currently supported only on Linux.
+ *
+ * The debugging allocators use standard, not thread-local allocation.
+ */
+
+#ifndef GC_LOCAL_ALLOC_H
+#define GC_LOCAL_ALLOC_H
+
+#ifndef _GC_H
+# include "gc.h"
+#endif
+
+#if defined(GC_GCJ_SUPPORT) && !defined(GC_GCJ_H)
+# include "gc_gcj.h"
+#endif
+
+/* We assume ANSI C for this interface. */
+/* GC_init() must be called explicitly before use of this interface. */
+
+GC_PTR GC_local_malloc(size_t bytes);
+
+GC_PTR GC_local_malloc_atomic(size_t bytes);
+
+#if defined(GC_GCJ_SUPPORT)
+ GC_PTR GC_local_gcj_malloc(size_t bytes,
+ void * ptr_to_struct_containing_descr);
+#endif
+
+# ifdef GC_DEBUG
+# define GC_LOCAL_MALLOC(s) GC_debug_malloc(s,GC_EXTRAS)
+# define GC_LOCAL_MALLOC_ATOMIC(s) GC_debug_malloc_atomic(s,GC_EXTRAS)
+# ifdef GC_GCJ_SUPPORT
+# define GC_LOCAL_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
+# endif
+# else
+# define GC_LOCAL_MALLOC(s) GC_local_malloc(s)
+# define GC_LOCAL_MALLOC_ATOMIC(s) GC_local_malloc_atomic(s)
+# ifdef GC_GCJ_SUPPORT
+# define GC_LOCAL_GCJ_MALLOC(s,d) GC_local_gcj_malloc(s,d)
+# endif
+# endif
+
+# ifdef GC_REDIRECT_TO_LOCAL
+# undef GC_MALLOC
+# define GC_MALLOC(s) GC_LOCAL_MALLOC(s)
+# undef GC_MALLOC_ATOMIC
+# define GC_MALLOC_ATOMIC(s) GC_LOCAL_MALLOC_ATOMIC(s)
+# ifdef GC_GCJ_SUPPORT
+# undef GC_GCJ_MALLOC
+# define GC_GCJ_MALLOC(s,d) GC_LOCAL_GCJ_MALLOC(s,d)
+# endif
+# endif
+
+#endif /* GC_LOCAL_ALLOC_H */
diff --git a/include/gc_nursery.h b/include/gc_nursery.h
deleted file mode 100755
index d109ff09..00000000
--- a/include/gc_nursery.h
+++ /dev/null
@@ -1,90 +0,0 @@
-
-/*
- * Copyright (c) 1999 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-/*
- * THIS IMPLEMENTATION FOR THIS INTERFACE IS INCOMPLETE.
- * NONE OF THIS HAS BEEN TESTED. DO NOT USE.
- *
- * Comments on the interface are appreciated, especially from
- * potential users of the interface.
- *
- * This is a Bartlett style copying collector for young objects.
- * We assume for now that all objects allocated through this
- * mechanism have pointers only in the first BITMAP_BITS words.
- * (On a 32-bit machine, BITMAP_BITS is 30.)
- * Objects allocated in this manner should be rarely referenced
- * by objects not allocated either through this interface, or through
- * the typed allocation interface.
- * If this interface is used, we assume that type information provided
- * through either this or the typed allocation interface is valid
- * in a stronger sense:
- *
- * 1) No pointers are stored in fields not marked as such.
- * (Otherwise it is only necessary that objects referenced by
- * fields marked as nonpointers are also reachable via another
- * path.)
- * 2) Values stored in pointer fields are either not addresses in
- * the heap, or they really are pointers. In the latter case, it
- * is acceptable to move the object they refer to, and to update
- * the pointer.
- *
- * GC_free may not be invoked on objects allocated with GC_copying_malloc.
- *
- * No extra space is added to the end of objects allocated through this
- * interface. If the client needs to maintain pointers past the
- * end, the size should be explicitly padded.
- *
- * We assume that calls to this will usually be compiler generated.
- * Hence the interface is allowed to be a bit ugly in return for speed.
- */
-
-#include "gc_copy_descr.h"
-
-/* GC_copy_descr.h must define */
-/* GC_SIZE_FROM_DESCRIPTOR(descr) and */
-/* GC_BIT_MAP_FROM_DESCRIPTOR(descr). */
-/* It may either be the GC supplied version of the header file, or a */
-/* client specific one that derives the information from a client- */
-/* specific type descriptor. */
-
-typedef GC_PTR GC_copy_alloc_state;
- /* Current allocator state. */
- /* Multiple allocation states */
- /* may be used for concurrent */
- /* allocation, or to enhance */
- /* locality. */
- /* Should be treated as opaque. */
-
-/* Allocate a memory block of size given in the descriptor, and with */
-/* pointer layout given by the descriptor. The resulting block may not */
-/* be cleared, and should immediately be initialized by the client. */
-/* (A concurrent GC may see an uninitialized pointer field. If it */
-/* points outside the nursery, that's fine. If it points inside, it */
-/* may retain an object, and be relocated. But that's also fine, since */
-/* the new value will be immediately overwritten. */
-/* This variant acquires the allocation lock, and uses a default */
-/* global allocation state. */
-GC_PTR GC_copying_malloc(GC_copy_descriptor);
-
-/* A variant of the above that does no locking on the fast path, */
-/* and passes an explicit pointer to an allocation state. */
-/* The allocation state is updated. */
-/* There will eventually need to be a macro or inline function version */
-/* of this. */
-GC_PTR GC_copying_malloc2(GC_copy_descriptor, GC_copy_alloc_state *);
-
-/* Initialize an allocation state so that it can be used for */
-/* allocation. This implicitly reserves a small section of the */
-/* nursery for use with this allocator. */
-void GC_init_copy_alloc_state(GC_copy_alloc_state *);
diff --git a/include/new_gc_alloc.h b/include/new_gc_alloc.h
index 54b7bd44..66f83236 100644
--- a/include/new_gc_alloc.h
+++ b/include/new_gc_alloc.h
@@ -43,6 +43,9 @@
// problems. The argument for changing it is that the usual default
// allocator is usually a very bad choice for a garbage collected environment.)
//
+// This code assumes that the collector itself has been compiled with a
+// compiler that defines __STDC__ .
+//
#ifndef GC_ALLOC_H
diff --git a/dbg_mlc.h b/include/private/dbg_mlc.h
index 6abeda8a..046464ed 100644
--- a/dbg_mlc.h
+++ b/include/private/dbg_mlc.h
@@ -29,7 +29,7 @@
# define I_HIDE_POINTERS
# include "gc_priv.h"
# ifdef KEEP_BACK_PTRS
-# include "backptr.h"
+# include "gc_backptr.h"
# endif
# define START_FLAG ((word)0xfedcedcb)
@@ -56,8 +56,10 @@ typedef struct {
# ifdef NEED_CALLINFO
struct callinfo oh_ci[NFRAMES];
# endif
- word oh_sz; /* Original malloc arg. */
- word oh_sf; /* start flag */
+# ifndef SHORT_DBG_HDRS
+ word oh_sz; /* Original malloc arg. */
+ word oh_sf; /* start flag */
+# endif /* SHORT_DBG_HDRS */
} oh;
/* The size of the above structure is assumed not to dealign things, */
/* and to be a multiple of the word length. */
@@ -93,7 +95,11 @@ typedef struct {
/* Check whether object with base pointer p has debugging info */
/* p is assumed to point to a legitimate object in our part */
/* of the heap. */
-GC_bool GC_has_debug_info(/* p */);
+#ifdef SHORT_DBG_HDRS
+# define GC_has_debug_info(p) TRUE
+#else
+ GC_bool GC_has_debug_info(/* p */);
+#endif
/* Store debugging info into p. Return displaced pointer. */
/* Assumes we don't hold allocation lock. */
diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h
new file mode 100644
index 00000000..e5f692a0
--- /dev/null
+++ b/include/private/gc_locks.h
@@ -0,0 +1,445 @@
+/*
+ * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
+ * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
+ * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
+ * Copyright (c) 1999 by Hewlett-Packard Company. All rights reserved.
+ *
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#ifndef GC_LOCKS_H
+#define GC_LOCKS_H
+
+/*
+ * Mutual exclusion between allocator/collector routines.
+ * Needed if there is more than one allocator thread.
+ * FASTLOCK() is assumed to try to acquire the lock in a cheap and
+ * dirty way that is acceptable for a few instructions, e.g. by
+ * inhibiting preemption. This is assumed to have succeeded only
+ * if a subsequent call to FASTLOCK_SUCCEEDED() returns TRUE.
+ * FASTUNLOCK() is called whether or not FASTLOCK_SUCCEEDED().
+ * If signals cannot be tolerated with the FASTLOCK held, then
+ * FASTLOCK should disable signals. The code executed under
+ * FASTLOCK is otherwise immune to interruption, provided it is
+ * not restarted.
+ * DCL_LOCK_STATE declares any local variables needed by LOCK and UNLOCK
+ * and/or DISABLE_SIGNALS and ENABLE_SIGNALS and/or FASTLOCK.
+ * (There is currently no equivalent for FASTLOCK.)
+ *
+ * In the PARALLEL_MARK case, we also need to define a number of
+ * other inline finctions here:
+ * GC_bool GC_compare_and_exchange( volatile GC_word *addr,
+ * GC_word old, GC_word new )
+ * GC_word GC_atomic_add( volatile GC_word *addr, GC_word how_much )
+ * void GC_memory_barrier( )
+ *
+ */
+# ifdef THREADS
+# ifdef PCR_OBSOLETE /* Faster, but broken with multiple lwp's */
+# include "th/PCR_Th.h"
+# include "th/PCR_ThCrSec.h"
+ extern struct PCR_Th_MLRep GC_allocate_ml;
+# define DCL_LOCK_STATE PCR_sigset_t GC_old_sig_mask
+# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
+# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
+# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
+# define FASTLOCK() PCR_ThCrSec_EnterSys()
+ /* Here we cheat (a lot): */
+# define FASTLOCK_SUCCEEDED() (*(int *)(&GC_allocate_ml) == 0)
+ /* TRUE if nobody currently holds the lock */
+# define FASTUNLOCK() PCR_ThCrSec_ExitSys()
+# endif
+# ifdef PCR
+# include <base/PCR_Base.h>
+# include <th/PCR_Th.h>
+ extern PCR_Th_ML GC_allocate_ml;
+# define DCL_LOCK_STATE \
+ PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask
+# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
+# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
+# define FASTLOCK() (GC_fastLockRes = PCR_Th_ML_Try(&GC_allocate_ml))
+# define FASTLOCK_SUCCEEDED() (GC_fastLockRes == PCR_ERes_okay)
+# define FASTUNLOCK() {\
+ if( FASTLOCK_SUCCEEDED() ) PCR_Th_ML_Release(&GC_allocate_ml); }
+# endif
+# ifdef SRC_M3
+ extern GC_word RT0u__inCritical;
+# define LOCK() RT0u__inCritical++
+# define UNLOCK() RT0u__inCritical--
+# endif
+# ifdef SOLARIS_THREADS
+# include <thread.h>
+# include <signal.h>
+ extern mutex_t GC_allocate_ml;
+# define LOCK() mutex_lock(&GC_allocate_ml);
+# define UNLOCK() mutex_unlock(&GC_allocate_ml);
+# endif
+# if defined(LINUX_THREADS)
+# define NO_THREAD (pthread_t)(-1)
+# if defined(I386)|| defined(POWERPC) || defined(ALPHA) || defined(IA64) \
+ || defined(M68K) || defined(SPARC)
+# include <pthread.h>
+# if defined(PARALLEL_MARK)
+ /* We need compare-and-swap to update mark bits, where it's */
+ /* performance critical. If USE_MARK_BYTES is defined, it is */
+ /* no longer needed for this purpose. However we use it in */
+ /* either case to implement atomic fetch-and-add, though that's */
+ /* less performance critical, and could perhaps be done with */
+ /* a lock. */
+# if defined(GENERIC_COMPARE_AND_SWAP)
+ /* Probably not useful, except for debugging. */
+ extern pthread_mutex_t GC_compare_and_swap_lock;
+
+ static GC_bool GC_compare_and_exchange(volatile GC_word *addr,
+ GC_word old, GC_word new_val)
+ {
+ GC_bool result;
+ pthread_mutex_lock(&GC_compare_and_swap_lock);
+ if (*addr == old) {
+ *addr = new_val;
+ result = TRUE;
+ } else {
+ result = FALSE;
+ }
+ pthread_mutex_unlock(&GC_compare_and_swap_lock);
+ return result;
+ }
+# endif /* GENERIC_COMPARE_AND_SWAP */
+# if defined(I386)
+# if !defined(GENERIC_COMPARE_AND_SWAP)
+ /* Returns TRUE if the comparison succeeded. */
+ inline static GC_bool GC_compare_and_exchange(volatile GC_word *addr,
+ GC_word old,
+ GC_word new_val)
+ {
+ char result;
+ __asm__ __volatile__("lock; cmpxchgl %2, %0; setz %1"
+ : "=m"(*(addr)), "=r"(result)
+ : "r" (new_val), "0"(*(addr)), "a"(old));
+ return (GC_bool) result;
+ }
+# endif /* !GENERIC_COMPARE_AND_SWAP */
+ inline static void GC_memory_barrier()
+ {
+ /* We believe the processor ensures at least processor */
+ /* consistent ordering. Thus a compiler barrier */
+ /* should suffice. */
+ __asm__ __volatile__("" : : : "memory");
+ }
+# endif
+# if defined(IA64)
+# if !defined(GENERIC_COMPARE_AND_SWAP)
+ inline static GC_bool GC_compare_and_exchange(volatile GC_word *addr,
+ GC_word old, GC_word new_val)
+ {
+ unsigned long oldval;
+ __asm__ __volatile__("mov ar.ccv=%4 ;; cmpxchg8.rel %0=%1,%2,ar.ccv"
+ : "=r"(oldval), "=m"(*addr)
+ : "r"(new_val), "1"(*addr), "r"(old));
+ return (oldval == old);
+ }
+# endif /* !GENERIC_COMPARE_AND_SWAP */
+ inline static void GC_memory_barrier()
+ {
+ __asm__ __volatile__("mf" : : : "memory");
+ }
+# endif /* IA64 */
+ /* Returns the original value of *addr. */
+ inline static GC_word GC_atomic_add(volatile GC_word *addr, GC_word how_much)
+ {
+ GC_word old;
+ do {
+ old = *addr;
+ } while (!GC_compare_and_exchange(addr, old, old+how_much));
+ return old;
+ }
+# endif /* PARALLEL_MARK */
+# ifndef THREAD_LOCAL_ALLOC
+ /* In the THREAD_LOCAL_ALLOC case, the allocation lock tends to */
+ /* be held for long periods, if it is held at all. Thus spinning */
+ /* and sleeping for fixed periods are likely to result in */
+ /* significant wasted time. We thus rely mostly on queued locks. */
+# define USE_SPIN_LOCK
+# if defined(I386)
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ int oldval;
+ /* Note: the "xchg" instruction does not need a "lock" prefix */
+ __asm__ __volatile__("xchgl %0, %1"
+ : "=r"(oldval), "=m"(*(addr))
+ : "0"(1), "m"(*(addr)));
+ return oldval;
+ }
+# endif
+# if defined(IA64)
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ long oldval, n = 1;
+ __asm__ __volatile__("xchg4 %0=%1,%2"
+ : "=r"(oldval), "=m"(*addr)
+ : "r"(n), "1"(*addr));
+ return oldval;
+ }
+ inline static void GC_clear(volatile unsigned int *addr) {
+ __asm__ __volatile__("st4.rel %0=r0" : "=m" (*addr));
+ }
+# define GC_CLEAR_DEFINED
+# endif
+# ifdef SPARC
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ int oldval;
+
+ __asm__ __volatile__("ldstub %1,%0"
+ : "=r"(oldval), "=m"(*addr)
+ : "m"(*addr));
+ return oldval;
+ }
+# endif
+# ifdef M68K
+ /* Contributed by Tony Mantler. I'm not sure how well it was */
+ /* tested. */
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ char oldval; /* this must be no longer than 8 bits */
+
+ /* The return value is semi-phony. */
+ /* 'tas' sets bit 7 while the return */
+ /* value pretends bit 0 was set */
+ __asm__ __volatile__(
+ "tas %1@; sne %0; negb %0"
+ : "=d" (oldval)
+ : "a" (addr));
+ return oldval;
+ }
+# endif
+# if defined(POWERPC)
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ int oldval;
+ int temp = 1; // locked value
+
+ __asm__ __volatile__(
+ "1:\tlwarx %0,0,%3\n" // load and reserve
+ "\tcmpwi %0, 0\n" // if load is
+ "\tbne 2f\n" // non-zero, return already set
+ "\tstwcx. %2,0,%1\n" // else store conditional
+ "\tbne- 1b\n" // retry if lost reservation
+ "2:\t\n" // oldval is zero if we set
+ : "=&r"(oldval), "=p"(addr)
+ : "r"(temp), "1"(addr)
+ : "memory");
+ return (int)oldval;
+ }
+ inline static void GC_clear(volatile unsigned int *addr) {
+ __asm__ __volatile__("eieio");
+ *(addr) = 0;
+ }
+# define GC_CLEAR_DEFINED
+# endif
+# ifdef ALPHA
+ inline static int GC_test_and_set(volatile unsigned int * addr)
+ {
+ unsigned long oldvalue;
+ unsigned long temp;
+
+ __asm__ __volatile__(
+ "1: ldl_l %0,%1\n"
+ " and %0,%3,%2\n"
+ " bne %2,2f\n"
+ " xor %0,%3,%0\n"
+ " stl_c %0,%1\n"
+ " beq %0,3f\n"
+ " mb\n"
+ "2:\n"
+ ".section .text2,\"ax\"\n"
+ "3: br 1b\n"
+ ".previous"
+ :"=&r" (temp), "=m" (*addr), "=&r" (oldvalue)
+ :"Ir" (1), "m" (*addr));
+
+ return oldvalue;
+ }
+ /* Should probably also define GC_clear, since it needs */
+ /* a memory barrier ?? */
+# endif /* ALPHA */
+# ifdef ARM32
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ int oldval;
+ /* SWP on ARM is very similar to XCHG on x86. Doesn't lock the
+ * bus because there are no SMP ARM machines. If/when there are,
+ * this code will likely need to be updated. */
+ /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */
+ __asm__ __volatile__("swp %0, %1, [%2]"
+ : "=r"(oldval)
+ : "r"(1), "r"(addr));
+ return oldval;
+ }
+# endif /* ARM32 */
+# ifndef GC_CLEAR_DEFINED
+ inline static void GC_clear(volatile unsigned int *addr) {
+ /* Try to discourage gcc from moving anything past this. */
+ __asm__ __volatile__(" ");
+ *(addr) = 0;
+ }
+# endif /* !GC_CLEAR_DEFINED */
+
+ extern volatile unsigned int GC_allocate_lock;
+ extern void GC_lock(void);
+ /* Allocation lock holder. Only set if acquired by client through */
+ /* GC_call_with_alloc_lock. */
+# ifdef GC_ASSERTIONS
+# define LOCK() \
+ { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); \
+ SET_LOCK_HOLDER(); }
+# define UNLOCK() \
+ { GC_ASSERT(I_HOLD_LOCK()); UNSET_LOCK_HOLDER(); \
+ GC_clear(&GC_allocate_lock); }
+# else
+# define LOCK() \
+ { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); }
+# define UNLOCK() \
+ GC_clear(&GC_allocate_lock)
+# endif /* !GC_ASSERTIONS */
+# else /* THREAD_LOCAL_ALLOC */
+# define USE_PTHREAD_LOCKS
+# endif /* THREAD_LOCAL_ALLOC */
+# else /* LINUX_THREADS on hardware for which we don't know how */
+ /* to do test and set. */
+# define USE_PTHREAD_LOCKS
+# endif /* ! known hardware */
+# ifdef USE_PTHREAD_LOCKS
+# include <pthread.h>
+ extern pthread_mutex_t GC_allocate_ml;
+# ifdef GC_ASSERTIONS
+# define LOCK() \
+ { GC_lock(); \
+ SET_LOCK_HOLDER(); }
+# define UNLOCK() \
+ { GC_ASSERT(I_HOLD_LOCK()); UNSET_LOCK_HOLDER(); \
+ pthread_mutex_unlock(&GC_allocate_ml); }
+# else /* !GC_ASSERTIONS */
+# define LOCK() \
+ { if (0 != pthread_mutex_trylock(&GC_allocate_ml)) GC_lock(); }
+# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
+# endif /* !GC_ASSERTIONS */
+# endif /* USE_PTHREAD_LOCKS */
+# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
+# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
+# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
+ extern VOLATILE GC_bool GC_collecting;
+# define ENTER_GC() GC_collecting = 1;
+# define EXIT_GC() GC_collecting = 0;
+ extern void GC_lock(void);
+ extern pthread_t GC_lock_holder;
+# ifdef GC_ASSERTIONS
+ extern pthread_t GC_mark_lock_holder;
+# endif
+# endif /* LINUX_THREADS */
+# if defined(HPUX_THREADS)
+# include <pthread.h>
+ extern pthread_mutex_t GC_allocate_ml;
+# define NO_THREAD (pthread_t)(-1)
+# define LOCK() pthread_mutex_lock(&GC_allocate_ml)
+# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
+# endif
+# if defined(IRIX_THREADS)
+ /* This may also eventually be appropriate for HPUX_THREADS */
+# include <pthread.h>
+# ifndef HPUX_THREADS
+ /* This probably should never be included, but I can't test */
+ /* on Irix anymore. */
+# include <mutex.h>
+# endif
+
+# ifndef HPUX_THREADS
+# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) \
+ || !defined(_COMPILER_VERSION) || _COMPILER_VERSION < 700
+# define GC_test_and_set(addr, v) test_and_set(addr,v)
+# else
+# define GC_test_and_set(addr, v) __test_and_set(addr,v)
+# endif
+# else
+ /* I couldn't find a way to do this inline on HP/UX */
+# endif
+ extern unsigned long GC_allocate_lock;
+ /* This is not a mutex because mutexes that obey the (optional) */
+ /* POSIX scheduling rules are subject to convoys in high contention */
+ /* applications. This is basically a spin lock. */
+ extern pthread_t GC_lock_holder;
+ extern void GC_lock(void);
+ /* Allocation lock holder. Only set if acquired by client through */
+ /* GC_call_with_alloc_lock. */
+# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
+# define NO_THREAD (pthread_t)(-1)
+# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
+# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
+# ifdef HPUX_THREADS
+# define LOCK() { if (!GC_test_and_clear(&GC_allocate_lock)) GC_lock(); }
+ /* The following is INCORRECT, since the memory model is too weak. */
+# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
+ *(volatile unsigned long *)(&GC_allocate_lock) = 1; }
+# else
+# define LOCK() { if (GC_test_and_set(&GC_allocate_lock, 1)) GC_lock(); }
+# if __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) \
+ && defined(_COMPILER_VERSION) && _COMPILER_VERSION >= 700
+# define UNLOCK() __lock_release(&GC_allocate_lock)
+# else
+ /* The function call in the following should prevent the */
+ /* compiler from moving assignments to below the UNLOCK. */
+ /* This is probably not necessary for ucode or gcc 2.8. */
+ /* It may be necessary for Ragnarok and future gcc */
+ /* versions. */
+# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
+ *(volatile unsigned long *)(&GC_allocate_lock) = 0; }
+# endif
+# endif
+ extern VOLATILE GC_bool GC_collecting;
+# define ENTER_GC() \
+ { \
+ GC_collecting = 1; \
+ }
+# define EXIT_GC() GC_collecting = 0;
+# endif /* IRIX_THREADS */
+# ifdef WIN32_THREADS
+# include <windows.h>
+ GC_API CRITICAL_SECTION GC_allocate_ml;
+# define LOCK() EnterCriticalSection(&GC_allocate_ml);
+# define UNLOCK() LeaveCriticalSection(&GC_allocate_ml);
+# endif
+# ifndef SET_LOCK_HOLDER
+# define SET_LOCK_HOLDER()
+# define UNSET_LOCK_HOLDER()
+# define I_HOLD_LOCK() FALSE
+ /* Used on platforms were locks can be reacquired, */
+ /* so it doesn't matter if we lie. */
+# endif
+# else /* !THREADS */
+# define LOCK()
+# define UNLOCK()
+# endif /* !THREADS */
+# ifndef SET_LOCK_HOLDER
+# define SET_LOCK_HOLDER()
+# define UNSET_LOCK_HOLDER()
+# define I_HOLD_LOCK() FALSE
+ /* Used on platforms were locks can be reacquired, */
+ /* so it doesn't matter if we lie. */
+# endif
+# ifndef ENTER_GC
+# define ENTER_GC()
+# define EXIT_GC()
+# endif
+
+# ifndef DCL_LOCK_STATE
+# define DCL_LOCK_STATE
+# endif
+# ifndef FASTLOCK
+# define FASTLOCK() LOCK()
+# define FASTLOCK_SUCCEEDED() TRUE
+# define FASTUNLOCK() UNLOCK()
+# endif
+
+#endif /* GC_LOCKS_H */
diff --git a/gc_mark.h b/include/private/gc_mark.h
index 3a4908fb..dddb20ce 100644
--- a/gc_mark.h
+++ b/include/private/gc_mark.h
@@ -41,6 +41,11 @@
/* Currently we require that mark procedures look for pointers in a */
/* subset of the places the conservative marker would. It must be safe */
/* to invoke the normal mark procedure instead. */
+/* WARNING: Such a mark procedure may be invoked on an unused object */
+/* residing on a free list. Such objects are cleared, except for a */
+/* free list link field in the first word. Thus mark procedures may */
+/* not count on the presence of a type descriptor, and must handle this */
+/* case correctly somehow. */
# define PROC_BYTES 100
/* The real declarations of the following are in gc_priv.h, so that */
/* we can avoid scanning the following table. */
@@ -57,6 +62,9 @@ extern mark_proc GC_mark_procs[MAX_MARK_PROCS];
extern word GC_n_mark_procs;
+/* Number of mark stack entries to discard on overflow. */
+#define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8)
+
/* In a few cases it's necessary to assign statically known indices to */
/* certain mark procs. Thus we reserve a few for well known clients. */
/* (This is necessary if mark descriptors are compiler generated.) */
@@ -113,10 +121,68 @@ typedef struct ms_entry {
extern word GC_mark_stack_size;
-extern mse * GC_mark_stack_top;
+#ifdef PARALLEL_MARK
+ extern mse * VOLATILE GC_mark_stack_top;
+#else
+ extern mse * GC_mark_stack_top;
+#endif
extern mse * GC_mark_stack;
+#ifdef PARALLEL_MARK
+ /*
+ * Allow multiple threads to participate in the marking process.
+ * This works roughly as follows:
+ * The main mark stack never shrinks, but it can grow.
+ *
+ * The initiating threads holds the GC lock, and sets GC_help_wanted.
+ *
+ * Other threads:
+ * 1) update helper_count (while holding mark_lock.)
+ * 2) allocate a local mark stack
+ * repeatedly:
+ * 3) Steal a global mark stack entry by atomically replacing
+ * its descriptor with 0.
+ * 4) Copy it to the local stack.
+ * 5) Mark on the local stack until it is empty, or
+ * it may be profitable to copy it back.
+ * 6) If necessary, copy local stack to global one,
+ * holding mark lock.
+ * 7) Stop when the global mark stack is empty.
+ * 8) decrement helper_count (holding mark_lock).
+ *
+ * This is an experiment to see if we can do something along the lines
+ * of the University of Tokyo SGC in a less intrusive, though probably
+ * also less performant, way.
+ */
+ void GC_do_parallel_mark();
+ /* inititate parallel marking. */
+
+ extern GC_bool GC_help_wanted; /* Protected by mark lock */
+ extern unsigned GC_helper_count; /* Number of running helpers. */
+ /* Protected by mark lock */
+ extern unsigned GC_active_count; /* Number of active helpers. */
+ /* Protected by mark lock */
+ /* May increase and decrease */
+ /* within each mark cycle. But */
+ /* once it returns to 0, it */
+ /* stays zero for the cycle. */
+ /* GC_mark_stack_top is also protected by mark lock. */
+ extern mse * VOLATILE GC_first_nonempty;
+ /* Lowest entry on mark stack */
+ /* that may be nonempty. */
+ /* Updated only by initiating */
+ /* thread. */
+ /*
+ * GC_notify_all_marker() is used when GC_help_wanted is first set,
+ * when the last helper becomes inactive,
+ * when something is added to the global mark stack, and just after
+ * GC_mark_no is incremented.
+ * This could be split into multiple CVs (and probably should be to
+ * scale to really large numbers of processors.)
+ */
+#endif /* PARALLEL_MARK */
+
ptr_t GC_find_start();
mse * GC_signal_mark_stack_overflow();
@@ -211,6 +277,32 @@ exit_label1: ; \
exit_label2: ; \
}
+/* Set mark bit, exit if it was already set. */
+
+# ifdef USE_MARK_BYTES
+ /* Unlike the mark bit case, there is a race here, and we may set */
+ /* the bit twice in the concurrent case. This can result in the */
+ /* object being pushed twice. But that's only a performance issue. */
+# define SET_MARK_BIT_EXIT_IF_SET(hhdr,displ,exit_label) \
+ { \
+ register VOLATILE char * mark_byte_addr = \
+ hhdr -> hb_marks + ((displ) >> 1); \
+ register char mark_byte = *mark_byte_addr; \
+ \
+ if (mark_byte) goto exit_label; \
+ *mark_byte_addr = 1; \
+ }
+# else
+# define SET_MARK_BIT_EXIT_IF_SET(hhdr,displ,exit_label) \
+ { \
+ register word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(displ); \
+ register word mark_word = *mark_word_addr; \
+ \
+ OR_WORD_EXIT_IF_SET(mark_word_addr, (word)1 << modWORDSZ(displ), \
+ exit_label); \
+ }
+# endif /* USE_MARK_BYTES */
+
# define PUSH_CONTENTS_HDR(current, mark_stack_top, mark_stack_limit, \
source, exit_label, hhdr) \
{ \
@@ -220,24 +312,13 @@ exit_label2: ; \
displ = HBLKDISPL(current); \
map_entry = MAP_ENTRY((hhdr -> hb_map), displ); \
if (map_entry == OBJ_INVALID) { \
- GC_ADD_TO_BLACK_LIST_NORMAL(current, source); goto exit_label; \
+ GC_ADD_TO_BLACK_LIST_NORMAL((word)current, source); goto exit_label; \
} \
displ = BYTES_TO_WORDS(displ); \
displ -= map_entry; \
- \
- { \
- register word * mark_word_addr = hhdr -> hb_marks + divWORDSZ(displ); \
- register word mark_word = *mark_word_addr; \
- register word mark_bit = (word)1 << modWORDSZ(displ); \
- \
- if (mark_word & mark_bit) { \
- /* Mark bit is already set */ \
- goto exit_label; \
- } \
- GC_STORE_BACK_PTR((ptr_t)source, (ptr_t)HBLKPTR(current) \
+ SET_MARK_BIT_EXIT_IF_SET(hhdr, displ, exit_label); \
+ GC_STORE_BACK_PTR((ptr_t)source, (ptr_t)HBLKPTR(current) \
+ WORDS_TO_BYTES(displ)); \
- *mark_word_addr = mark_word | mark_bit; \
- } \
PUSH_OBJ(((word *)(HBLKPTR(current)) + displ), hhdr, \
mark_stack_top, mark_stack_limit) \
}
@@ -277,6 +358,17 @@ exit_label2: ; \
PUSH_ONE_CHECKED(p,AIP,source); \
}
+/* Mark starting at mark stack entry top (incl.) down to */
+/* mark stack entry bottom (incl.). Stop after performing */
+/* about one page worth of work. Return the new mark stack */
+/* top entry. */
+mse * GC_mark_from GC_PROTO((mse * top, mse * bottom, mse *limit));
+
+#define MARK_FROM_MARK_STACK() \
+ GC_mark_stack_top = GC_mark_from(GC_mark_stack_top, \
+ GC_mark_stack, \
+ GC_mark_stack + GC_mark_stack_size);
+
/*
* Mark from one finalizable object using the specified
* mark proc. May not mark the object pointed to by
@@ -285,7 +377,7 @@ exit_label2: ; \
# define GC_MARK_FO(real_ptr, mark_proc) \
{ \
(*(mark_proc))(real_ptr); \
- while (!GC_mark_stack_empty()) GC_mark_from_mark_stack(); \
+ while (!GC_mark_stack_empty()) MARK_FROM_MARK_STACK(); \
if (GC_mark_state != MS_NONE) { \
GC_set_mark_bit(real_ptr); \
while (!GC_mark_some((ptr_t)0)); \
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index ce685875..cc23d342 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -14,7 +14,6 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, February 16, 1996 2:30 pm PST */
# ifndef GC_PRIVATE_H
@@ -74,7 +73,9 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
# define VOLATILE
#endif
-#define CONST GC_CONST
+# ifndef GC_LOCKS_H
+# include "gc_locks.h"
+# endif
#if 0 /* was once defined for AMIGA */
# define GC_FAR __far
@@ -174,6 +175,12 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* May save significant amounts of space for obj_map */
/* entries. */
+#if defined(USE_MARK_BYTES) && !defined(ALIGN_DOUBLE)
+# define ALIGN_DOUBLE
+ /* We use one byte for every 2 words, which doesn't allow for */
+ /* odd numbered words to have mark bits. */
+#endif
+
/* ALIGN_DOUBLE requires MERGE_SIZES at present. */
# if defined(ALIGN_DOUBLE) && !defined(MERGE_SIZES)
# define MERGE_SIZES
@@ -228,9 +235,10 @@ typedef char * ptr_t; /* A generic pointer to which we can add */
/* Fill in the pc and argument information for up to NFRAMES of my */
/* callers. Ignore my frame and my callers frame. */
-void GC_save_callers (/* struct callinfo info[NFRAMES] */);
-
-void GC_print_callers (/* struct callinfo info[NFRAMES] */);
+struct callinfo;
+void GC_save_callers GC_PROTO((struct callinfo info[NFRAMES]));
+
+void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
#else
@@ -244,7 +252,7 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
#ifdef NEED_CALLINFO
struct callinfo {
- word ci_pc;
+ word ci_pc; /* Caller, not callee, pc */
# if NARGS > 0
word ci_arg[NARGS]; /* bit-wise complement to avoid retention */
# endif
@@ -273,13 +281,13 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
# define MS_TIME_DIFF(a,b) ((double) (a.tv_sec - b.tv_sec) * 1000.0 \
+ (double) (a.tv_usec - b.tv_usec) / 1000.0)
#else /* !BSD_TIME */
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# include <windows.h>
# include <winbase.h>
# define CLOCK_TYPE DWORD
# define GET_TIME(x) x = GetTickCount()
# define MS_TIME_DIFF(a,b) ((long)((a)-(b)))
-# else /* !MSWIN32, !BSD_TIME */
+# else /* !MSWIN32, !MSWINCE, !BSD_TIME */
# include <time.h>
# if !defined(__STDC__) && defined(SPARC) && defined(SUNOS4)
clock_t clock(); /* Not in time.h, where it belongs */
@@ -325,6 +333,9 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
# include <string.h>
# define BCOPY_EXISTS
# endif
+# if defined(MACOSX)
+# define BCOPY_EXISTS
+# endif
# ifndef BCOPY_EXISTS
# include <string.h>
@@ -342,6 +353,7 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
/* GET_MEM is currently not assumed to retrieve 0 filled space, */
/* though we should perhaps take advantage of the case in which */
/* does. */
+struct hblk; /* See below. */
# ifdef PCR
char * real_malloc();
# define GET_MEM(bytes) HBLKPTR(real_malloc((size_t)bytes + GC_page_size) \
@@ -374,312 +386,19 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
NewPtrClear(bytes + GC_page_size) + GC_page_size-1)
# endif
# else
+# ifdef MSWINCE
+ extern ptr_t GC_wince_get_mem();
+# define GET_MEM(bytes) (struct hblk *)GC_wince_get_mem(bytes)
+# else
extern ptr_t GC_unix_get_mem();
# define GET_MEM(bytes) (struct hblk *)GC_unix_get_mem(bytes)
+# endif
# endif
# endif
# endif
# endif
# endif
-/*
- * Mutual exclusion between allocator/collector routines.
- * Needed if there is more than one allocator thread.
- * FASTLOCK() is assumed to try to acquire the lock in a cheap and
- * dirty way that is acceptable for a few instructions, e.g. by
- * inhibiting preemption. This is assumed to have succeeded only
- * if a subsequent call to FASTLOCK_SUCCEEDED() returns TRUE.
- * FASTUNLOCK() is called whether or not FASTLOCK_SUCCEEDED().
- * If signals cannot be tolerated with the FASTLOCK held, then
- * FASTLOCK should disable signals. The code executed under
- * FASTLOCK is otherwise immune to interruption, provided it is
- * not restarted.
- * DCL_LOCK_STATE declares any local variables needed by LOCK and UNLOCK
- * and/or DISABLE_SIGNALS and ENABLE_SIGNALS and/or FASTLOCK.
- * (There is currently no equivalent for FASTLOCK.)
- */
-# ifdef THREADS
-# ifdef PCR_OBSOLETE /* Faster, but broken with multiple lwp's */
-# include "th/PCR_Th.h"
-# include "th/PCR_ThCrSec.h"
- extern struct PCR_Th_MLRep GC_allocate_ml;
-# define DCL_LOCK_STATE PCR_sigset_t GC_old_sig_mask
-# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
-# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
-# define FASTLOCK() PCR_ThCrSec_EnterSys()
- /* Here we cheat (a lot): */
-# define FASTLOCK_SUCCEEDED() (*(int *)(&GC_allocate_ml) == 0)
- /* TRUE if nobody currently holds the lock */
-# define FASTUNLOCK() PCR_ThCrSec_ExitSys()
-# endif
-# ifdef PCR
-# include <base/PCR_Base.h>
-# include <th/PCR_Th.h>
- extern PCR_Th_ML GC_allocate_ml;
-# define DCL_LOCK_STATE \
- PCR_ERes GC_fastLockRes; PCR_sigset_t GC_old_sig_mask
-# define LOCK() PCR_Th_ML_Acquire(&GC_allocate_ml)
-# define UNLOCK() PCR_Th_ML_Release(&GC_allocate_ml)
-# define FASTLOCK() (GC_fastLockRes = PCR_Th_ML_Try(&GC_allocate_ml))
-# define FASTLOCK_SUCCEEDED() (GC_fastLockRes == PCR_ERes_okay)
-# define FASTUNLOCK() {\
- if( FASTLOCK_SUCCEEDED() ) PCR_Th_ML_Release(&GC_allocate_ml); }
-# endif
-# ifdef SRC_M3
- extern word RT0u__inCritical;
-# define LOCK() RT0u__inCritical++
-# define UNLOCK() RT0u__inCritical--
-# endif
-# ifdef SOLARIS_THREADS
-# include <thread.h>
-# include <signal.h>
- extern mutex_t GC_allocate_ml;
-# define LOCK() mutex_lock(&GC_allocate_ml);
-# define UNLOCK() mutex_unlock(&GC_allocate_ml);
-# endif
-# if defined(LINUX_THREADS)
-# if defined(I386)|| defined(POWERPC) || defined(ALPHA) || defined(IA64) \
- || defined(M68K)
-# include <pthread.h>
-# define USE_SPIN_LOCK
-# if defined(I386)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- /* Note: the "xchg" instruction does not need a "lock" prefix */
- __asm__ __volatile__("xchgl %0, %1"
- : "=r"(oldval), "=m"(*(addr))
- : "0"(1), "m"(*(addr)));
- return oldval;
- }
-# endif
-# if defined(IA64)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- __asm__ __volatile__("xchg4 %0=%1,%2"
- : "=r"(oldval), "=m"(*addr)
- : "r"(1), "1"(*addr));
- return oldval;
- }
- inline static void GC_clear(volatile unsigned int *addr) {
- __asm__ __volatile__("st4.rel %0=r0" : "=m" (*addr));
- }
-# define GC_CLEAR_DEFINED
-# endif
-# ifdef M68K
- /* Contributed by Tony Mantler. I'm not sure how well it was */
- /* tested. */
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- char oldval; /* this must be no longer than 8 bits */
-
- /* The return value is semi-phony. */
- /* 'tas' sets bit 7 while the return */
- /* value pretends bit 0 was set */
- __asm__ __volatile__(
- "tas %1@; sne %0; negb %0"
- : "=d" (oldval)
- : "a" (addr));
- return oldval;
- }
-# endif
-# if defined(POWERPC)
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- int temp = 1; // locked value
-
- __asm__ __volatile__(
- "1:\tlwarx %0,0,%3\n" // load and reserve
- "\tcmpwi %0, 0\n" // if load is
- "\tbne 2f\n" // non-zero, return already set
- "\tstwcx. %2,0,%1\n" // else store conditional
- "\tbne- 1b\n" // retry if lost reservation
- "2:\t\n" // oldval is zero if we set
- : "=&r"(oldval), "=p"(addr)
- : "r"(temp), "1"(addr)
- : "memory");
- return (int)oldval;
- }
- inline static void GC_clear(volatile unsigned int *addr) {
- __asm__ __volatile__("eieio");
- *(addr) = 0;
- }
-# define GC_CLEAR_DEFINED
-# endif
-# ifdef ALPHA
- inline static int GC_test_and_set(volatile unsigned int * addr)
- {
- unsigned long oldvalue;
- unsigned long temp;
-
- __asm__ __volatile__(
- "1: ldl_l %0,%1\n"
- " and %0,%3,%2\n"
- " bne %2,2f\n"
- " xor %0,%3,%0\n"
- " stl_c %0,%1\n"
- " beq %0,3f\n"
- " mb\n"
- "2:\n"
- ".section .text2,\"ax\"\n"
- "3: br 1b\n"
- ".previous"
- :"=&r" (temp), "=m" (*addr), "=&r" (oldvalue)
- :"Ir" (1), "m" (*addr));
-
- return oldvalue;
- }
- /* Should probably also define GC_clear, since it needs */
- /* a memory barrier ?? */
-# endif /* ALPHA */
-# ifdef ARM32
- inline static int GC_test_and_set(volatile unsigned int *addr) {
- int oldval;
- /* SWP on ARM is very similar to XCHG on x86. Doesn't lock the
- * bus because there are no SMP ARM machines. If/when there are,
- * this code will likely need to be updated. */
- /* See linuxthreads/sysdeps/arm/pt-machine.h in glibc-2.1 */
- __asm__ __volatile__("swp %0, %1, [%2]"
- : "=r"(oldval)
- : "r"(1), "r"(addr));
- return oldval;
- }
-# endif
-# ifndef GC_CLEAR_DEFINED
- inline static void GC_clear(volatile unsigned int *addr) {
- /* Try to discourage gcc from moving anything past this. */
- __asm__ __volatile__(" ");
- *(addr) = 0;
- }
-# endif
-
- extern volatile unsigned int GC_allocate_lock;
- extern pthread_t GC_lock_holder;
- extern void GC_lock(void);
- /* Allocation lock holder. Only set if acquired by client through */
- /* GC_call_with_alloc_lock. */
-# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
-# define NO_THREAD (pthread_t)(-1)
-# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
-# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
-# define LOCK() \
- { if (GC_test_and_set(&GC_allocate_lock)) GC_lock(); }
-# define UNLOCK() \
- GC_clear(&GC_allocate_lock)
- extern VOLATILE GC_bool GC_collecting;
-# define ENTER_GC() \
- { \
- GC_collecting = 1; \
- }
-# define EXIT_GC() GC_collecting = 0;
-# else /* LINUX_THREADS on hardware for which we don't know how */
- /* to do test and set. */
-# include <pthread.h>
- extern pthread_mutex_t GC_allocate_ml;
-# define LOCK() pthread_mutex_lock(&GC_allocate_ml)
-# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
-# endif
-# endif /* LINUX_THREADS */
-# if defined(HPUX_THREADS)
-# include <pthread.h>
- extern pthread_mutex_t GC_allocate_ml;
-# define LOCK() pthread_mutex_lock(&GC_allocate_ml)
-# define UNLOCK() pthread_mutex_unlock(&GC_allocate_ml)
-# endif
-# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS)
- /* This may also eventually be appropriate for HPUX_THREADS */
-# include <pthread.h>
-# ifndef HPUX_THREADS
- /* This probably should never be included, but I can't test */
- /* on Irix anymore. */
-# include <mutex.h>
-# endif
-
-# ifndef HPUX_THREADS
-# if __mips < 3 || !(defined (_ABIN32) || defined(_ABI64)) \
- || !defined(_COMPILER_VERSION) || _COMPILER_VERSION < 700
-# define GC_test_and_set(addr, v) test_and_set(addr,v)
-# else
-# define GC_test_and_set(addr, v) __test_and_set(addr,v)
-# endif
-# else
- /* I couldn't find a way to do this inline on HP/UX */
-# endif
- extern unsigned long GC_allocate_lock;
- /* This is not a mutex because mutexes that obey the (optional) */
- /* POSIX scheduling rules are subject to convoys in high contention */
- /* applications. This is basically a spin lock. */
- extern pthread_t GC_lock_holder;
- extern void GC_lock(void);
- /* Allocation lock holder. Only set if acquired by client through */
- /* GC_call_with_alloc_lock. */
-# define SET_LOCK_HOLDER() GC_lock_holder = pthread_self()
-# define NO_THREAD (pthread_t)(-1)
-# define UNSET_LOCK_HOLDER() GC_lock_holder = NO_THREAD
-# define I_HOLD_LOCK() (pthread_equal(GC_lock_holder, pthread_self()))
-# ifdef HPUX_THREADS
-# define LOCK() { if (!GC_test_and_clear(&GC_allocate_lock)) GC_lock(); }
- /* The following is INCORRECT, since the memory model is too weak. */
-# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
- *(volatile unsigned long *)(&GC_allocate_lock) = 1; }
-# else
-# define LOCK() { if (GC_test_and_set(&GC_allocate_lock, 1)) GC_lock(); }
-# if __mips >= 3 && (defined (_ABIN32) || defined(_ABI64)) \
- && defined(_COMPILER_VERSION) && _COMPILER_VERSION >= 700
-# define UNLOCK() __lock_release(&GC_allocate_lock)
-# else
- /* The function call in the following should prevent the */
- /* compiler from moving assignments to below the UNLOCK. */
- /* This is probably not necessary for ucode or gcc 2.8. */
- /* It may be necessary for Ragnarok and future gcc */
- /* versions. */
-# define UNLOCK() { GC_noop1(&GC_allocate_lock); \
- *(volatile unsigned long *)(&GC_allocate_lock) = 0; }
-# endif
-# endif
- extern VOLATILE GC_bool GC_collecting;
-# define ENTER_GC() \
- { \
- GC_collecting = 1; \
- }
-# define EXIT_GC() GC_collecting = 0;
-# endif /* IRIX_THREADS || IRIX_JDK_THREADS */
-# ifdef WIN32_THREADS
-# include <windows.h>
- GC_API CRITICAL_SECTION GC_allocate_ml;
-# define LOCK() EnterCriticalSection(&GC_allocate_ml);
-# define UNLOCK() LeaveCriticalSection(&GC_allocate_ml);
-# endif
-# ifndef SET_LOCK_HOLDER
-# define SET_LOCK_HOLDER()
-# define UNSET_LOCK_HOLDER()
-# define I_HOLD_LOCK() FALSE
- /* Used on platforms were locks can be reacquired, */
- /* so it doesn't matter if we lie. */
-# endif
-# else
-# define LOCK()
-# define UNLOCK()
-# endif
-# ifndef SET_LOCK_HOLDER
-# define SET_LOCK_HOLDER()
-# define UNSET_LOCK_HOLDER()
-# define I_HOLD_LOCK() FALSE
- /* Used on platforms were locks can be reacquired, */
- /* so it doesn't matter if we lie. */
-# endif
-# ifndef ENTER_GC
-# define ENTER_GC()
-# define EXIT_GC()
-# endif
-
-# ifndef DCL_LOCK_STATE
-# define DCL_LOCK_STATE
-# endif
-# ifndef FASTLOCK
-# define FASTLOCK() LOCK()
-# define FASTLOCK_SUCCEEDED() TRUE
-# define FASTUNLOCK() UNLOCK()
-# endif
-
/* Delay any interrupts or signals that may abort this thread. Data */
/* structures are in a consistent state outside this pair of calls. */
/* ANSI C allows both to be empty (though the standard isn't very */
@@ -693,9 +412,9 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
PCR_Th_SetSigMask(&GC_old_sig_mask, NIL)
# else
# if defined(SRC_M3) || defined(AMIGA) || defined(SOLARIS_THREADS) \
- || defined(MSWIN32) || defined(MACOS) || defined(DJGPP) \
- || defined(NO_SIGNALS) || defined(IRIX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(LINUX_THREADS)
+ || defined(MSWIN32) || defined(MSWINCE) || defined(MACOS) \
+ || defined(DJGPP) || defined(NO_SIGNALS) || defined(IRIX_THREADS) \
+ || defined(LINUX_THREADS)
/* Also useful for debugging. */
/* Should probably use thr_sigsetmask for SOLARIS_THREADS. */
# define DISABLE_SIGNALS()
@@ -724,7 +443,7 @@ void GC_print_callers (/* struct callinfo info[NFRAMES] */);
# else
# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \
|| defined(IRIX_THREADS) || defined(LINUX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
+ || defined(HPUX_THREADS)
void GC_stop_world();
void GC_start_world();
# define STOP_WORLD() GC_stop_world()
@@ -840,6 +559,8 @@ extern GC_warn_proc GC_current_warn_proc;
/* max size objects supported by freelist (larger objects may be */
/* allocated, but less efficiently) */
+#define CPP_MAXOBJBYTES (CPP_HBLKSIZE/2)
+#define MAXOBJBYTES ((word)CPP_MAXOBJBYTES)
#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2)
#define MAXOBJSZ ((word)CPP_MAXOBJSZ)
@@ -867,7 +588,7 @@ extern GC_warn_proc GC_current_warn_proc;
# else
# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n)
# endif
-# define SMALL_OBJ(bytes) ((bytes) < WORDS_TO_BYTES(MAXOBJSZ))
+# define SMALL_OBJ(bytes) ((bytes) < MAXOBJBYTES)
# define ADD_SLOP(bytes) ((bytes)+1)
# else
# define ROUNDED_UP_WORDS(n) BYTES_TO_WORDS((n) + (WORDS_TO_BYTES(1) - 1))
@@ -877,9 +598,14 @@ extern GC_warn_proc GC_current_warn_proc;
# else
# define ALIGNED_WORDS(n) ROUNDED_UP_WORDS(n)
# endif
-# define SMALL_OBJ(bytes) ((bytes) <= WORDS_TO_BYTES(MAXOBJSZ))
+# define SMALL_OBJ(bytes) ((bytes) <= MAXOBJBYTES)
# define ADD_SLOP(bytes) (bytes)
# endif
+# ifdef USE_MARK_BYTES
+# define MIN_WORDS 2 /* Smallest allocated object. */
+# else
+# define MIN_WORDS 1
+# endif
/*
@@ -919,20 +645,23 @@ typedef word page_hash_table[PHT_SIZE];
/* heap block header */
#define HBLKMASK (HBLKSIZE-1)
-#define BITS_PER_HBLK (HBLKSIZE * 8)
+#define BITS_PER_HBLK (CPP_HBLKSIZE * 8)
#define MARK_BITS_PER_HBLK (BITS_PER_HBLK/CPP_WORDSZ)
/* upper bound */
- /* We allocate 1 bit/word. Only the first word */
+ /* We allocate 1 bit/word, unless USE_MARK_BYTES */
+ /* is defined. Only the first word */
/* in each object is actually marked. */
-# ifdef ALIGN_DOUBLE
-# define MARK_BITS_SZ (((MARK_BITS_PER_HBLK + 2*CPP_WORDSZ - 1) \
- / (2*CPP_WORDSZ))*2)
+# ifdef USE_MARK_BYTES
+# define MARK_BITS_SZ (MARK_BITS_PER_HBLK/2)
+ /* Unlike the other case, this is in units of bytes. */
+ /* We actually allocate only every second mark bit, since we */
+ /* force all objects to be doubleword aligned. */
+ /* However, each mark bit is allocated as a byte. */
# else
-# define MARK_BITS_SZ ((MARK_BITS_PER_HBLK + CPP_WORDSZ - 1)/CPP_WORDSZ)
+# define MARK_BITS_SZ (MARK_BITS_PER_HBLK/CPP_WORDSZ)
# endif
- /* Upper bound on number of mark words per heap block */
struct hblkhdr {
word hb_sz; /* If in use, size in words, of objects in the block. */
@@ -965,11 +694,20 @@ struct hblkhdr {
/* Value of GC_gc_no when block was */
/* last allocated or swept. May wrap. */
/* For a free block, this is maintained */
- /* unly for USE_MUNMAP, and indicates */
+ /* only for USE_MUNMAP, and indicates */
/* when the header was allocated, or */
/* when the size of the block last */
/* changed. */
- word hb_marks[MARK_BITS_SZ];
+# ifdef USE_MARK_BYTES
+ union {
+ char _hb_marks[MARK_BITS_SZ];
+ /* The i'th byte is 1 if the object */
+ /* starting at word 2i is marked, 0 o.w. */
+ word dummy; /* Force word alignment of mark bytes. */
+ } _mark_byte_union;
+# define hb_marks _mark_byte_union._hb_marks
+# else
+ word hb_marks[MARK_BITS_SZ];
/* Bit i in the array refers to the */
/* object starting at the ith word (header */
/* INCLUDED) in the heap block. */
@@ -977,6 +715,7 @@ struct hblkhdr {
/* Unused bits are invalid, and are */
/* occasionally set, e.g for uncollectable */
/* objects. */
+# endif /* !USE_MARK_BYTES */
};
/* heap block body */
@@ -1011,10 +750,11 @@ struct hblk {
/* The type of mark procedures. This really belongs in gc_mark.h. */
/* But we put it here, so that we can avoid scanning the mark proc */
/* table. */
-typedef struct ms_entry * (*mark_proc)(/* word * addr,
- struct ms_entry *mark_stack_ptr,
- struct ms_entry *mark_stack_limit,
- word env */);
+struct ms_entry;
+typedef struct ms_entry * (*mark_proc) GC_PROTO((
+ word * addr, struct ms_entry * mark_stack_ptr,
+ struct ms_entry * mark_stack_limit, word env));
+
# define LOG_MAX_MARK_PROCS 6
# define MAX_MARK_PROCS (1 << LOG_MAX_MARK_PROCS)
@@ -1028,7 +768,7 @@ typedef struct ms_entry * (*mark_proc)(/* word * addr,
# ifdef PCR
# define MAX_ROOT_SETS 1024
# else
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# define MAX_ROOT_SETS 512
/* Under NT, we add only written pages, which can result */
/* in many small root sets. */
@@ -1056,14 +796,14 @@ struct exclusion {
struct roots {
ptr_t r_start;
ptr_t r_end;
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
struct roots * r_next;
# endif
GC_bool r_tmp;
/* Delete before registering new dynamic libraries */
};
-#ifndef MSWIN32
+#if !defined(MSWIN32) && !defined(MSWINCE)
/* Size of hash table index to roots. */
# define LOG_RT_SIZE 6
# define RT_SIZE (1 << LOG_RT_SIZE) /* Power of 2, may be != MAX_ROOT_SETS */
@@ -1100,8 +840,10 @@ struct _GC_arrays {
word _words_allocd_before_gc;
/* Number of words allocated before this */
/* collection cycle. */
- word _words_allocd;
+# ifndef SEPARATE_GLOBALS
+ word _words_allocd;
/* Number of words allocated during this collection cycle */
+# endif
word _words_wasted;
/* Number of words wasted due to internal fragmentation */
/* in large objects, or due to dropping blacklisted */
@@ -1124,10 +866,13 @@ struct _GC_arrays {
/* Table of user-defined mark procedures. There is */
/* a small number of these, which can be referenced */
/* by DS_PROC mark descriptors. See gc_mark.h. */
- ptr_t _objfreelist[MAXOBJSZ+1];
+
+# ifndef SEPARATE_GLOBALS
+ ptr_t _objfreelist[MAXOBJSZ+1];
/* free list for objects */
- ptr_t _aobjfreelist[MAXOBJSZ+1];
+ ptr_t _aobjfreelist[MAXOBJSZ+1];
/* free list for atomic objs */
+# endif
ptr_t _uobjfreelist[MAXOBJSZ+1];
/* uncollectable but traced objs */
@@ -1238,12 +983,16 @@ struct _GC_arrays {
struct HeapSect {
ptr_t hs_start; word hs_bytes;
} _heap_sects[MAX_HEAP_SECTS];
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
ptr_t _heap_bases[MAX_HEAP_SECTS];
/* Start address of memory regions obtained from kernel. */
# endif
+# ifdef MSWINCE
+ word _heap_lengths[MAX_HEAP_SECTS];
+ /* Commited lengths of memory regions obtained from kernel. */
+# endif
struct roots _static_roots[MAX_ROOT_SETS];
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
struct roots * _root_index[RT_SIZE];
# endif
struct exclusion _excl_table[MAX_EXCLUSIONS];
@@ -1262,8 +1011,11 @@ struct _GC_arrays {
GC_API GC_FAR struct _GC_arrays GC_arrays;
-# define GC_objfreelist GC_arrays._objfreelist
-# define GC_aobjfreelist GC_arrays._aobjfreelist
+# ifndef SEPARATE_GLOBALS
+# define GC_objfreelist GC_arrays._objfreelist
+# define GC_aobjfreelist GC_arrays._aobjfreelist
+# define GC_words_allocd GC_arrays._words_allocd
+# endif
# define GC_uobjfreelist GC_arrays._uobjfreelist
# ifdef ATOMIC_UNCOLLECTABLE
# define GC_auobjfreelist GC_arrays._auobjfreelist
@@ -1278,7 +1030,6 @@ GC_API GC_FAR struct _GC_arrays GC_arrays;
# define GC_obj_map GC_arrays._obj_map
# define GC_last_heap_addr GC_arrays._last_heap_addr
# define GC_prev_heap_addr GC_arrays._prev_heap_addr
-# define GC_words_allocd GC_arrays._words_allocd
# define GC_words_wasted GC_arrays._words_wasted
# define GC_large_free_bytes GC_arrays._large_free_bytes
# define GC_words_finalized GC_arrays._words_finalized
@@ -1296,9 +1047,12 @@ GC_API GC_FAR struct _GC_arrays GC_arrays;
# ifdef USE_MUNMAP
# define GC_unmapped_bytes GC_arrays._unmapped_bytes
# endif
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# define GC_heap_bases GC_arrays._heap_bases
# endif
+# ifdef MSWINCE
+# define GC_heap_lengths GC_arrays._heap_lengths
+# endif
# define GC_static_roots GC_arrays._static_roots
# define GC_root_index GC_arrays._root_index
# define GC_excl_table GC_arrays._excl_table
@@ -1345,10 +1099,27 @@ extern struct obj_kind {
GC_bool ok_init; /* Clear objects before putting them on the free list. */
} GC_obj_kinds[MAXOBJKINDS];
-# define endGC_obj_kinds (((ptr_t)(&GC_obj_kinds)) + (sizeof GC_obj_kinds))
+# define beginGC_obj_kinds ((ptr_t)(&GC_obj_kinds))
+# define endGC_obj_kinds (beginGC_obj_kinds + (sizeof GC_obj_kinds))
+
+/* Variables that used to be in GC_arrays, but need to be accessed by */
+/* inline allocation code. If they were in GC_arrays, the inlined */
+/* allocation code would include GC_arrays offsets (as it did), which */
+/* introduce maintenance problems. */
-# define end_gc_area ((ptr_t)endGC_arrays == (ptr_t)(&GC_obj_kinds) ? \
- endGC_obj_kinds : endGC_arrays)
+#ifdef SEPARATE_GLOBALS
+ word GC_words_allocd;
+ /* Number of words allocated during this collection cycle */
+ ptr_t GC_objfreelist[MAXOBJSZ+1];
+ /* free list for NORMAL objects */
+# define beginGC_objfreelist ((ptr_t)(&GC_objfreelist))
+# define endGC_objfreelist (beginGC_objfreelist + sizeof(GC_objfreelist))
+
+ ptr_t GC_aobjfreelist[MAXOBJSZ+1];
+ /* free list for atomic (PTRFREE) objs */
+# define beginGC_aobjfreelist ((ptr_t)(&GC_aobjfreelist))
+# define endGC_aobjfreelist (beginGC_aobjfreelist + sizeof(GC_aobjfreelist))
+#endif
/* Predefined kinds: */
# define PTRFREE 0
@@ -1372,8 +1143,10 @@ extern word GC_n_heap_sects; /* Number of separately added heap */
extern word GC_page_size;
-# ifdef MSWIN32
-extern word GC_n_heap_bases; /* See GC_heap_bases. */
+# if defined(MSWIN32) || defined(MSWINCE)
+ struct _SYSTEM_INFO;
+ extern struct _SYSTEM_INFO GC_sysinfo;
+ extern word GC_n_heap_bases; /* See GC_heap_bases. */
# endif
extern word GC_total_stack_black_listed;
@@ -1434,6 +1207,33 @@ extern ptr_t GC_greatest_plausible_heap_addr;
/* with it. Only those corresponding to the beginning of an */
/* object are used. */
+/* Set mark bit correctly, even if mark bits may be concurrently */
+/* accessed. */
+#ifdef PARALLEL_MARK
+# define OR_WORD(addr, bits) \
+ { word old; \
+ do { \
+ old = *((volatile word *)addr); \
+ } while (!GC_compare_and_exchange((addr), old, old | (bits))); \
+ }
+# define OR_WORD_EXIT_IF_SET(addr, bits, exit_label) \
+ { word old; \
+ word my_bits = (bits); \
+ do { \
+ old = *((volatile word *)addr); \
+ if (old & my_bits) goto exit_label; \
+ } while (!GC_compare_and_exchange((addr), old, old | my_bits)); \
+ }
+#else
+# define OR_WORD(addr, bits) *(addr) |= (bits)
+# define OR_WORD_EXIT_IF_SET(addr, bits, exit_label) \
+ { \
+ word old = *(addr); \
+ word my_bits = (bits); \
+ if (old & my_bits) goto exit_label; \
+ *(addr) = (old | my_bits); \
+ }
+#endif
/* Mark bit operations */
@@ -1445,72 +1245,87 @@ extern ptr_t GC_greatest_plausible_heap_addr;
* relative to the beginning of the block, including unused words)
*/
+#ifdef USE_MARK_BYTES
+# define mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n) >> 1])
+# define set_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n)>>1]) = 1
+# define clear_mark_bit_from_hdr(hhdr,n) ((hhdr)->hb_marks[(n)>>1]) = 0
+#else /* !USE_MARK_BYTES */
# define mark_bit_from_hdr(hhdr,n) (((hhdr)->hb_marks[divWORDSZ(n)] \
>> (modWORDSZ(n))) & (word)1)
-# define set_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \
- |= (word)1 << modWORDSZ(n)
-
+# define set_mark_bit_from_hdr(hhdr,n) \
+ OR_WORD((hhdr)->hb_marks+divWORDSZ(n), \
+ (word)1 << modWORDSZ(n))
# define clear_mark_bit_from_hdr(hhdr,n) (hhdr)->hb_marks[divWORDSZ(n)] \
&= ~((word)1 << modWORDSZ(n))
+#endif /* !USE_MARK_BYTES */
/* Important internal collector routines */
-ptr_t GC_approx_sp();
-
-GC_bool GC_should_collect();
-
-void GC_apply_to_all_blocks(/*fn, client_data*/);
- /* Invoke fn(hbp, client_data) for each */
- /* allocated heap block. */
-struct hblk * GC_next_used_block(/* struct hblk * h */);
- /* Return first in-use block >= h */
-struct hblk * GC_prev_block(/* struct hblk * h */);
- /* Return last block <= h. Returned block */
- /* is managed by GC, but may or may not be in */
+ptr_t GC_approx_sp GC_PROTO((void));
+
+GC_bool GC_should_collect GC_PROTO((void));
+
+void GC_apply_to_all_blocks GC_PROTO(( \
+ void (*fn) GC_PROTO((struct hblk *h, word client_data)), \
+ word client_data));
+ /* Invoke fn(hbp, client_data) for each */
+ /* allocated heap block. */
+struct hblk * GC_next_used_block GC_PROTO((struct hblk * h));
+ /* Return first in-use block >= h */
+struct hblk * GC_prev_block GC_PROTO((struct hblk * h));
+ /* Return last block <= h. Returned block */
+ /* is managed by GC, but may or may not be in */
/* use. */
-void GC_mark_init();
-void GC_clear_marks(); /* Clear mark bits for all heap objects. */
-void GC_invalidate_mark_state(); /* Tell the marker that marked */
- /* objects may point to unmarked */
- /* ones, and roots may point to */
- /* unmarked objects. */
- /* Reset mark stack. */
-void GC_mark_from_mark_stack(); /* Mark from everything on the mark stack. */
- /* Return after about one pages worth of */
- /* work. */
-GC_bool GC_mark_stack_empty();
-GC_bool GC_mark_some(/* cold_gc_frame */);
- /* Perform about one pages worth of marking */
- /* work of whatever kind is needed. Returns */
- /* quickly if no collection is in progress. */
- /* Return TRUE if mark phase finished. */
-void GC_initiate_gc(); /* initiate collection. */
- /* If the mark state is invalid, this */
- /* becomes full colleection. Otherwise */
- /* it's partial. */
-void GC_push_all(/*b,t*/); /* Push everything in a range */
- /* onto mark stack. */
-void GC_push_dirty(/*b,t*/); /* Push all possibly changed */
- /* subintervals of [b,t) onto */
- /* mark stack. */
+void GC_mark_init GC_PROTO((void));
+void GC_clear_marks GC_PROTO((void)); /* Clear mark bits for all heap objects. */
+void GC_invalidate_mark_state GC_PROTO((void));
+ /* Tell the marker that marked */
+ /* objects may point to unmarked */
+ /* ones, and roots may point to */
+ /* unmarked objects. */
+ /* Reset mark stack. */
+GC_bool GC_mark_stack_empty GC_PROTO((void));
+GC_bool GC_mark_some GC_PROTO((ptr_t cold_gc_frame));
+ /* Perform about one pages worth of marking */
+ /* work of whatever kind is needed. Returns */
+ /* quickly if no collection is in progress. */
+ /* Return TRUE if mark phase finished. */
+void GC_initiate_gc GC_PROTO((void));
+ /* initiate collection. */
+ /* If the mark state is invalid, this */
+ /* becomes full colleection. Otherwise */
+ /* it's partial. */
+void GC_push_all GC_PROTO((ptr_t bottom, ptr_t top));
+ /* Push everything in a range */
+ /* onto mark stack. */
+void GC_push_selected GC_PROTO(( \
+ ptr_t bottom, \
+ ptr_t top, \
+ int (*dirty_fn) GC_PROTO((struct hblk *h)), \
+ void (*push_fn) GC_PROTO((ptr_t bottom, ptr_t top)) ));
+ /* Push all pages h in [b,t) s.t. */
+ /* select_fn(h) != 0 onto mark stack. */
#ifndef SMALL_CONFIG
- void GC_push_conditional(/* ptr_t b, ptr_t t, GC_bool all*/);
+ void GC_push_conditional GC_PROTO((ptr_t b, ptr_t t, GC_bool all));
#else
# define GC_push_conditional(b, t, all) GC_push_all(b, t)
#endif
/* Do either of the above, depending */
/* on the third arg. */
-void GC_push_all_stack(/*b,t*/); /* As above, but consider */
+void GC_push_all_stack GC_PROTO((ptr_t b, ptr_t t));
+ /* As above, but consider */
/* interior pointers as valid */
-void GC_push_all_eager(/*b,t*/); /* Same as GC_push_all_stack, but */
+void GC_push_all_eager GC_PROTO((ptr_t b, ptr_t t));
+ /* Same as GC_push_all_stack, but */
/* ensures that stack is scanned */
/* immediately, not just scheduled */
/* for scanning. */
#ifndef THREADS
- void GC_push_all_stack_partially_eager(/* bottom, top, cold_gc_frame */);
+ void GC_push_all_stack_partially_eager GC_PROTO(( \
+ ptr_t bottom, ptr_t top, ptr_t cold_gc_frame ));
/* Similar to GC_push_all_eager, but only the */
/* part hotter than cold_gc_frame is scanned */
- /* immediately. Needed to endure that callee- */
+ /* immediately. Needed to ensure that callee- */
/* save registers are not missed. */
#else
/* In the threads case, we push part of the current thread stack */
@@ -1519,84 +1334,105 @@ void GC_push_all_eager(/*b,t*/); /* Same as GC_push_all_stack, but */
/* stacks are scheduled for scanning in *GC_push_other_roots, which */
/* is thread-package-specific. */
#endif
-void GC_push_current_stack(/* ptr_t cold_gc_frame */);
- /* Push enough of the current stack eagerly to */
- /* ensure that callee-save registers saved in */
- /* GC frames are scanned. */
- /* In the non-threads case, schedule entire */
- /* stack for scanning. */
-void GC_push_roots(/* GC_bool all, ptr_t cold_gc_frame */);
- /* Push all or dirty roots. */
-extern void (*GC_push_other_roots)();
- /* Push system or application specific roots */
- /* onto the mark stack. In some environments */
- /* (e.g. threads environments) this is */
- /* predfined to be non-zero. A client supplied */
- /* replacement should also call the original */
- /* function. */
-extern void (*GC_start_call_back)(/* void */);
- /* Called at start of full collections. */
- /* Not called if 0. Called with allocation */
- /* lock held. */
- /* 0 by default. */
-void GC_push_regs(); /* Push register contents onto mark stack. */
- /* If NURSERY is defined, the default push */
- /* action can be overridden with GC_push_proc */
-void GC_remark(); /* Mark from all marked objects. Used */
- /* only if we had to drop something. */
+void GC_push_current_stack GC_PROTO((ptr_t cold_gc_frame));
+ /* Push enough of the current stack eagerly to */
+ /* ensure that callee-save registers saved in */
+ /* GC frames are scanned. */
+ /* In the non-threads case, schedule entire */
+ /* stack for scanning. */
+void GC_push_roots GC_PROTO((GC_bool all, ptr_t cold_gc_frame));
+ /* Push all or dirty roots. */
+extern void (*GC_push_other_roots) GC_PROTO((void));
+ /* Push system or application specific roots */
+ /* onto the mark stack. In some environments */
+ /* (e.g. threads environments) this is */
+ /* predfined to be non-zero. A client supplied */
+ /* replacement should also call the original */
+ /* function. */
+extern void (*GC_start_call_back) GC_PROTO((void));
+ /* Called at start of full collections. */
+ /* Not called if 0. Called with allocation */
+ /* lock held. */
+ /* 0 by default. */
+# if defined(USE_GENERIC_PUSH_REGS)
+ void GC_generic_push_regs GC_PROTO((ptr_t cold_gc_frame));
+# else
+ void GC_push_regs GC_PROTO((void));
+# endif
+ /* Push register contents onto mark stack. */
+ /* If NURSERY is defined, the default push */
+ /* action can be overridden with GC_push_proc */
# ifdef NURSERY
extern void (*GC_push_proc)(ptr_t);
# endif
-# if defined(MSWIN32)
- void __cdecl GC_push_one();
+# if defined(MSWIN32) || defined(MSWINCE)
+ void __cdecl GC_push_one GC_PROTO((word p));
# else
- void GC_push_one(/*p*/); /* If p points to an object, mark it */
+ void GC_push_one GC_PROTO((word p));
+ /* If p points to an object, mark it */
/* and push contents on the mark stack */
# endif
-void GC_push_one_checked(/*p*/); /* Ditto, omits plausibility test */
-void GC_push_marked(/* struct hblk h, hdr * hhdr */);
+# if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS)
+ void GC_push_one_checked GC_PROTO(( \
+ word p, GC_bool interior_ptrs, ptr_t source));
+ /* Ditto, omits plausibility test */
+# else
+ void GC_push_one_checked GC_PROTO(( \
+ word p, GC_bool interior_ptrs));
+# endif
+void GC_push_marked GC_PROTO((struct hblk * h, hdr * hhdr));
/* Push contents of all marked objects in h onto */
/* mark stack. */
#ifdef SMALL_CONFIG
# define GC_push_next_marked_dirty(h) GC_push_next_marked(h)
#else
- struct hblk * GC_push_next_marked_dirty(/* h */);
+ struct hblk * GC_push_next_marked_dirty GC_PROTO((struct hblk * h));
/* Invoke GC_push_marked on next dirty block above h. */
/* Return a pointer just past the end of this block. */
#endif /* !SMALL_CONFIG */
-struct hblk * GC_push_next_marked(/* h */);
- /* Ditto, but also mark from clean pages. */
-struct hblk * GC_push_next_marked_uncollectable(/* h */);
- /* Ditto, but mark only from uncollectable pages. */
-GC_bool GC_stopped_mark(); /* Stop world and mark from all roots */
- /* and rescuers. */
-void GC_clear_hdr_marks(/* hhdr */); /* Clear the mark bits in a header */
-void GC_set_hdr_marks(/* hhdr */); /* Set the mark bits in a header */
-void GC_add_roots_inner();
-GC_bool GC_is_static_root(/* ptr_t p */);
- /* Is the address p in one of the registered static */
+struct hblk * GC_push_next_marked GC_PROTO((struct hblk * h));
+ /* Ditto, but also mark from clean pages. */
+struct hblk * GC_push_next_marked_uncollectable GC_PROTO((struct hblk * h));
+ /* Ditto, but mark only from uncollectable pages. */
+GC_bool GC_stopped_mark GC_PROTO((GC_stop_func stop_func));
+ /* Stop world and mark from all roots */
+ /* and rescuers. */
+void GC_clear_hdr_marks GC_PROTO((hdr * hhdr));
+ /* Clear the mark bits in a header */
+void GC_set_hdr_marks GC_PROTO((hdr * hhdr));
+ /* Set the mark bits in a header */
+void GC_add_roots_inner GC_PROTO((char * b, char * e, GC_bool tmp));
+GC_bool GC_is_static_root GC_PROTO((ptr_t p));
+ /* Is the address p in one of the registered static */
+ /* root sections? */
+# if defined(MSWIN32) || defined(_WIN32_WCE_EMULATION)
+GC_bool GC_is_tmp_root GC_PROTO((ptr_t p));
+ /* Is the address p in one of the temporary static */
/* root sections? */
-void GC_register_dynamic_libraries();
- /* Add dynamic library data sections to the root set. */
-
+# endif
+void GC_register_dynamic_libraries GC_PROTO((void));
+ /* Add dynamic library data sections to the root set. */
+
/* Machine dependent startup routines */
-ptr_t GC_get_stack_base();
-void GC_register_data_segments();
-
+ptr_t GC_get_stack_base GC_PROTO((void));
+void GC_register_data_segments GC_PROTO((void));
+
/* Black listing: */
-void GC_bl_init();
+void GC_bl_init GC_PROTO((void));
# ifndef ALL_INTERIOR_POINTERS
- void GC_add_to_black_list_normal(/* bits, maybe source */);
+# ifdef PRINT_BLACK_LIST
+ void GC_add_to_black_list_normal GC_PROTO((word p, ptr_t source));
/* Register bits as a possible future false */
/* reference from the heap or static data */
-# ifdef PRINT_BLACK_LIST
# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_normal(bits, source)
+ GC_add_to_black_list_normal(bits, source)
# else
+ void GC_add_to_black_list_normal GC_PROTO((word p));
# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
- GC_add_to_black_list_normal(bits)
+ GC_add_to_black_list_normal(bits)
# endif
+
# else
# ifdef PRINT_BLACK_LIST
# define GC_ADD_TO_BLACK_LIST_NORMAL(bits, source) \
@@ -1607,81 +1443,114 @@ void GC_bl_init();
# endif
# endif
-void GC_add_to_black_list_stack(/* bits, maybe source */);
-struct hblk * GC_is_black_listed(/* h, len */);
- /* If there are likely to be false references */
- /* to a block starting at h of the indicated */
- /* length, then return the next plausible */
- /* starting location for h that might avoid */
- /* these false references. */
-void GC_promote_black_lists();
- /* Declare an end to a black listing phase. */
-void GC_unpromote_black_lists();
- /* Approximately undo the effect of the above. */
- /* This actually loses some information, but */
- /* only in a reasonably safe way. */
-word GC_number_stack_black_listed(/*struct hblk *start, struct hblk *endp1 */);
- /* Return the number of (stack) blacklisted */
- /* blocks in the range for statistical */
- /* purposes. */
-
-ptr_t GC_scratch_alloc(/*bytes*/);
- /* GC internal memory allocation for */
- /* small objects. Deallocation is not */
- /* possible. */
-
+# ifdef PRINT_BLACK_LIST
+ void GC_add_to_black_list_stack GC_PROTO((word p, ptr_t source));
+# else
+ void GC_add_to_black_list_stack GC_PROTO((word p));
+# endif
+struct hblk * GC_is_black_listed GC_PROTO((struct hblk * h, word len));
+ /* If there are likely to be false references */
+ /* to a block starting at h of the indicated */
+ /* length, then return the next plausible */
+ /* starting location for h that might avoid */
+ /* these false references. */
+void GC_promote_black_lists GC_PROTO((void));
+ /* Declare an end to a black listing phase. */
+void GC_unpromote_black_lists GC_PROTO((void));
+ /* Approximately undo the effect of the above. */
+ /* This actually loses some information, but */
+ /* only in a reasonably safe way. */
+word GC_number_stack_black_listed GC_PROTO(( \
+ struct hblk *start, struct hblk *endp1));
+ /* Return the number of (stack) blacklisted */
+ /* blocks in the range for statistical */
+ /* purposes. */
+
+ptr_t GC_scratch_alloc GC_PROTO((word bytes));
+ /* GC internal memory allocation for */
+ /* small objects. Deallocation is not */
+ /* possible. */
+
/* Heap block layout maps: */
-void GC_invalidate_map(/* hdr */);
- /* Remove the object map associated */
- /* with the block. This identifies */
- /* the block as invalid to the mark */
- /* routines. */
-GC_bool GC_add_map_entry(/*sz*/);
- /* Add a heap block map for objects of */
- /* size sz to obj_map. */
- /* Return FALSE on failure. */
-void GC_register_displacement_inner(/*offset*/);
- /* Version of GC_register_displacement */
- /* that assumes lock is already held */
- /* and signals are already disabled. */
-
+void GC_invalidate_map GC_PROTO((hdr * hhdr));
+ /* Remove the object map associated */
+ /* with the block. This identifies */
+ /* the block as invalid to the mark */
+ /* routines. */
+GC_bool GC_add_map_entry GC_PROTO((word sz));
+ /* Add a heap block map for objects of */
+ /* size sz to obj_map. */
+ /* Return FALSE on failure. */
+void GC_register_displacement_inner GC_PROTO((word offset));
+ /* Version of GC_register_displacement */
+ /* that assumes lock is already held */
+ /* and signals are already disabled. */
+
/* hblk allocation: */
-void GC_new_hblk(/*size_in_words, kind*/);
- /* Allocate a new heap block, and build */
- /* a free list in it. */
-struct hblk * GC_allochblk(/*size_in_words, kind*/);
- /* Allocate a heap block, clear it if */
- /* for composite objects, inform */
+void GC_new_hblk GC_PROTO((word size_in_words, int kind));
+ /* Allocate a new heap block, and build */
+ /* a free list in it. */
+
+ptr_t GC_build_fl GC_PROTO((struct hblk *h, word sz,
+ GC_bool clear, ptr_t list));
+ /* Build a free list for objects of */
+ /* size sz in block h. Append list to */
+ /* end of the free lists. Possibly */
+ /* clear objects on the list. Normally */
+ /* called by GC_new_hblk, but also */
+ /* called explicitly without GC lock. */
+
+struct hblk * GC_allochblk GC_PROTO(( \
+ word size_in_words, int kind, unsigned char flags));
+ /* Allocate a heap block, inform */
/* the marker that block is valid */
/* for objects of indicated size. */
- /* sz < 0 ==> atomic. */
-void GC_freehblk(); /* Deallocate a heap block and mark it */
- /* as invalid. */
-
+
+ptr_t GC_alloc_large GC_PROTO((word lw, int k, unsigned char flags));
+ /* Allocate a large block of size lw words. */
+ /* The block is not cleared. */
+ /* Flags is 0 or IGNORE_OFF_PAGE. */
+ /* Calls GC_allchblk to do the actual */
+ /* allocation, but also triggers GC and/or */
+ /* heap expansion as appropriate. */
+ /* Does not update GC_words_allocd, but does */
+ /* other accounting. */
+
+ptr_t GC_alloc_large_and_clear GC_PROTO((word lw, int k, unsigned char flags));
+ /* As above, but clear block if appropriate */
+ /* for kind k. */
+
+void GC_freehblk GC_PROTO((struct hblk * p));
+ /* Deallocate a heap block and mark it */
+ /* as invalid. */
+
/* Misc GC: */
-void GC_init_inner();
-GC_bool GC_expand_hp_inner();
-void GC_start_reclaim(/*abort_if_found*/);
- /* Restore unmarked objects to free */
- /* lists, or (if abort_if_found is */
- /* TRUE) report them. */
- /* Sweeping of small object pages is */
- /* largely deferred. */
-void GC_continue_reclaim(/*size, kind*/);
- /* Sweep pages of the given size and */
- /* kind, as long as possible, and */
- /* as long as the corr. free list is */
- /* empty. */
-void GC_reclaim_or_delete_all();
- /* Arrange for all reclaim lists to be */
- /* empty. Judiciously choose between */
- /* sweeping and discarding each page. */
-GC_bool GC_reclaim_all(/* GC_stop_func f*/);
- /* Reclaim all blocks. Abort (in a */
- /* consistent state) if f returns TRUE. */
-GC_bool GC_block_empty(/* hhdr */); /* Block completely unmarked? */
-GC_bool GC_never_stop_func(); /* Returns FALSE. */
-GC_bool GC_try_to_collect_inner(/* GC_stop_func f */);
+void GC_init_inner GC_PROTO((void));
+GC_bool GC_expand_hp_inner GC_PROTO((word n));
+void GC_start_reclaim GC_PROTO((int abort_if_found));
+ /* Restore unmarked objects to free */
+ /* lists, or (if abort_if_found is */
+ /* TRUE) report them. */
+ /* Sweeping of small object pages is */
+ /* largely deferred. */
+void GC_continue_reclaim GC_PROTO((word sz, int kind));
+ /* Sweep pages of the given size and */
+ /* kind, as long as possible, and */
+ /* as long as the corr. free list is */
+ /* empty. */
+void GC_reclaim_or_delete_all GC_PROTO((void));
+ /* Arrange for all reclaim lists to be */
+ /* empty. Judiciously choose between */
+ /* sweeping and discarding each page. */
+GC_bool GC_reclaim_all GC_PROTO((GC_stop_func stop_func, GC_bool ignore_old));
+ /* Reclaim all blocks. Abort (in a */
+ /* consistent state) if f returns TRUE. */
+GC_bool GC_block_empty GC_PROTO((hdr * hhdr));
+ /* Block completely unmarked? */
+GC_bool GC_never_stop_func GC_PROTO((void));
+ /* Returns FALSE. */
+GC_bool GC_try_to_collect_inner GC_PROTO((GC_stop_func f));
+
/* Collect; caller must have acquired */
/* lock and disabled signals. */
/* Collection is aborted if f returns */
@@ -1689,88 +1558,114 @@ GC_bool GC_try_to_collect_inner(/* GC_stop_func f */);
/* successfully. */
# define GC_gcollect_inner() \
(void) GC_try_to_collect_inner(GC_never_stop_func)
-void GC_finish_collection(); /* Finish collection. Mark bits are */
- /* consistent and lock is still held. */
-GC_bool GC_collect_or_expand(/* needed_blocks */);
- /* Collect or expand heap in an attempt */
- /* make the indicated number of free */
- /* blocks available. Should be called */
- /* until the blocks are available or */
- /* until it fails by returning FALSE. */
-GC_API void GC_init(); /* Initialize collector. */
-void GC_collect_a_little_inner(/* int n */);
- /* Do n units worth of garbage */
- /* collection work, if appropriate. */
- /* A unit is an amount appropriate for */
- /* HBLKSIZE bytes of allocation. */
-ptr_t GC_generic_malloc(/* bytes, kind */);
- /* Allocate an object of the given */
- /* kind. By default, there are only */
- /* a few kinds: composite(pointerfree), */
+void GC_finish_collection GC_PROTO((void));
+ /* Finish collection. Mark bits are */
+ /* consistent and lock is still held. */
+GC_bool GC_collect_or_expand GC_PROTO(( \
+ word needed_blocks, GC_bool ignore_off_page));
+ /* Collect or expand heap in an attempt */
+ /* make the indicated number of free */
+ /* blocks available. Should be called */
+ /* until the blocks are available or */
+ /* until it fails by returning FALSE. */
+GC_API void GC_init GC_PROTO((void)); /* Initialize collector. */
+
+#if defined(MSWIN32) || defined(MSWINCE)
+ void GC_deinit GC_PROTO((void));
+ /* Free any resources allocated by */
+ /* GC_init */
+#endif
+
+void GC_collect_a_little_inner GC_PROTO((int n));
+ /* Do n units worth of garbage */
+ /* collection work, if appropriate. */
+ /* A unit is an amount appropriate for */
+ /* HBLKSIZE bytes of allocation. */
+ptr_t GC_generic_malloc GC_PROTO((word lb, int k));
+ /* Allocate an object of the given */
+ /* kind. By default, there are only */
+ /* a few kinds: composite(pointerfree), */
/* atomic, uncollectable, etc. */
/* We claim it's possible for clever */
/* client code that understands GC */
/* internals to add more, e.g. to */
/* communicate object layout info */
/* to the collector. */
-ptr_t GC_generic_malloc_ignore_off_page(/* bytes, kind */);
- /* As above, but pointers past the */
- /* first page of the resulting object */
- /* are ignored. */
-ptr_t GC_generic_malloc_inner(/* bytes, kind */);
- /* Ditto, but I already hold lock, etc. */
-ptr_t GC_generic_malloc_words_small GC_PROTO((size_t words, int kind));
- /* As above, but size in units of words */
- /* Bypasses MERGE_SIZES. Assumes */
- /* words <= MAXOBJSZ. */
-ptr_t GC_generic_malloc_inner_ignore_off_page(/* bytes, kind */);
- /* Allocate an object, where */
- /* the client guarantees that there */
- /* will always be a pointer to the */
- /* beginning of the object while the */
- /* object is live. */
-ptr_t GC_allocobj(/* sz_inn_words, kind */);
- /* Make the indicated */
- /* free list nonempty, and return its */
- /* head. */
-
-void GC_init_headers();
-struct hblkhdr * GC_install_header(/*h*/);
- /* Install a header for block h. */
- /* Return 0 on failure, or the header */
- /* otherwise. */
-GC_bool GC_install_counts(/*h, sz*/);
- /* Set up forwarding counts for block */
- /* h of size sz. */
- /* Return FALSE on failure. */
-void GC_remove_header(/*h*/);
- /* Remove the header for block h. */
-void GC_remove_counts(/*h, sz*/);
- /* Remove forwarding counts for h. */
-hdr * GC_find_header(/*p*/); /* Debugging only. */
-
-void GC_finalize(); /* Perform all indicated finalization actions */
- /* on unmarked objects. */
- /* Unreachable finalizable objects are enqueued */
- /* for processing by GC_invoke_finalizers. */
- /* Invoked with lock. */
-
-void GC_add_to_heap(/*p, bytes*/);
- /* Add a HBLKSIZE aligned chunk to the heap. */
-
-void GC_print_obj(/* ptr_t p */);
- /* P points to somewhere inside an object with */
- /* debugging info. Print a human readable */
- /* description of the object to stderr. */
-extern void (*GC_check_heap)();
- /* Check that all objects in the heap with */
- /* debugging info are intact. Print */
- /* descriptions of any that are not. */
-extern void (*GC_print_heap_obj)(/* ptr_t p */);
- /* If possible print s followed by a more */
- /* detailed description of the object */
- /* referred to by p. */
-
+ptr_t GC_generic_malloc_ignore_off_page GC_PROTO((size_t b, int k));
+ /* As above, but pointers past the */
+ /* first page of the resulting object */
+ /* are ignored. */
+ptr_t GC_generic_malloc_inner GC_PROTO((word lb, int k));
+ /* Ditto, but I already hold lock, etc. */
+ptr_t GC_generic_malloc_words_small GC_PROTO((size_t lw, int k));
+ /* As above, but size in units of words */
+ /* Bypasses MERGE_SIZES. Assumes */
+ /* words <= MAXOBJSZ. */
+ptr_t GC_generic_malloc_inner_ignore_off_page GC_PROTO((size_t lb, int k));
+ /* Allocate an object, where */
+ /* the client guarantees that there */
+ /* will always be a pointer to the */
+ /* beginning of the object while the */
+ /* object is live. */
+ptr_t GC_allocobj GC_PROTO((word sz, int kind));
+ /* Make the indicated */
+ /* free list nonempty, and return its */
+ /* head. */
+
+void GC_init_headers GC_PROTO((void));
+struct hblkhdr * GC_install_header GC_PROTO((struct hblk *h));
+ /* Install a header for block h. */
+ /* Return 0 on failure, or the header */
+ /* otherwise. */
+GC_bool GC_install_counts GC_PROTO((struct hblk * h, word sz));
+ /* Set up forwarding counts for block */
+ /* h of size sz. */
+ /* Return FALSE on failure. */
+void GC_remove_header GC_PROTO((struct hblk * h));
+ /* Remove the header for block h. */
+void GC_remove_counts GC_PROTO((struct hblk * h, word sz));
+ /* Remove forwarding counts for h. */
+hdr * GC_find_header GC_PROTO((ptr_t h)); /* Debugging only. */
+
+void GC_finalize GC_PROTO((void));
+ /* Perform all indicated finalization actions */
+ /* on unmarked objects. */
+ /* Unreachable finalizable objects are enqueued */
+ /* for processing by GC_invoke_finalizers. */
+ /* Invoked with lock. */
+
+void GC_add_to_heap GC_PROTO((struct hblk *p, word bytes));
+ /* Add a HBLKSIZE aligned chunk to the heap. */
+
+void GC_print_obj GC_PROTO((ptr_t p));
+ /* P points to somewhere inside an object with */
+ /* debugging info. Print a human readable */
+ /* description of the object to stderr. */
+extern void (*GC_check_heap) GC_PROTO((void));
+ /* Check that all objects in the heap with */
+ /* debugging info are intact. Print */
+ /* descriptions of any that are not. */
+extern void (*GC_print_heap_obj) GC_PROTO((ptr_t p));
+ /* If possible print s followed by a more */
+ /* detailed description of the object */
+ /* referred to by p. */
+
+
+/* Macros used for collector internal allocation. */
+/* These assume the collector lock is held. */
+#ifdef DBG_HDRS_ALL
+ extern GC_PTR GC_debug_generic_malloc_inner(size_t lb, int k);
+ extern GC_PTR GC_debug_generic_malloc_inner_ignore_off_page(size_t lb,
+ int k);
+# define GC_INTERNAL_MALLOC GC_debug_generic_malloc_inner
+# define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \
+ GC_debug_generic_malloc_inner_ignore_off_page
+#else
+# define GC_INTERNAL_MALLOC GC_generic_malloc_inner
+# define GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE \
+ GC_generic_malloc_inner_ignore_off_page
+#endif
+
/* Memory unmapping: */
#ifdef USE_MUNMAP
void GC_unmap_old(void);
@@ -1782,35 +1677,38 @@ extern void (*GC_print_heap_obj)(/* ptr_t p */);
/* Virtual dirty bit implementation: */
/* Each implementation exports the following: */
-void GC_read_dirty(); /* Retrieve dirty bits. */
-GC_bool GC_page_was_dirty(/* struct hblk * h */);
- /* Read retrieved dirty bits. */
-GC_bool GC_page_was_ever_dirty(/* struct hblk * h */);
- /* Could the page contain valid heap pointers? */
-void GC_is_fresh(/* struct hblk * h, word number_of_blocks */);
- /* Assert the region currently contains no */
- /* valid pointers. */
-void GC_write_hint(/* struct hblk * h */);
- /* h is about to be written. */
-void GC_dirty_init();
-
+void GC_read_dirty GC_PROTO((void));
+ /* Retrieve dirty bits. */
+GC_bool GC_page_was_dirty GC_PROTO((struct hblk *h));
+ /* Read retrieved dirty bits. */
+GC_bool GC_page_was_ever_dirty GC_PROTO((struct hblk *h));
+ /* Could the page contain valid heap pointers? */
+void GC_is_fresh GC_PROTO((struct hblk *h, word n));
+ /* Assert the region currently contains no */
+ /* valid pointers. */
+void GC_write_hint GC_PROTO((struct hblk *h));
+ /* h is about to be written. */
+void GC_dirty_init GC_PROTO((void));
+
/* Slow/general mark bit manipulation: */
-GC_API GC_bool GC_is_marked();
-void GC_clear_mark_bit();
-void GC_set_mark_bit();
-
+GC_API GC_bool GC_is_marked GC_PROTO((ptr_t p));
+void GC_clear_mark_bit GC_PROTO((ptr_t p));
+void GC_set_mark_bit GC_PROTO((ptr_t p));
+
/* Stubborn objects: */
-void GC_read_changed(); /* Analogous to GC_read_dirty */
-GC_bool GC_page_was_changed(/* h */); /* Analogous to GC_page_was_dirty */
-void GC_clean_changing_list(); /* Collect obsolete changing list entries */
-void GC_stubborn_init();
-
+void GC_read_changed GC_PROTO((void)); /* Analogous to GC_read_dirty */
+GC_bool GC_page_was_changed GC_PROTO((struct hblk * h));
+ /* Analogous to GC_page_was_dirty */
+void GC_clean_changing_list GC_PROTO((void));
+ /* Collect obsolete changing list entries */
+void GC_stubborn_init GC_PROTO((void));
+
/* Debugging print routines: */
-void GC_print_block_list();
-void GC_print_hblkfreelist();
-void GC_print_heap_sects();
-void GC_print_static_roots();
-void GC_dump();
+void GC_print_block_list GC_PROTO((void));
+void GC_print_hblkfreelist GC_PROTO((void));
+void GC_print_heap_sects GC_PROTO((void));
+void GC_print_static_roots GC_PROTO((void));
+void GC_dump GC_PROTO((void));
#ifdef KEEP_BACK_PTRS
void GC_store_back_pointer(ptr_t source, ptr_t dest);
@@ -1829,10 +1727,10 @@ void GC_dump();
GC_API void GC_noop();
# endif
-void GC_noop1(/* word arg */);
+void GC_noop1 GC_PROTO((word arg));
/* Logging and diagnostic output: */
-GC_API void GC_printf GC_PROTO((char * format, long, long, long, long, long, long));
+GC_API void GC_printf GC_PROTO((GC_CONST char * format, long, long, long, long, long, long));
/* A version of printf that doesn't allocate, */
/* is restricted to long arguments, and */
/* (unfortunately) doesn't use varargs for */
@@ -1851,7 +1749,7 @@ GC_API void GC_printf GC_PROTO((char * format, long, long, long, long, long, lon
# define GC_printf6(f,a,b,c,d,e,g) GC_printf(f, (long)a, (long)b, (long)c, \
(long)d, (long)e, (long)g)
-void GC_err_printf(/* format, a, b, c, d, e, f */);
+GC_API void GC_err_printf GC_PROTO((GC_CONST char * format, long, long, long, long, long, long));
# define GC_err_printf0(f) GC_err_puts(f)
# define GC_err_printf1(f,a) GC_err_printf(f, (long)a, 0l, 0l, 0l, 0l, 0l)
# define GC_err_printf2(f,a,b) GC_err_printf(f, (long)a, (long)b, 0l, 0l, 0l, 0l)
@@ -1867,18 +1765,53 @@ void GC_err_printf(/* format, a, b, c, d, e, f */);
(long)e, (long)g)
/* Ditto, writes to stderr. */
-void GC_err_puts(/* char *s */);
+void GC_err_puts GC_PROTO((GC_CONST char *s));
/* Write s to stderr, don't buffer, don't add */
/* newlines, don't ... */
-# ifdef GC_ASSERTIONS
+# ifdef GC_ASSERTIONS
# define GC_ASSERT(expr) if(!(expr)) {\
GC_err_printf2("Assertion failure: %s:%ld\n", \
__FILE__, (unsigned long)__LINE__); \
ABORT("assertion failure"); }
-# else
+# else
# define GC_ASSERT(expr)
-# endif
+# endif
+
+# ifdef PARALLEL_MARK
+ /* We need additional synchronization facilities from the thread */
+ /* support. We believe these are less performance critical */
+ /* than the main garbage collector lock; standard pthreads-based */
+ /* implementations should be sufficient. */
+
+ /* The mark lock and condition variable. If the GC lock is also */
+ /* acquired, the GC lock must be acquired first. The mark lock is */
+ /* used to both protect some variables used by the parallel */
+ /* marker, and to protect GC_fl_builder_count, below. */
+ /* GC_notify_all_marker() is called when */
+ /* the state of the parallel marker changes */
+ /* in some significant way (see gc_mark.h for details). The */
+ /* latter set of events includes incrementing GC_mark_no. */
+ /* GC_notify_all_builder() is called when GC_fl_builder_count */
+ /* reaches 0. */
+
+ extern void GC_acquire_mark_lock();
+ extern void GC_release_mark_lock();
+ extern void GC_notify_all_marker();
+ extern void GC_notify_all_builder();
+ extern void GC_wait_marker();
+ /* extern void GC_wait_builder(); */
+ extern void GC_wait_for_reclaim();
+
+ extern word GC_fl_builder_count; /* Protected by mark lock. */
+ extern word GC_mark_no; /* Protected by mark lock. */
+
+ extern void GC_help_marker(word my_mark_no);
+ /* Try to help out parallel marker for mark cycle */
+ /* my_mark_no. Returns if the mark cycle finishes or */
+ /* was already done, or there was nothing to do for */
+ /* some other reason. */
+# endif /* PARALLEL_MARK */
# endif /* GC_PRIVATE_H */
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index 221983ca..5af9d9fb 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -2,6 +2,7 @@
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1996 by Silicon Graphics. All rights reserved.
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -194,11 +195,17 @@
# define MACOS
# define mach_type_known
# endif
-# if defined(macosx)
+# if defined(macosx) || \
+ defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
# define MACOSX
# define POWERPC
# define mach_type_known
# endif
+# if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
+# define MACOSX
+# define I386
+ --> Not really supported, but at least we recognize it.
+# endif
# if defined(NeXT) && defined(mc68000)
# define M68K
# define NEXT
@@ -244,11 +251,23 @@
/* DGUX defined */
# define mach_type_known
# endif
-# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
- || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
-# define I386
-# define MSWIN32 /* or Win32s */
+# if defined(_WIN32_WCE)
+ /* SH3, SH4, MIPS already defined for corresponding architectures */
+# if defined(x86)
+# define I386
+# endif
+# if defined(ARM)
+# define ARM32
+# endif
+# define MSWINCE
# define mach_type_known
+# else
+# if (defined(_MSDOS) || defined(_MSC_VER)) && (_M_IX86 >= 300) \
+ || defined(_WIN32) && !defined(__CYGWIN32__) && !defined(__CYGWIN__)
+# define I386
+# define MSWIN32 /* or Win32s */
+# define mach_type_known
+# endif
# endif
# if defined(__DJGPP__)
# define I386
@@ -326,8 +345,8 @@
/* RT ==> IBM PC/RT */
/* HP_PA ==> HP9000/700 & /800 */
/* HP/UX */
- /* SPARC ==> SPARC under SunOS */
- /* (SUNOS4, SUNOS5, */
+ /* SPARC ==> SPARC v7/v8/v9 */
+ /* (SUNOS4, SUNOS5, LINUX, */
/* DRSNX variants) */
/* ALPHA ==> DEC Alpha */
/* (OSF1 and LINUX variants) */
@@ -462,8 +481,12 @@
# define MPROTECT_VDB
# ifdef __ELF__
# define DYNAMIC_LOADING
- extern char **__environ;
-# define DATASTART ((ptr_t)(&__environ))
+# include <features.h>
+# if defined(__GLIBC__)&& __GLIBC__>=2
+# define LINUX_DATA_START
+# else /* !GLIBC2 */
+ extern char **__environ;
+# define DATASTART ((ptr_t)(&__environ))
/* hideous kludge: __environ is the first */
/* word in crt0.o, and delimits the start */
/* of the data segment, no matter which */
@@ -472,6 +495,7 @@
/* would include .rodata, which may */
/* contain large read-only data tables */
/* that we'd rather not scan. */
+# endif /* !GLIBC2 */
extern int _end;
# define DATAEND (&_end)
# else
@@ -567,11 +591,17 @@
# define DATAEND (&_end)
# endif
# ifdef MACOSX
+ /* There are reasons to suspect this may not be reliable. */
# define ALIGNMENT 4
# define OS_TYPE "MACOSX"
# define DATASTART ((ptr_t) get_etext())
# define STACKBOTTOM ((ptr_t) 0xc0000000)
# define DATAEND /* not needed */
+# ifdef POWERPC
+# define MPROTECT_VDB
+# endif
+# include <unistd.h>
+# define GETPAGESIZE() getpagesize()
# endif
# endif
@@ -600,7 +630,11 @@
# ifdef SPARC
# define MACH_TYPE "SPARC"
-# define ALIGNMENT 4 /* Required by hardware */
+# if defined(__arch64__) || defined(__sparcv9)
+# define ALIGNMENT 8
+# else
+# define ALIGNMENT 4 /* Required by hardware */
+# endif
# define ALIGN_DOUBLE
extern int etext;
# ifdef SUNOS5
@@ -661,15 +695,22 @@
# ifdef LINUX
# define OS_TYPE "LINUX"
# ifdef __ELF__
-# define LINUX_DATA_START
# define DYNAMIC_LOADING
# else
- Linux Sparc non elf ?
+ Linux Sparc/a.out not supported
# endif
extern int _end;
+ extern int _etext;
# define DATAEND (&_end)
# define SVR4
-# define STACKBOTTOM ((ptr_t) 0xf0000000)
+# ifdef __arch64__
+# define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
+# define DATASTART (ptr_t)GC_SysVGetDataStart(0x100000, &_etext)
+# define CPP_WORDSZ 64
+# else
+# define STACKBOTTOM ((ptr_t) 0xf0000000)
+# define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext)
+# endif
# endif
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
@@ -833,6 +874,10 @@
# endif
# define DATAEND /* not needed */
# endif
+# ifdef MSWINCE
+# define OS_TYPE "MSWINCE"
+# define DATAEND /* not needed */
+# endif
# ifdef DJGPP
# define OS_TYPE "DJGPP"
# include "stubinfo.h"
@@ -960,6 +1005,11 @@
# endif
# define DYNAMIC_LOADING
# endif
+# ifdef MSWINCE
+# define OS_TYPE "MSWINCE"
+# define ALIGNMENT 4
+# define DATAEND /* not needed */
+# endif
# endif
# ifdef RS6000
@@ -1009,6 +1059,12 @@
# endif
# include <unistd.h>
# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE)
+# ifndef __GNUC__
+# define PREFETCH(x) { \
+ register long addr = (long)(x); \
+ (void) _asm ("LDW", 0, 0, addr, 0); \
+ }
+# endif
# endif
# ifdef ALPHA
@@ -1059,8 +1115,13 @@
/* Requires 16 byte alignment for malloc */
# define ALIGNMENT 8
# define USE_GENERIC_PUSH_REGS
- /* We need to get preserved registers in addition to register windows. */
- /* That's easiest to do with setjmp. */
+ /* We need to get preserved registers in addition to register */
+ /* windows. That's easiest to do with setjmp. */
+# ifdef PARALLEL_MARK
+# define USE_MARK_BYTES
+ /* Compare-and-exchange is too expensive to use for */
+ /* setting mark bits. */
+# endif
# ifdef HPUX
--> needs work
# endif
@@ -1173,8 +1234,26 @@
# define DATASTART ((ptr_t)((((word) (&etext)) + 0xfff) & ~0xfff))
# endif
# endif
+# ifdef MSWINCE
+# define OS_TYPE "MSWINCE"
+# define DATAEND /* not needed */
+# endif
#endif
+# ifdef SH3
+# define MACH_TYPE "SH3"
+# define OS_TYPE "MSWINCE"
+# define ALIGNMENT 4
+# define DATAEND /* not needed */
+# endif
+
+# ifdef SH4
+# define MACH_TYPE "SH4"
+# define OS_TYPE "MSWINCE"
+# define ALIGNMENT 4
+# define DATAEND /* not needed */
+# endif
+
#ifdef LINUX_DATA_START
/* Some Linux distributions arrange to define __data_start. Some */
/* define data_start as a weak symbol. The latter is technically */
@@ -1188,6 +1267,14 @@
# define DATASTART ((ptr_t)(&__data_start != 0? &__data_start : &data_start))
#endif
+#if defined(LINUX) && defined(REDIRECT_MALLOC) && !defined(LINUX_THREADS)
+ /* Rld appears to allocate some meory with its own allocator, and */
+ /* some through malloc, which might be redirected. To make this */
+ /* work with collectable memory, we have to scan memory allocated */
+ /* by rld's internal malloc. */
+# define USE_PROC_FOR_LIBRARIES
+#endif
+
# ifndef STACK_GROWS_UP
# define STACK_GROWS_DOWN
# endif
@@ -1264,6 +1351,10 @@
# undef MPROTECT_VDB /* Can't deal with address space holes. */
# endif
+# ifdef PARALLEL_MARK
+# undef MPROTECT_VDB /* For now. */
+# endif
+
# if !defined(PCR_VDB) && !defined(PROC_VDB) && !defined(MPROTECT_VDB)
# define DEFAULT_VDB
# endif
@@ -1288,15 +1379,35 @@
((word*)x)[1] = 0;
# endif /* CLEAR_DOUBLE */
+/* Internally to the collector we test only the XXX_THREADS macros */
+/* not the GC_XXX_THREADS versions. Here we make sure the latter */
+/* are treated as equivalent. */
+#if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_THREADS)
+# define _SOLARIS_THREADS
+#endif
+#if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS)
+# define _SOLARIS_PTHREADS
+#endif
+#if defined(GC_IRIX_THREADS) && !defined(IRIX_THREADS)
+# define IRIX_THREADS
+#endif
+#if defined(GC_LINUX_THREADS) && !defined(LINUX_THREADS)
+# define LINUX_THREADS
+#endif
+#if defined(GC_WIN32_THREADS) && !defined(WIN32_THREADS)
+# define WIN32_THREADS
+#endif
+#if defined(GC_HPUX_THREADS) && !defined(HPUX_THREADS)
+# define HPUX_THREADS
+#endif
+
+/* Internally we use SOLARIS_THREADS to test for either old or pthreads. */
# if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS)
# define SOLARIS_THREADS
# endif
# if defined(IRIX_THREADS) && !defined(IRIX5)
--> inconsistent configuration
# endif
-# if defined(IRIX_JDK_THREADS) && !defined(IRIX5)
---> inconsistent configuration
-# endif
# if defined(LINUX_THREADS) && !defined(LINUX)
--> inconsistent configuration
# endif
@@ -1309,16 +1420,22 @@
# if defined(PCR) || defined(SRC_M3) || \
defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \
defined(IRIX_THREADS) || defined(LINUX_THREADS) || \
- defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
+ defined(HPUX_THREADS)
# define THREADS
# endif
-# if defined(HP_PA) || defined(M88K) || defined(POWERPC) \
- || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT)
+# if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(MACOSX) \
+ || (defined(I386) && defined(OS2)) || defined(UTS4) || defined(LINT) \
+ || defined(MSWINCE)
/* Use setjmp based hack to mark from callee-save registers. */
# define USE_GENERIC_PUSH_REGS
# endif
-# if defined(SPARC) && !defined(LINUX)
+# if defined(I386) && defined(LINUX)
+ /* SAVE_CALL_CHAIN is supported if the code is compiled to save */
+ /* frame pointers by default, i.e. no -fomit-frame-pointer flag. */
+/* # define SAVE_CALL_CHAIN */
+# endif
+# if defined(SPARC)
# define SAVE_CALL_CHAIN
# define ASM_CLEAR_CODE /* Stack clearing is crucial, and we */
/* include assembly code to do it well. */
diff --git a/solaris_threads.h b/include/private/solaris_threads.h
index b2cdb36e..b2cdb36e 100644
--- a/solaris_threads.h
+++ b/include/private/solaris_threads.h
diff --git a/include/private/specific.h b/include/private/specific.h
new file mode 100644
index 00000000..182a1cbe
--- /dev/null
+++ b/include/private/specific.h
@@ -0,0 +1,81 @@
+/*
+ * This is a reimplementation of a subset of the pthread_getspecific/setspecific
+ * interface. This appears to outperform the standard linuxthreads one
+ * by a significant margin.
+ * The major restriction is that each thread may only make a single
+ * pthread_setspecific call on a single key. (The current data structure
+ * doesn't really require that. The restriction should be easily removable.)
+ * We don't currently support the destruction functions, though that
+ * could be done.
+ * We also currently assume that only one pthread_setspecific call
+ * can be executed at a time, though that assumption would be easy to remove
+ * by adding a lock.
+ */
+
+#include <errno.h>
+
+/* Called during key creation or setspecific. */
+/* For the GC we already hold lock. */
+/* Currently allocated objects leak on thread exit. */
+/* That's hard to fix, but OK if we allocate garbage */
+/* collected memory. */
+#define MALLOC_CLEAR(n) GC_INTERNAL_MALLOC(n, NORMAL)
+#define PREFIXED(name) GC_##name
+
+#define TS_CACHE_SIZE 1024
+#define CACHE_HASH(n) (((((long)n) >> 8) ^ (long)n) & (TS_CACHE_SIZE - 1))
+#define TS_HASH_SIZE 1024
+#define HASH(n) (((((long)n) >> 8) ^ (long)n) & (TS_HASH_SIZE - 1))
+
+typedef struct thread_specific_entry {
+ unsigned long qtid; /* quick thread id, only for cache */
+ void * value;
+ pthread_t thread;
+ struct thread_specific_entry *next;
+} tse;
+
+
+/* We represent each thread-specific datum as two tables. The first is */
+/* a cache, index by a "quick thread identifier". The "quick" thread */
+/* identifier is an easy to compute value, which is guaranteed to */
+/* determine the thread, though a thread may correspond to more than */
+/* one value. We typically use the address of a page in the stack. */
+/* The second is a hash table, indexed by pthread_self(). It is used */
+/* only as a backup. */
+
+/* Return the "quick thread id". Default version. Assumes page size, */
+/* or at least thread stack separation, is at least 4K. */
+static __inline__ long quick_thread_id() {
+ int dummy;
+ return (long)(&dummy) >> 12;
+}
+
+typedef struct thread_specific_data {
+ tse * volatile cache[TS_CACHE_SIZE];
+ /* A faster index to the hash table */
+ tse * hash[TS_HASH_SIZE];
+ pthread_mutex_t lock;
+} tsd;
+
+typedef tsd * PREFIXED(key_t);
+
+extern int PREFIXED(key_create) (tsd ** key_ptr, void (* destructor)(void *));
+
+extern int PREFIXED(setspecific) (tsd * key, void * value);
+
+extern int PREFIXED(remove_specific) (tsd * key);
+
+/* An internal version of getspecific that assumes a cache miss. */
+void * PREFIXED(slow_getspecific) (tsd * key, unsigned long qtid,
+ tse * volatile * cache_entry);
+
+static __inline__ void * PREFIXED(getspecific) (tsd * key) {
+ long qtid = quick_thread_id();
+ unsigned hash_val = CACHE_HASH(qtid);
+ tse * volatile * entry_ptr = key -> cache + hash_val;
+ tse * entry = *entry_ptr; /* Must be loaded only once. */
+ if (entry -> qtid == qtid) return entry -> value;
+ return PREFIXED(slow_getspecific) (key, qtid, entry_ptr);
+}
+
+
diff --git a/linux_threads.c b/linux_threads.c
index 4b808823..fb8d9f70 100644
--- a/linux_threads.c
+++ b/linux_threads.c
@@ -2,6 +2,7 @@
* Copyright (c) 1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1996 by Silicon Graphics. All rights reserved.
* Copyright (c) 1998 by Fergus Henderson. All rights reserved.
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -17,24 +18,26 @@
* thread package for Linux which is included in libc6.
*
* This code relies on implementation details of LinuxThreads,
- * (i.e. properties not guaranteed by the Pthread standard):
- *
- * - the function GC_linux_thread_top_of_stack(void)
- * relies on the way LinuxThreads lays out thread stacks
- * in the address space.
+ * (i.e. properties not guaranteed by the Pthread standard),
+ * though this version now does less of that than the other Pthreads
+ * support code.
*
* Note that there is a lot of code duplication between linux_threads.c
- * and irix_threads.c; any changes made here may need to be reflected
- * there too.
+ * and thread support for some of the other Posix platforms; any changes
+ * made here may need to be reflected there too.
*/
/* #define DEBUG_THREADS 1 */
/* ANSI C requires that a compilation unit contains something */
-# include "gc_priv.h"
-# if defined(LINUX_THREADS)
+# if defined(GC_LINUX_THREADS) || defined(LINUX_THREADS)
+# include "private/gc_priv.h"
+# ifdef THREAD_LOCAL_ALLOC
+# include "private/specific.h"
+# endif
+# include <stdlib.h>
# include <pthread.h>
# include <sched.h>
# include <time.h>
@@ -44,8 +47,15 @@
# include <sys/time.h>
# include <semaphore.h>
# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <fcntl.h>
+
+#ifndef __GNUC__
+# define __inline__
+#endif
-#ifdef USE_LD_WRAP
+#ifdef GC_USE_LD_WRAP
# define WRAP_FUNC(f) __wrap_##f
# define REAL_FUNC(f) __real_##f
#else
@@ -75,6 +85,7 @@ void GC_print_sig_mask()
}
#endif
+
/* We use the allocation lock to protect thread-related data structures. */
/* The set of all known threads. We intercept thread creation and */
@@ -107,8 +118,210 @@ typedef struct GC_Thread_Rep {
/* Used only to avoid premature */
/* reclamation of any data it might */
/* reference. */
+# ifdef THREAD_LOCAL_ALLOC
+# if CCP_WORDSZ == 64 && defined(ALIGN_DOUBLE)
+# define GRANULARITY 16
+# else
+# define GRANULARITY 8
+# endif
+# define NFREELISTS 20
+ /* The ith free list corresponds to size (i+1)*GRANULARITY */
+# define INDEX_FROM_BYTES(n) (ADD_SLOP(n) - 1)/GRANULARITY
+# ifdef ADD_BYTE_AT_END
+# define BYTES_FROM_INDEX(i) (((i) + 1) * GRANULARITY - 1)
+# else
+# define BYTES_FROM_INDEX(i) (((i) + 1) * GRANULARITY)
+# endif
+# define SMALL_ENOUGH(bytes) (ADD_SLOP(bytes) <= NFREELISTS*GRANULARITY)
+ ptr_t ptrfree_freelists[NFREELISTS];
+ ptr_t normal_freelists[NFREELISTS];
+# ifdef GC_GCJ_SUPPORT
+ ptr_t gcj_freelists[NFREELISTS];
+# endif
+ /* Free lists contain either a pointer or a small count */
+ /* reflecting the number of granules allocated at that */
+ /* size. */
+ /* 0 ==> thread-local allocation in use, free list */
+ /* empty. */
+ /* > 0, <= DIRECT_GRANULES ==> Using global allocation, */
+ /* too few objects of this size have been */
+ /* allocated by this thread. */
+ /* >= HBLKSIZE => pointer to nonempty free list. */
+ /* > DIRECT_GRANULES, < HBLKSIZE ==> transition to */
+ /* local alloc, equivalent to 0. */
+# define DIRECT_GRANULES 1024
+ /* Don't use local free lists for up to this much */
+ /* allocation. */
+# endif
} * GC_thread;
+# ifdef THREAD_LOCAL_ALLOC
+
+GC_key_t GC_thread_key;
+
+static GC_bool keys_initialized;
+
+/* Recover the contents of the freelist array p */
+/* Could be improved, or perhaps deleted. */
+/* This is mostly a placeholder for now. */
+static void return_freelists(ptr_t *fl)
+{
+ int i;
+ ptr_t q, next;
+ for (i = 0; i < NFREELISTS; ++i) {
+ for (q = fl[i]; 0 != q; q = next) {
+ next = obj_link(q);
+ GC_free(q);
+ }
+ }
+}
+
+/* Each thread structure must be initialized. */
+/* This call must be made from the new thread. */
+/* Caller holds allocation lock. */
+void GC_init_thread_local(GC_thread p)
+{
+ int i;
+
+ if (!keys_initialized) {
+ if (0 != GC_key_create(&GC_thread_key, 0)) {
+ ABORT("Failed to create key for local allocator");
+ }
+ keys_initialized = TRUE;
+ }
+ if (0 != GC_setspecific(GC_thread_key, p)) {
+ ABORT("Failed to set thread specific allocation pointers");
+ }
+ for (i = 0; i < NFREELISTS; ++i) {
+ p -> ptrfree_freelists[i] = (ptr_t)1;
+ p -> normal_freelists[i] = (ptr_t)1;
+# ifdef GC_GCJ_SUPPORT
+ p -> gcj_freelists[i] = (ptr_t)1;
+# endif
+ }
+}
+
+void GC_destroy_thread_local(GC_thread p)
+{
+ return_freelists(p -> ptrfree_freelists);
+ return_freelists(p -> normal_freelists);
+# ifdef GC_GCJ_SUPPORT
+ return_freelists(p -> gcj_freelists);
+# endif
+}
+
+extern GC_PTR GC_generic_malloc_many();
+
+
+GC_PTR GC_local_malloc(size_t bytes)
+{
+ if (!SMALL_ENOUGH(bytes)) {
+ return(GC_malloc(bytes));
+ } else {
+ int index = INDEX_FROM_BYTES(bytes);
+ ptr_t * my_fl;
+ ptr_t my_entry;
+
+ my_fl = ((GC_thread)GC_getspecific(GC_thread_key))
+ -> normal_freelists + index;
+ my_entry = *my_fl;
+ if ((word)my_entry >= HBLKSIZE) {
+ GC_PTR result = (GC_PTR)my_entry;
+ *my_fl = obj_link(my_entry);
+ obj_link(my_entry) = 0;
+ return result;
+ } else if ((word)my_entry - 1 < DIRECT_GRANULES) {
+ *my_fl = my_entry + index + 1;
+ return GC_malloc(bytes);
+ } else {
+ my_entry = GC_generic_malloc_many(BYTES_FROM_INDEX(index),
+ NORMAL);
+ *my_fl = my_entry;
+ if (my_entry == 0) return GC_oom_fn(bytes);
+ return GC_local_malloc(bytes);
+ }
+ }
+}
+
+GC_PTR GC_local_malloc_atomic(size_t bytes)
+{
+ if (!SMALL_ENOUGH(bytes)) {
+ return(GC_malloc_atomic(bytes));
+ } else {
+ int index = INDEX_FROM_BYTES(bytes);
+ ptr_t * my_fl = ((GC_thread)GC_getspecific(GC_thread_key))
+ -> ptrfree_freelists + index;
+ ptr_t my_entry = *my_fl;
+ if ((word)my_entry >= HBLKSIZE) {
+ GC_PTR result = (GC_PTR)my_entry;
+ *my_fl = obj_link(my_entry);
+ return result;
+ } else if ((word)my_entry - 1 < DIRECT_GRANULES) {
+ *my_fl = my_entry + index + 1;
+ return GC_malloc_atomic(bytes);
+ } else {
+ my_entry = GC_generic_malloc_many(BYTES_FROM_INDEX(index),
+ PTRFREE);
+ *my_fl = my_entry;
+ if (my_entry == 0) return GC_oom_fn(bytes);
+ return GC_local_malloc_atomic(bytes);
+ }
+ }
+}
+
+#ifdef GC_GCJ_SUPPORT
+
+#include "include/gc_gcj.h"
+
+#ifdef GC_ASSERTIONS
+ extern GC_bool GC_gcj_malloc_initialized;
+#endif
+
+extern int GC_gcj_kind;
+
+GC_PTR GC_local_gcj_malloc(size_t bytes,
+ void * ptr_to_struct_containing_descr)
+{
+ GC_ASSERT(GC_gcj_malloc_initialized);
+ if (!SMALL_ENOUGH(bytes)) {
+ return GC_gcj_malloc(bytes, ptr_to_struct_containing_descr);
+ } else {
+ int index = INDEX_FROM_BYTES(bytes);
+ ptr_t * my_fl = ((GC_thread)GC_getspecific(GC_thread_key))
+ -> gcj_freelists + index;
+ ptr_t my_entry = *my_fl;
+ if ((word)my_entry >= HBLKSIZE) {
+ GC_PTR result = (GC_PTR)my_entry;
+ GC_ASSERT(!GC_incremental);
+ /* We assert that any concurrent marker will stop us. */
+ /* Thus it is impossible for a mark procedure to see the */
+ /* allocation of the next object, but to see this object */
+ /* still containing a free list pointer. Otherwise the */
+ /* marker might find a random "mark descriptor". */
+ *my_fl = obj_link(my_entry);
+ *(void **)result = ptr_to_struct_containing_descr;
+ return result;
+ } else if ((word)my_entry - 1 < DIRECT_GRANULES) {
+ *my_fl = my_entry + index + 1;
+ return GC_gcj_malloc(bytes, ptr_to_struct_containing_descr);
+ } else {
+ my_entry = GC_generic_malloc_many(BYTES_FROM_INDEX(index),
+ GC_gcj_kind);
+ *my_fl = my_entry;
+ if (my_entry == 0) return GC_oom_fn(bytes);
+ return GC_gcj_malloc(bytes, ptr_to_struct_containing_descr);
+ }
+ }
+}
+
+#endif /* GC_GCJ_SUPPORT */
+
+# else /* !THREAD_LOCAL_ALLOC */
+
+# define GC_destroy_thread_local(t)
+
+# endif /* !THREAD_LOCAL_ALLOC */
+
GC_thread GC_lookup_thread(pthread_t id);
/*
@@ -121,16 +334,32 @@ GC_thread GC_lookup_thread(pthread_t id);
* so we need to reuse something else. I chose SIGPWR.
* (Perhaps SIGUNUSED would be a better choice.)
*/
-#define SIG_SUSPEND SIGPWR
+#ifndef SIG_SUSPEND
+# ifdef HPUX_THREADS
+# define SIG_SUSPEND _SIGRTMIN + 6
+# else
+# define SIG_SUSPEND SIGPWR
+# endif
+#endif
+
+#ifndef SIG_THR_RESTART
+# ifdef HPUX_THREADS
+# define SIG_THR_RESTART _SIGRTMIN + 5
+# else
+# define SIG_THR_RESTART SIGXCPU
+# endif
+#endif
-#define SIG_RESTART SIGXCPU
+/* SPARC/Linux doesn't properly define SIGPWR in <signal.h>.
+ * It is aliased to SIGLOST in asm/signal.h, though. */
+#if defined(SPARC) && !defined(SIGPWR)
+# define SIGPWR SIGLOST
+#endif
sem_t GC_suspend_ack_sem;
+#ifndef HPUX_THREADS
/*
-GC_linux_thread_top_of_stack() relies on implementation details of
-LinuxThreads, namely that thread stacks are allocated on 2M boundaries
-and grow to no more than 2M.
To make sure that we're using LinuxThreads and not some other thread
package, we generate a dummy reference to `pthread_kill_other_threads_np'
(was `__pthread_initial_thread_bos' but that disappeared),
@@ -138,23 +367,79 @@ which is a symbol defined in LinuxThreads, but (hopefully) not in other
thread packages.
*/
void (*dummy_var_to_force_linux_threads)() = pthread_kill_other_threads_np;
+#endif /* !HPUX_THREADS */
+
+#if defined(SPARC) || defined(IA64)
+ extern word GC_save_regs_in_stack();
+#endif
+
+long GC_nprocs = 1; /* Number of processors. We may not have */
+ /* access to all of them, but this is as good */
+ /* a guess as any ... */
-#define LINUX_THREADS_STACK_SIZE (2 * 1024 * 1024)
+#ifdef PARALLEL_MARK
-static inline ptr_t GC_linux_thread_top_of_stack(void)
+void * GC_mark_thread(void * dummy)
{
- char *sp = GC_approx_sp();
- ptr_t tos = (ptr_t) (((unsigned long)sp | (LINUX_THREADS_STACK_SIZE - 1)) + 1);
-#if DEBUG_THREADS
- GC_printf1("SP = %lx\n", (unsigned long)sp);
- GC_printf1("TOS = %lx\n", (unsigned long)tos);
-#endif
- return tos;
+ word my_mark_no = 0;
+
+ for (;; ++my_mark_no) {
+ /* GC_mark_no is passed only to allow GC_help_marker to terminate */
+ /* promptly. This is important if it were called from the signal */
+ /* handler or from the GC lock acquisition code. Under Linux, it's */
+ /* not safe to call it from a signal handler, since it uses mutexes */
+ /* and condition variables. Since it is called only here, the */
+ /* argument is unnecessary. */
+ if (my_mark_no < GC_mark_no || my_mark_no > GC_mark_no + 2) {
+ /* resynchronize if we get far off, e.g. because GC_mark_no */
+ /* wrapped. */
+ my_mark_no = GC_mark_no;
+ }
+# ifdef DEBUG_THREADS
+ GC_printf1("Starting mark helper for mark number %ld\n", my_mark_no);
+# endif
+ GC_help_marker(my_mark_no);
+ }
}
-#ifdef IA64
- extern word GC_save_regs_in_stack();
-#endif
+extern long GC_markers; /* Number of mark threads we would */
+ /* like to have. Includes the */
+ /* initiating thread. */
+
+#define MAX_MARKERS 16
+
+pthread_t GC_mark_threads[MAX_MARKERS];
+
+#define PTHREAD_CREATE REAL_FUNC(pthread_create)
+
+static void start_mark_threads()
+{
+ unsigned i;
+ pthread_attr_t attr;
+
+ if (GC_markers > MAX_MARKERS) {
+ WARN("Limiting number of mark threads\n", 0);
+ GC_markers = MAX_MARKERS;
+ }
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+# ifdef PRINTSTATS
+ GC_printf1("Starting %ld marker threads\n", GC_markers - 1);
+# endif
+ for (i = 0; i < GC_markers - 1; ++i) {
+ if (0 != PTHREAD_CREATE(GC_mark_threads + i, &attr, GC_mark_thread, 0)) {
+ WARN("Marker thread creation failed.\n", 0);
+ }
+ }
+}
+
+#else /* !PARALLEL_MARK */
+
+static __inline__ void start_mark_threads()
+{
+}
+
+#endif /* !PARALLEL_MARK */
void GC_suspend_handler(int sig)
{
@@ -165,6 +450,12 @@ void GC_suspend_handler(int sig)
sigset_t old_sigs;
int i;
sigset_t mask;
+# ifdef PARALLEL_MARK
+ word my_mark_no = GC_mark_no;
+ /* Marker can't proceed until we acknowledge. Thus this is */
+ /* guaranteed to be the mark_no correspending to our */
+ /* suspension, i.e. the marker can't have incremented it yet. */
+# endif
if (sig != SIG_SUSPEND) ABORT("Bad signal in suspend_handler");
@@ -177,7 +468,11 @@ void GC_suspend_handler(int sig)
/* of a thread which holds the allocation lock in order */
/* to stop the world. Thus concurrent modification of the */
/* data structure is impossible. */
- me -> stack_ptr = (ptr_t)(&dummy);
+# ifdef SPARC
+ me -> stack_ptr = (ptr_t)GC_save_regs_in_stack();
+# else
+ me -> stack_ptr = (ptr_t)(&dummy);
+# endif
# ifdef IA64
me -> backing_store_ptr = (ptr_t)GC_save_regs_in_stack();
# endif
@@ -188,11 +483,11 @@ void GC_suspend_handler(int sig)
sem_post(&GC_suspend_ack_sem);
/* Wait until that thread tells us to restart by sending */
- /* this thread a SIG_RESTART signal. */
- /* SIG_RESTART should be masked at this point. Thus there */
+ /* this thread a SIG_THR_RESTART signal. */
+ /* SIG_THR_RESTART should be masked at this point. Thus there */
/* is no race. */
if (sigfillset(&mask) != 0) ABORT("sigfillset() failed");
- if (sigdelset(&mask, SIG_RESTART) != 0) ABORT("sigdelset() failed");
+ if (sigdelset(&mask, SIG_THR_RESTART) != 0) ABORT("sigdelset() failed");
# ifdef NO_SIGNALS
if (sigdelset(&mask, SIGINT) != 0) ABORT("sigdelset() failed");
if (sigdelset(&mask, SIGQUIT) != 0) ABORT("sigdelset() failed");
@@ -201,7 +496,7 @@ void GC_suspend_handler(int sig)
do {
me->signal = 0;
sigsuspend(&mask); /* Wait for signal */
- } while (me->signal != SIG_RESTART);
+ } while (me->signal != SIG_THR_RESTART);
#if DEBUG_THREADS
GC_printf1("Continuing 0x%x\n", my_thread);
@@ -212,15 +507,15 @@ void GC_restart_handler(int sig)
{
GC_thread me;
- if (sig != SIG_RESTART) ABORT("Bad signal in suspend_handler");
+ if (sig != SIG_THR_RESTART) ABORT("Bad signal in suspend_handler");
- /* Let the GC_suspend_handler() know that we got a SIG_RESTART. */
+ /* Let the GC_suspend_handler() know that we got a SIG_THR_RESTART. */
/* The lookup here is safe, since I'm doing this on behalf */
/* of a thread which holds the allocation lock in order */
/* to stop the world. Thus concurrent modification of the */
/* data structure is impossible. */
me = GC_lookup_thread(pthread_self());
- me->signal = SIG_RESTART;
+ me->signal = SIG_THR_RESTART;
/*
** Note: even if we didn't do anything useful here,
@@ -255,7 +550,7 @@ GC_thread GC_new_thread(pthread_t id)
/* Dont acquire allocation lock, since we may already hold it. */
} else {
result = (struct GC_Thread_Rep *)
- GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
+ GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
}
if (result == 0) return(0);
result -> id = id;
@@ -278,6 +573,7 @@ void GC_delete_thread(pthread_t id)
prev = p;
p = p -> next;
}
+ GC_destroy_thread_local(p);
if (prev == 0) {
GC_threads[hv] = p -> next;
} else {
@@ -330,6 +626,15 @@ void GC_stop_world()
register int n_live_threads = 0;
register int result;
+ /* Make sure all free list construction has stopped before we start. */
+ /* No new construction can start, since free list construction is */
+ /* required to acquire and release the GC lock before it starts, */
+ /* and we have the lock. */
+# ifdef PARALLEL_MARK
+ GC_acquire_mark_lock();
+ GC_ASSERT(GC_fl_builder_count == 0);
+ /* We should have previously waited for it to become zero. */
+# endif /* PARALLEL_MARK */
for (i = 0; i < THREAD_TABLE_SZ; i++) {
for (p = GC_threads[i]; p != 0; p = p -> next) {
if (p -> id != my_thread) {
@@ -355,6 +660,9 @@ void GC_stop_world()
for (i = 0; i < n_live_threads; i++) {
sem_wait(&GC_suspend_ack_sem);
}
+# ifdef PARALLEL_MARK
+ GC_release_mark_lock();
+# endif
#if DEBUG_THREADS
GC_printf1("World stopped 0x%x\n", pthread_self());
#endif
@@ -381,7 +689,7 @@ void GC_start_world()
#if DEBUG_THREADS
GC_printf1("Sending restart signal to 0x%x\n", p -> id);
#endif
- result = pthread_kill(p -> id, SIG_RESTART);
+ result = pthread_kill(p -> id, SIG_THR_RESTART);
switch(result) {
case ESRCH:
/* Not really there anymore. Possible? */
@@ -425,7 +733,11 @@ void GC_push_all_stacks()
for (p = GC_threads[i]; p != 0; p = p -> next) {
if (p -> flags & FINISHED) continue;
if (pthread_equal(p -> id, me)) {
- lo = GC_approx_sp();
+# ifdef SPARC
+ lo = (ptr_t)GC_save_regs_in_stack();
+# else
+ lo = GC_approx_sp();
+# endif
IF_IA64(bs_hi = (ptr_t)GC_save_regs_in_stack();)
} else {
lo = p -> stack_ptr;
@@ -445,7 +757,12 @@ void GC_push_all_stacks()
(unsigned long) lo, (unsigned long) hi);
#endif
if (0 == lo) ABORT("GC_push_all_stacks: sp not set!\n");
- GC_push_all_stack(lo, hi);
+# ifdef STACK_GROWS_UP
+ /* We got them backwards! */
+ GC_push_all_stack(hi, lo);
+# else
+ GC_push_all_stack(lo, hi);
+# endif
# ifdef IA64
if (pthread_equal(p -> id, me)) {
GC_push_all_eager(bs_lo, bs_hi);
@@ -457,6 +774,41 @@ void GC_push_all_stacks()
}
}
+/* Return the number of processors, or i<= 0 if it can't be determined. */
+int GC_get_nprocs()
+{
+ /* Should be "return sysconf(_SC_NPROCESSORS_ONLN);" but that */
+ /* appears to be buggy in many cases. */
+ /* We look for lines "cpu<n>" in /proc/stat. */
+# define STAT_BUF_SIZE 4096
+# if defined(GC_USE_LD_WRAP) && defined(MPROTECT_VDB)
+# define STAT_READ __real_read
+# else
+# define STAT_READ read
+# endif
+ char stat_buf[STAT_BUF_SIZE];
+ int f;
+ char c;
+ word result = 1;
+ /* Some old kernels only have a single "cpu nnnn ..." */
+ /* entry in /proc/stat. We identify those as */
+ /* uniprocessors. */
+ size_t i, len = 0;
+
+ f = open("/proc/stat", O_RDONLY);
+ if (f < 0 || (len = STAT_READ(f, stat_buf, STAT_BUF_SIZE)) < 100) {
+ WARN("Couldn't read /proc/stat\n", 0);
+ return -1;
+ }
+ for (i = 0; i < len - 100; ++i) {
+ if (stat_buf[i] == '\n' && stat_buf[i+1] == 'c'
+ && stat_buf[i+2] == 'p' && stat_buf[i+3] == 'u') {
+ int cpu_no = atoi(stat_buf + i + 4);
+ if (cpu_no >= result) result = cpu_no + 1;
+ }
+ }
+ return result;
+}
/* We hold the allocation lock. */
void GC_thr_init()
@@ -483,23 +835,77 @@ void GC_thr_init()
}
# endif
- /* SIG_RESTART is unmasked by the handler when necessary. */
+ /* SIG_THR_RESTART is unmasked by the handler when necessary. */
act.sa_handler = GC_suspend_handler;
if (sigaction(SIG_SUSPEND, &act, NULL) != 0) {
ABORT("Cannot set SIG_SUSPEND handler");
}
act.sa_handler = GC_restart_handler;
- if (sigaction(SIG_RESTART, &act, NULL) != 0) {
- ABORT("Cannot set SIG_SUSPEND handler");
+ if (sigaction(SIG_THR_RESTART, &act, NULL) != 0) {
+ ABORT("Cannot set SIG_THR_RESTART handler");
}
/* Add the initial thread, so we can stop it. */
t = GC_new_thread(pthread_self());
t -> stack_ptr = (ptr_t)(&dummy);
t -> flags = DETACHED | MAIN_THREAD;
+
+ /* Set GC_nprocs. */
+ {
+ char * nprocs_string = getenv("GC_NPROCS");
+ GC_nprocs = -1;
+ if (nprocs_string != NULL) GC_nprocs = atoi(nprocs_string);
+ }
+ if (GC_nprocs <= 0) {
+# ifdef HPUX_THREADS
+ GC_nprocs = 1;
+# else
+ GC_nprocs = GC_get_nprocs();
+# endif
+ }
+ if (GC_nprocs <= 0) {
+ WARN("GC_get_nprocs() returned %ld\n", GC_nprocs);
+ GC_nprocs = 2;
+# ifdef PARALLEL_MARK
+ GC_markers = 1;
+# endif
+ } else {
+# ifdef PARALLEL_MARK
+ GC_markers = GC_nprocs;
+# endif
+ }
+# ifdef PRINTSTATS
+ GC_printf2("Number of processors = %ld, "
+ "number of marker threads = %ld\n", GC_nprocs, GC_markers);
+# endif
+# ifdef PARALLEL_MARK
+ if (GC_markers == 1) {
+ GC_parallel = FALSE;
+# ifdef PRINTSTATS
+ GC_printf0("Single marker thread, turning off parallel marking\n");
+# endif
+ } else {
+ GC_parallel = TRUE;
+ }
+# endif
+
+ /* If we are using a parallel marker, start the helper threads. */
+# ifdef PARALLEL_MARK
+ if (GC_parallel) start_mark_threads();
+# endif
+}
+
+/* Initializations that might require allocation */
+void GC_thr_late_init()
+{
+ /* Initialize thread local free lists if used. */
+# ifdef THREAD_LOCAL_ALLOC
+ GC_init_thread_local(GC_lookup_thread(pthread_self()));
+# endif
}
+
int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset)
{
sigset_t fudged_set;
@@ -533,6 +939,9 @@ void GC_thread_exit_proc(void *arg)
} else {
me -> flags |= FINISHED;
}
+# ifdef THREAD_LOCAL_ALLOC
+ GC_remove_specific(GC_thread_key);
+# endif
if (GC_incremental && GC_collection_in_progress()) {
int old_gc_no = GC_gc_no;
@@ -600,7 +1009,7 @@ void * GC_start_routine(void * arg)
/* Needs to be plausible, since an asynchronous stack mark */
/* should not crash. */
# else
- me -> stack_end = (ptr_t)(((word)(&dummy) & ~(GC_page_size - 1));
+ me -> stack_end = (ptr_t)((word)(&dummy) & ~(GC_page_size - 1));
me -> stack_ptr = me -> stack_end + 0x10;
# endif
/* This is dubious, since we may be more than a page into the stack, */
@@ -619,6 +1028,11 @@ void * GC_start_routine(void * arg)
start_arg = si -> arg;
sem_post(&(si -> registered));
pthread_cleanup_push(GC_thread_exit_proc, si);
+# ifdef THREAD_LOCAL_ALLOC
+ LOCK();
+ GC_init_thread_local(me);
+ UNLOCK();
+# endif
result = (*start)(start_arg);
#if DEBUG_THREADS
GC_printf1("Finishing thread 0x%x\n", pthread_self());
@@ -632,6 +1046,41 @@ void * GC_start_routine(void * arg)
return(result);
}
+# ifdef HPUX_THREADS
+ /* pthread_attr_t is not a structure, thus a simple structure copy */
+ /* won't work. */
+ static void copy_attr(pthread_attr_t * pa_ptr,
+ const pthread_attr_t * source) {
+ int tmp;
+ size_t stmp;
+ void * vtmp;
+ struct sched_param sp_tmp;
+ pthread_spu_t ps_tmp;
+ (void) pthread_attr_init(pa_ptr);
+ (void) pthread_attr_getdetachstate(source, &tmp);
+ (void) pthread_attr_setdetachstate(pa_ptr, tmp);
+ (void) pthread_attr_getinheritsched(source, &tmp);
+ (void) pthread_attr_setinheritsched(pa_ptr, tmp);
+ (void) pthread_attr_getschedpolicy(source, &tmp);
+ (void) pthread_attr_setschedpolicy(pa_ptr, tmp);
+ (void) pthread_attr_getstacksize(source, &stmp);
+ (void) pthread_attr_setstacksize(pa_ptr, stmp);
+ (void) pthread_attr_getguardsize(source, &stmp);
+ (void) pthread_attr_setguardsize(pa_ptr, stmp);
+ (void) pthread_attr_getstackaddr(source, &vtmp);
+ (void) pthread_attr_setstackaddr(pa_ptr, vtmp);
+ (void) pthread_attr_getscope(source, &tmp);
+ (void) pthread_attr_setscope(pa_ptr, tmp);
+ (void) pthread_attr_getschedparam(source, &sp_tmp);
+ (void) pthread_attr_setschedparam(pa_ptr, &sp_tmp);
+ (void) pthread_attr_getprocessor_np(source, &ps_tmp, &tmp);
+ (void) pthread_attr_setprocessor_np(pa_ptr, ps_tmp, tmp);
+ }
+# else
+# define copy_attr(pa_ptr, source) *(pa_ptr) = *(source)
+# endif
+
+
int
WRAP_FUNC(pthread_create)(pthread_t *new_thread,
const pthread_attr_t *attr,
@@ -659,7 +1108,7 @@ WRAP_FUNC(pthread_create)(pthread_t *new_thread,
stack = 0;
(void) pthread_attr_init(&new_attr);
} else {
- new_attr = *attr;
+ copy_attr(&new_attr, attr);
}
pthread_attr_getdetachstate(&new_attr, &detachstate);
if (PTHREAD_CREATE_DETACHED == detachstate) my_flags |= DETACHED;
@@ -684,13 +1133,66 @@ WRAP_FUNC(pthread_create)(pthread_t *new_thread,
return(result);
}
-#if defined(USE_SPIN_LOCK)
+/* Spend a few cycles in a way that can't introduce contention with */
+/* othre threads. */
+void GC_pause()
+{
+ volatile unsigned junk = 3;
+
+ junk *= junk; junk *= junk; junk *= junk; junk *= junk;
+}
+
+#define SPIN_MAX 1024 /* Maximum number of calls to GC_pause before */
+ /* give up. */
VOLATILE GC_bool GC_collecting = 0;
/* A hint that we're in the collector and */
/* holding the allocation lock for an */
/* extended period. */
+#if !defined(USE_SPIN_LOCK) || defined(PARALLEL_MARK)
+/* If we don't want to use the below spinlock implementation, either */
+/* because we don't have a GC_test_and_set implementation, or because */
+/* we don't want to risk sleeping, we can still try spinning on */
+/* pthread_mutex_trylock for a while. This appears to be very */
+/* beneficial in many cases. */
+/* I suspect that under high contention this is nearly always better */
+/* than the spin lock. But it's a bit slower on a uniprocessor. */
+/* Hence we still default to the spin lock. */
+/* This is also used to acquire the mark lock for the parallel */
+/* marker. */
+
+/* Here we use a strict exponential backoff scheme. I don't know */
+/* whether that's better or worse than the above. We eventually */
+/* yield by calling pthread_mutex_lock(); it never makes sense to */
+/* explicitly sleep. */
+
+void GC_generic_lock(pthread_mutex_t * lock)
+{
+ unsigned pause_length = 1;
+ unsigned i;
+
+ if (0 == pthread_mutex_trylock(lock)) return;
+ for (; pause_length <= SPIN_MAX; pause_length <<= 1) {
+ for (i = 0; i < pause_length; ++i) {
+ GC_pause();
+ }
+ switch(pthread_mutex_trylock(lock)) {
+ case 0:
+ return;
+ case EBUSY:
+ break;
+ default:
+ ABORT("Unexpected error from pthread_mutex_trylock");
+ }
+ }
+ pthread_mutex_lock(lock);
+}
+
+#endif /* !USE_SPIN_LOCK || PARALLEL_MARK */
+
+#if defined(USE_SPIN_LOCK)
+
/* Reasonably fast spin locks. Basically the same implementation */
/* as STL alloc.h. This isn't really the right way to do this. */
/* but until the POSIX scheduling mess gets straightened out ... */
@@ -701,25 +1203,22 @@ volatile unsigned int GC_allocate_lock = 0;
void GC_lock()
{
# define low_spin_max 30 /* spin cycles if we suspect uniprocessor */
-# define high_spin_max 1000 /* spin cycles for multiprocessor */
+# define high_spin_max SPIN_MAX /* spin cycles for multiprocessor */
static unsigned spin_max = low_spin_max;
unsigned my_spin_max;
static unsigned last_spins = 0;
unsigned my_last_spins;
- volatile unsigned junk;
-# define PAUSE junk *= junk; junk *= junk; junk *= junk; junk *= junk
int i;
if (!GC_test_and_set(&GC_allocate_lock)) {
return;
}
- junk = 0;
my_spin_max = spin_max;
my_last_spins = last_spins;
for (i = 0; i < my_spin_max; i++) {
- if (GC_collecting) goto yield;
+ if (GC_collecting || GC_nprocs == 1) goto yield;
if (i < my_last_spins/2 || GC_allocate_lock) {
- PAUSE;
+ GC_pause();
continue;
}
if (!GC_test_and_set(&GC_allocate_lock)) {
@@ -749,8 +1248,8 @@ yield:
} else {
struct timespec ts;
- if (i > 26) i = 26;
- /* Don't wait for more than about 60msecs, even */
+ if (i > 24) i = 24;
+ /* Don't wait for more than about 15msecs, even */
/* under extreme contention. */
ts.tv_sec = 0;
ts.tv_nsec = 1 << i;
@@ -759,7 +1258,125 @@ yield:
}
}
-#endif /* known architecture */
+#else /* !USE_SPINLOCK */
+
+void GC_lock()
+{
+ if (1 == GC_nprocs || GC_collecting) {
+ pthread_mutex_lock(&GC_allocate_ml);
+ } else {
+ GC_generic_lock(&GC_allocate_ml);
+ }
+}
+
+#endif /* !USE_SPINLOCK */
+
+#ifdef PARALLEL_MARK
+
+#ifdef GC_ASSERTIONS
+ pthread_t GC_mark_lock_holder = NO_THREAD;
+#endif
+
+#ifdef GENERIC_COMPARE_AND_SWAP
+ pthread_mutex_t GC_compare_and_swap_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+#ifdef IA64
+ /* Ugly workaround for a linux threads bug in the final versions */
+ /* of glibc2.1. Pthread_mutex_trylock sets the mutex owner */
+ /* field even when it fails to acquire the mutex. This causes */
+ /* pthread_cond_wait to die. Remove for glibc2.2. */
+ /* According to the man page, we should use */
+ /* PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP, but that isn't actually */
+ /* defined. */
+ static pthread_mutex_t mark_mutex =
+ {0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP, {0, 0}};
+#else
+ static pthread_mutex_t mark_mutex = PTHREAD_MUTEX_INITIALIZER;
+#endif
+
+static pthread_cond_t mark_cv = PTHREAD_COND_INITIALIZER;
+
+static pthread_cond_t builder_cv = PTHREAD_COND_INITIALIZER;
+
+void GC_acquire_mark_lock()
+{
+/*
+ if (pthread_mutex_lock(&mark_mutex) != 0) {
+ ABORT("pthread_mutex_lock failed");
+ }
+*/
+ GC_generic_lock(&mark_mutex);
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = pthread_self();
+# endif
+}
+
+void GC_release_mark_lock()
+{
+ GC_ASSERT(GC_mark_lock_holder == pthread_self());
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = NO_THREAD;
+# endif
+ if (pthread_mutex_unlock(&mark_mutex) != 0) {
+ ABORT("pthread_mutex_unlock failed");
+ }
+}
+
+void GC_wait_marker()
+{
+ GC_ASSERT(GC_mark_lock_holder == pthread_self());
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = NO_THREAD;
+# endif
+ if (pthread_cond_wait(&mark_cv, &mark_mutex) != 0) {
+ ABORT("pthread_cond_wait failed");
+ }
+ GC_ASSERT(GC_mark_lock_holder == NO_THREAD);
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = pthread_self();
+# endif
+}
+
+void GC_wait_builder()
+{
+ GC_ASSERT(GC_mark_lock_holder == pthread_self());
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = NO_THREAD;
+# endif
+ if (pthread_cond_wait(&builder_cv, &mark_mutex) != 0) {
+ ABORT("pthread_cond_wait failed");
+ }
+ GC_ASSERT(GC_mark_lock_holder == NO_THREAD);
+# ifdef GC_ASSERTIONS
+ GC_mark_lock_holder = pthread_self();
+# endif
+}
+
+void GC_notify_all_marker()
+{
+ if (pthread_cond_broadcast(&mark_cv) != 0) {
+ ABORT("pthread_cond_broadcast failed");
+ }
+}
+
+void GC_notify_all_builder()
+{
+ GC_ASSERT(GC_mark_lock_holder == pthread_self());
+ if (pthread_cond_broadcast(&builder_cv) != 0) {
+ ABORT("pthread_cond_broadcast failed");
+ }
+}
+
+void GC_wait_for_reclaim()
+{
+ GC_acquire_mark_lock();
+ while (GC_fl_builder_count > 0) {
+ GC_wait_builder();
+ }
+ GC_release_mark_lock();
+}
+#endif /* PARALLEL_MARK */
# endif /* LINUX_THREADS */
diff --git a/mach_dep.c b/mach_dep.c
index 12c3f076..137bdabf 100644
--- a/mach_dep.c
+++ b/mach_dep.c
@@ -12,7 +12,7 @@
* modified is included with the above copyright notice.
*/
/* Boehm, November 17, 1995 12:13 pm PST */
-# include "gc_priv.h"
+# include "private/gc_priv.h"
# include <stdio.h>
# include <setjmp.h>
# if defined(OS2) || defined(CX_UX)
@@ -402,7 +402,8 @@ ptr_t cold_gc_frame;
for (; (char *)i < lim; i++) {
*i = 0;
}
-# if defined(POWERPC) || defined(MSWIN32) || defined(UTS4) || defined(LINUX)
+# if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \
+ || defined(UTS4) || defined(LINUX)
(void) setjmp(regs);
# else
(void) _setjmp(regs);
@@ -437,10 +438,16 @@ ptr_t cold_gc_frame;
asm(" .globl _GC_save_regs_in_stack");
asm("_GC_save_regs_in_stack:");
# endif
- asm(" ta 0x3 ! ST_FLUSH_WINDOWS");
- asm(" mov %sp,%o0");
- asm(" retl");
- asm(" nop");
+# if defined(__arch64__) || defined(__sparcv9)
+ asm(" save %sp,-128,%sp");
+ asm(" flushw");
+ asm(" ret");
+ asm(" restore %sp,2047+128,%o0");
+# else
+ asm(" ta 0x3 ! ST_FLUSH_WINDOWS");
+ asm(" retl");
+ asm(" mov %sp,%o0");
+# endif
# ifdef SVR4
asm(" .GC_save_regs_in_stack_end:");
asm(" .size GC_save_regs_in_stack,.GC_save_regs_in_stack_end-GC_save_regs_in_stack");
@@ -488,6 +495,21 @@ ptr_t cold_gc_frame;
asm("GC_clear_stack_inner:");
asm(".type GC_save_regs_in_stack,#function");
# endif
+#if defined(__arch64__) || defined(__sparcv9)
+ asm("mov %sp,%o2"); /* Save sp */
+ asm("add %sp,2047-8,%o3"); /* p = sp+bias-8 */
+ asm("add %o1,-2047-192,%sp"); /* Move sp out of the way, */
+ /* so that traps still work. */
+ /* Includes some extra words */
+ /* so we can be sloppy below. */
+ asm("loop:");
+ asm("stx %g0,[%o3]"); /* *(long *)p = 0 */
+ asm("cmp %o3,%o1");
+ asm("bgu,pt %xcc, loop"); /* if (p > limit) goto loop */
+ asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */
+ asm("retl");
+ asm("mov %o2,%sp"); /* Restore sp., delay slot */
+#else
asm("mov %sp,%o2"); /* Save sp */
asm("add %sp,-8,%o3"); /* p = sp-8 */
asm("clr %g1"); /* [g0,g1] = 0 */
@@ -502,6 +524,7 @@ ptr_t cold_gc_frame;
asm("add %o3,-8,%o3"); /* p -= 8 (delay slot) */
asm("retl");
asm("mov %o2,%sp"); /* Restore sp., delay slot */
+#endif /* old SPARC */
/* First argument = %o0 = return value */
# ifdef SVR4
asm(" .GC_clear_stack_inner_end:");
diff --git a/malloc.c b/malloc.c
index a5a93ad8..c757f426 100644
--- a/malloc.c
+++ b/malloc.c
@@ -14,7 +14,7 @@
/* Boehm, February 7, 1996 4:32 pm PST */
#include <stdio.h>
-#include "gc_priv.h"
+#include "private/gc_priv.h"
extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
void GC_extend_size_map(); /* in misc.c. */
@@ -32,7 +32,60 @@ register struct obj_kind * kind;
return(TRUE);
}
-/* allocate lb bytes for an object of kind. */
+/* Allocate a large block of size lw words. */
+/* The block is not cleared. */
+/* Flags is 0 or IGNORE_OFF_PAGE. */
+ptr_t GC_alloc_large(lw, k, flags)
+word lw;
+int k;
+unsigned char flags;
+{
+ struct hblk * h;
+ word n_blocks = OBJ_SZ_TO_BLOCKS(lw);
+ ptr_t result;
+
+ if (!GC_is_initialized) GC_init_inner();
+ /* Do our share of marking work */
+ if(GC_incremental && !GC_dont_gc)
+ GC_collect_a_little_inner((int)n_blocks);
+ h = GC_allochblk(lw, k, flags);
+# ifdef USE_MUNMAP
+ if (0 == h) {
+ GC_merge_unmapped();
+ h = GC_allochblk(lw, k, flags);
+ }
+# endif
+ while (0 == h && GC_collect_or_expand(n_blocks, (flags != 0))) {
+ h = GC_allochblk(lw, k, flags);
+ }
+ if (h == 0) {
+ result = 0;
+ } else {
+ result = (ptr_t) (h -> hb_body);
+ GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw;
+ }
+ return result;
+}
+
+
+/* Allocate a large block of size lb bytes. Clear if appropriate. */
+ptr_t GC_alloc_large_and_clear(lw, k, flags)
+word lw;
+int k;
+unsigned char flags;
+{
+ ptr_t result = GC_alloc_large(lw, k, flags);
+ word n_blocks = OBJ_SZ_TO_BLOCKS(lw);
+
+ if (0 == result) return 0;
+ if (GC_debugging_started || GC_obj_kinds[k].ok_init) {
+ /* Clear the whole block, in case of GC_realloc call. */
+ BZERO(result, n_blocks * HBLKSIZE - HDR_BYTES);
+ }
+ return result;
+}
+
+/* allocate lb bytes for an object of kind k. */
/* Should not be used to directly to allocate */
/* objects such as STUBBORN objects that */
/* require special handling on allocation. */
@@ -52,7 +105,7 @@ register ptr_t *opp;
lw = GC_size_map[lb];
# else
lw = ALIGNED_WORDS(lb);
- if (lw == 0) lw = 1;
+ if (lw == 0) lw = MIN_WORDS;
# endif
opp = &(kind -> ok_freelist[lw]);
if( (op = *opp) == 0 ) {
@@ -88,36 +141,13 @@ register ptr_t *opp;
*opp = obj_link(op);
obj_link(op) = 0;
} else {
- register struct hblk * h;
- register word n_blocks = divHBLKSZ(ADD_SLOP(lb)
- + HDR_BYTES + HBLKSIZE-1);
-
- if (!GC_is_initialized) GC_init_inner();
- /* Do our share of marking work */
- if(GC_incremental && !GC_dont_gc)
- GC_collect_a_little_inner((int)n_blocks);
lw = ROUNDED_UP_WORDS(lb);
- h = GC_allochblk(lw, k, 0);
-# ifdef USE_MUNMAP
- if (0 == h) {
- GC_merge_unmapped();
- h = GC_allochblk(lw, k, 0);
- }
-# endif
- while (0 == h && GC_collect_or_expand(n_blocks, FALSE)) {
- h = GC_allochblk(lw, k, 0);
- }
- if (h == 0) {
- op = 0;
- } else {
- op = (ptr_t) (h -> hb_body);
- GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw;
- }
+ op = (ptr_t)GC_alloc_large_and_clear(lw, k, 0);
}
GC_words_allocd += lw;
out:
- return((ptr_t)op);
+ return op;
}
ptr_t GC_generic_malloc(lb, k)
@@ -128,11 +158,32 @@ register int k;
DCL_LOCK_STATE;
GC_INVOKE_FINALIZERS();
- DISABLE_SIGNALS();
- LOCK();
- result = GC_generic_malloc_inner(lb, k);
- UNLOCK();
- ENABLE_SIGNALS();
+ if (SMALL_OBJ(lb)) {
+ DISABLE_SIGNALS();
+ LOCK();
+ result = GC_generic_malloc_inner((word)lb, k);
+ UNLOCK();
+ ENABLE_SIGNALS();
+ } else {
+ word lw;
+ word n_blocks;
+ GC_bool init;
+ lw = ROUNDED_UP_WORDS(lb);
+ n_blocks = OBJ_SZ_TO_BLOCKS(lw);
+ init = GC_obj_kinds[k].ok_init;
+ DISABLE_SIGNALS();
+ LOCK();
+ result = (ptr_t)GC_alloc_large(lw, k, 0);
+ if (GC_debugging_started) {
+ BZERO(result, n_blocks * HBLKSIZE - HDR_BYTES);
+ }
+ GC_words_allocd += lw;
+ UNLOCK();
+ ENABLE_SIGNALS();
+ if (init & !GC_debugging_started && 0 != result) {
+ BZERO(result, n_blocks * HBLKSIZE - HDR_BYTES);
+ }
+ }
if (0 == result) {
return((*GC_oom_fn)(lb));
} else {
@@ -303,7 +354,7 @@ int obj_kind;
sz = WORDS_TO_BYTES(sz);
orig_sz = sz;
- if (sz > WORDS_TO_BYTES(MAXOBJSZ)) {
+ if (sz > MAXOBJBYTES) {
/* Round it up to the next whole heap block */
register word descr;
@@ -315,7 +366,7 @@ int obj_kind;
if (GC_obj_kinds[obj_kind].ok_relocate_descr) descr += sz;
hhdr -> hb_descr = descr;
if (IS_UNCOLLECTABLE(obj_kind)) GC_non_gc_bytes += (sz - orig_sz);
- /* Extra area is already cleared by allochblk. */
+ /* Extra area is already cleared by GC_alloc_large_and_clear. */
}
if (ADD_SLOP(lb) <= sz) {
if (lb >= (sz >> 1)) {
diff --git a/mallocx.c b/mallocx.c
index c8426652..2fb5d303 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -2,6 +2,7 @@
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
* Copyright (c) 1996 by Silicon Graphics. All rights reserved.
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -21,7 +22,7 @@
*/
#include <stdio.h>
-#include "gc_priv.h"
+#include "private/gc_priv.h"
extern ptr_t GC_clear_stack(); /* in misc.c, behaves like identity */
void GC_extend_size_map(); /* in misc.c. */
@@ -30,13 +31,15 @@ GC_bool GC_alloc_reclaim_list(); /* in malloc.c */
/* Some externally visible but unadvertised variables to allow access to */
/* free lists from inlined allocators without including gc_priv.h */
/* or introducing dependencies on internal data structure layouts. */
-ptr_t * CONST GC_objfreelist_ptr = GC_objfreelist;
-ptr_t * CONST GC_aobjfreelist_ptr = GC_aobjfreelist;
-ptr_t * CONST GC_uobjfreelist_ptr = GC_uobjfreelist;
+ptr_t * GC_CONST GC_objfreelist_ptr = GC_objfreelist;
+ptr_t * GC_CONST GC_aobjfreelist_ptr = GC_aobjfreelist;
+ptr_t * GC_CONST GC_uobjfreelist_ptr = GC_uobjfreelist;
# ifdef ATOMIC_UNCOLLECTABLE
- ptr_t * CONST GC_auobjfreelist_ptr = GC_auobjfreelist;
+ ptr_t * GC_CONST GC_auobjfreelist_ptr = GC_auobjfreelist;
# endif
+
+
/* Allocate a composite object of size n bytes. The caller guarantees */
/* that pointers past the first page are not relevant. Caller holds */
/* allocation lock. */
@@ -44,55 +47,50 @@ ptr_t GC_generic_malloc_inner_ignore_off_page(lb, k)
register size_t lb;
register int k;
{
- register struct hblk * h;
- register word n_blocks;
register word lw;
- register ptr_t op;
+ ptr_t op;
if (lb <= HBLKSIZE)
return(GC_generic_malloc_inner((word)lb, k));
- n_blocks = divHBLKSZ(ADD_SLOP(lb) + HDR_BYTES + HBLKSIZE-1);
- if (!GC_is_initialized) GC_init_inner();
- /* Do our share of marking work */
- if(GC_incremental && !GC_dont_gc)
- GC_collect_a_little_inner((int)n_blocks);
lw = ROUNDED_UP_WORDS(lb);
- h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
-# ifdef USE_MUNMAP
- if (0 == h) {
- GC_merge_unmapped();
- h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
- }
-# endif
- while (0 == h && GC_collect_or_expand(n_blocks, TRUE)) {
- h = GC_allochblk(lw, k, IGNORE_OFF_PAGE);
- }
- if (h == 0) {
- op = 0;
- } else {
- op = (ptr_t) (h -> hb_body);
- GC_words_wasted += BYTES_TO_WORDS(n_blocks * HBLKSIZE) - lw;
- }
+ op = (ptr_t)GC_alloc_large_and_clear(lw, k, IGNORE_OFF_PAGE);
GC_words_allocd += lw;
- return((ptr_t)op);
+ return op;
}
+/* The same thing, except caller does not hold allocation lock. */
+/* We avoid holding allocation lock while we clear memory. */
ptr_t GC_generic_malloc_ignore_off_page(lb, k)
register size_t lb;
register int k;
{
register ptr_t result;
+ word lw;
+ word n_blocks;
+ GC_bool init;
DCL_LOCK_STATE;
+ if (SMALL_OBJ(lb))
+ return(GC_generic_malloc((word)lb, k));
+ lw = ROUNDED_UP_WORDS(lb);
+ n_blocks = OBJ_SZ_TO_BLOCKS(lw);
+ init = GC_obj_kinds[k].ok_init;
GC_INVOKE_FINALIZERS();
DISABLE_SIGNALS();
LOCK();
- result = GC_generic_malloc_inner_ignore_off_page(lb,k);
+ result = (ptr_t)GC_alloc_large(lw, k, IGNORE_OFF_PAGE);
+ if (GC_debugging_started) {
+ BZERO(result, n_blocks * HBLKSIZE - HDR_BYTES);
+ }
+ GC_words_allocd += lw;
UNLOCK();
ENABLE_SIGNALS();
if (0 == result) {
return((*GC_oom_fn)(lb));
} else {
+ if (init & !GC_debugging_started) {
+ BZERO(result, n_blocks * HBLKSIZE - HDR_BYTES);
+ }
return(result);
}
}
@@ -185,6 +183,24 @@ DCL_LOCK_STATE;
}
#if defined(THREADS) && !defined(SRC_M3)
+
+extern signed_word GC_mem_found; /* Protected by GC lock. */
+
+#ifdef PARALLEL_MARK
+volatile signed_word GC_words_allocd_tmp = 0;
+ /* Number of words of memory allocated since */
+ /* we released the GC lock. Instead of */
+ /* reacquiring the GC lock just to add this in, */
+ /* we add it in the next time we reacquire */
+ /* the lock. (Atomically adding it doesn't */
+ /* work, since we would have to atomically */
+ /* update it in GC_malloc, which is too */
+ /* expensive. */
+#endif /* PARALLEL_MARK */
+
+/* See reclaim.c: */
+extern ptr_t GC_reclaim_generic();
+
/* Return a list of 1 or more objects of the indicated size, linked */
/* through the first word in the object. This has the advantage that */
/* it acquires the allocation lock only once, and may greatly reduce */
@@ -200,12 +216,19 @@ register word lb;
register int k;
{
ptr_t op;
-register ptr_t p;
+ptr_t p;
ptr_t *opp;
word lw;
-register word my_words_allocd;
+word my_words_allocd = 0;
+struct obj_kind * ok = &(GC_obj_kinds[k]);
DCL_LOCK_STATE;
+# if defined(GATHERSTATS) || defined(PARALLEL_MARK)
+# define COUNT_ARG , &my_words_allocd
+# else
+# define COUNT_ARG
+# define NEED_TO_COUNT
+# endif
if (!SMALL_OBJ(lb)) {
op = GC_generic_malloc(lb, k);
if(0 != op) obj_link(op) = 0;
@@ -215,37 +238,118 @@ DCL_LOCK_STATE;
GC_INVOKE_FINALIZERS();
DISABLE_SIGNALS();
LOCK();
- opp = &(GC_obj_kinds[k].ok_freelist[lw]);
- if( (op = *opp) == 0 ) {
- if (!GC_is_initialized) {
- GC_init_inner();
- }
- op = GC_clear_stack(GC_allocobj(lw, k));
- if (op == 0) {
+ /* First see if we can reclaim a page of objects waiting to be */
+ /* reclaimed. */
+ {
+ struct hblk ** rlh = ok -> ok_reclaim_list;
+ struct hblk * hbp;
+ hdr * hhdr;
+
+ if (rlh == 0) return; /* No blocks of this kind. */
+ rlh += lw;
+ while ((hbp = *rlh) != 0) {
+ hhdr = HDR(hbp);
+ *rlh = hhdr -> hb_next;
+# ifdef PARALLEL_MARK
+ {
+ signed_word my_words_allocd_tmp = GC_words_allocd_tmp;
+
+ GC_ASSERT(my_words_allocd_tmp >= 0);
+ /* We only decrement it while holding the GC lock. */
+ /* Thus we can't accidentally adjust it down in more */
+ /* than one thread simultaneously. */
+ if (my_words_allocd_tmp != 0) {
+ (void)GC_atomic_add(&GC_words_allocd_tmp,
+ -my_words_allocd_tmp);
+ GC_words_allocd += my_words_allocd_tmp;
+ }
+ }
+ GC_acquire_mark_lock();
+ ++ GC_fl_builder_count;
+ UNLOCK();
+ ENABLE_SIGNALS();
+ GC_release_mark_lock();
+# endif
+ op = GC_reclaim_generic(hbp, hhdr, lw,
+ ok -> ok_init, 0 COUNT_ARG);
+ if (op != 0) {
+# ifdef NEED_TO_COUNT
+ /* We are neither gathering statistics, nor marking in */
+ /* parallel. Thus GC_reclaim_generic doesn't count */
+ /* for us. */
+ for (p = op; p != 0; p = obj_link(p)) {
+ my_words_allocd += lw;
+ }
+# endif
+# if defined(GATHERSTATS)
+ /* We also reclaimed memory, so we need to adjust */
+ /* that count. */
+ /* This should be atomic, so the results may be */
+ /* inaccurate. */
+ GC_mem_found += my_words_allocd;
+# endif
+# ifdef PARALLEL_MARK
+ (void)GC_atomic_add(&GC_words_allocd_tmp, my_words_allocd);
+ GC_acquire_mark_lock();
+ -- GC_fl_builder_count;
+ if (GC_fl_builder_count == 0) GC_notify_all_builder();
+ GC_release_mark_lock();
+ return op;
+# else
+ GC_words_allocd += my_words_allocd;
+ goto out;
+# endif
+ }
+# ifdef PARALLEL_MARK
+ GC_acquire_mark_lock();
+ -- GC_fl_builder_count;
+ if (GC_fl_builder_count == 0) GC_notify_all_builder();
+ GC_release_mark_lock();
+ DISABLE_SIGNALS();
+ LOCK();
+ /* GC lock is needed for reclaim list access. We */
+ /* must decrement fl_builder_count before reaquiring GC */
+ /* lock. Hopefully this path is rare. */
+# endif
+ }
+ }
+ /* Next try to allocate a new block worth of objects of this size. */
+ {
+ struct hblk *h = GC_allochblk(lw, k, 0);
+ if (h != 0) {
+ if (IS_UNCOLLECTABLE(k)) GC_set_hdr_marks(HDR(h));
+ GC_words_allocd += BYTES_TO_WORDS(HBLKSIZE)
+ - BYTES_TO_WORDS(HBLKSIZE) % lw;
+# ifdef PARALLEL_MARK
+ GC_acquire_mark_lock();
+ ++ GC_fl_builder_count;
UNLOCK();
ENABLE_SIGNALS();
- op = (*GC_oom_fn)(lb);
- if(0 != op) obj_link(op) = 0;
- return(op);
+ GC_release_mark_lock();
+# endif
+
+ op = GC_build_fl(h, lw, ok -> ok_init, 0);
+# ifdef PARALLEL_MARK
+ GC_acquire_mark_lock();
+ -- GC_fl_builder_count;
+ if (GC_fl_builder_count == 0) GC_notify_all_builder();
+ GC_release_mark_lock();
+ return op;
+# else
+ goto out;
+# endif
}
}
- *opp = 0;
- my_words_allocd = 0;
- for (p = op; p != 0; p = obj_link(p)) {
- my_words_allocd += lw;
- if (my_words_allocd >= BODY_SZ) {
- *opp = obj_link(p);
- obj_link(p) = 0;
- break;
- }
- }
- GC_words_allocd += my_words_allocd;
-out:
+ op = GC_generic_malloc_inner(lb, k);
+ obj_link(op) = 0;
+
+# ifndef PARALLEL_MARK
+ out:
+# endif
UNLOCK();
ENABLE_SIGNALS();
return(op);
-
}
void * GC_malloc_many(size_t lb)
diff --git a/mark.c b/mark.c
index c54d894e..e4264335 100644
--- a/mark.c
+++ b/mark.c
@@ -2,6 +2,7 @@
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved.
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -16,8 +17,8 @@
# include <stdio.h>
-# include "gc_priv.h"
-# include "gc_mark.h"
+# include "private/gc_priv.h"
+# include "private/gc_mark.h"
/* We put this here to minimize the risk of inlining. */
/*VARARGS*/
@@ -106,7 +107,11 @@ mse * GC_mark_stack;
word GC_mark_stack_size = 0;
-mse * GC_mark_stack_top;
+#ifdef PARALLEL_MARK
+ mse * VOLATILE GC_mark_stack_top;
+#else
+ mse * GC_mark_stack_top;
+#endif
static struct hblk * scan_ptr;
@@ -129,7 +134,11 @@ GC_bool GC_collection_in_progress()
void GC_clear_hdr_marks(hhdr)
register hdr * hhdr;
{
- BZERO(hhdr -> hb_marks, MARK_BITS_SZ*sizeof(word));
+# ifdef USE_MARK_BYTES
+ BZERO(hhdr -> hb_marks, MARK_BITS_SZ);
+# else
+ BZERO(hhdr -> hb_marks, MARK_BITS_SZ*sizeof(word));
+# endif
}
/* Set all mark bits in the header. Used for uncollectable blocks. */
@@ -139,7 +148,11 @@ register hdr * hhdr;
register int i;
for (i = 0; i < MARK_BITS_SZ; ++i) {
+# ifdef USE_MARK_BYTES
+ hhdr -> hb_marks[i] = 1;
+# else
hhdr -> hb_marks[i] = ONES;
+# endif
}
}
@@ -147,9 +160,13 @@ register hdr * hhdr;
* Clear all mark bits associated with block h.
*/
/*ARGSUSED*/
-static void clear_marks_for_block(h, dummy)
-struct hblk *h;
-word dummy;
+# if defined(__STDC__) || defined(__cplusplus)
+ static void clear_marks_for_block(struct hblk *h, word dummy)
+# else
+ static void clear_marks_for_block(h, dummy)
+ struct hblk *h;
+ word dummy;
+# endif
{
register hdr * hhdr = HDR(h);
@@ -275,7 +292,7 @@ ptr_t cold_gc_frame;
/* see more marked dirty objects later on. Avoid this */
/* in the future. */
GC_mark_stack_too_small = TRUE;
- GC_mark_from_mark_stack();
+ MARK_FROM_MARK_STACK();
return(FALSE);
} else {
scan_ptr = GC_push_next_marked_dirty(scan_ptr);
@@ -295,8 +312,13 @@ ptr_t cold_gc_frame;
case MS_PUSH_UNCOLLECTABLE:
if (GC_mark_stack_top
- >= GC_mark_stack + INITIAL_MARK_STACK_SIZE/4) {
- GC_mark_from_mark_stack();
+ >= GC_mark_stack + GC_mark_stack_size/4) {
+# ifdef PARALLEL_MARK
+ /* Avoid this, since we don't parallelize the marker */
+ /* here. */
+ if (GC_parallel) GC_mark_stack_too_small = TRUE;
+# endif
+ MARK_FROM_MARK_STACK();
return(FALSE);
} else {
scan_ptr = GC_push_next_marked_uncollectable(scan_ptr);
@@ -311,8 +333,32 @@ ptr_t cold_gc_frame;
return(FALSE);
case MS_ROOTS_PUSHED:
+# ifdef PARALLEL_MARK
+ /* In the incremental GC case, this currently doesn't */
+ /* quite do the right thing, since it runs to */
+ /* completion. On the other hand, starting a */
+ /* parallel marker is expensive, so perhaps it is */
+ /* the right thing? */
+ /* Eventually, incremental marking should run */
+ /* asynchronously in multiple threads, without grabbing */
+ /* the allocation lock. */
+ if (GC_parallel) {
+ GC_do_parallel_mark();
+ GC_ASSERT(GC_mark_stack_top < GC_first_nonempty);
+ GC_mark_stack_top = GC_mark_stack - 1;
+ if (GC_mark_stack_too_small) {
+ alloc_mark_stack(2*GC_mark_stack_size);
+ }
+ if (GC_mark_state == MS_ROOTS_PUSHED) {
+ GC_mark_state = MS_NONE;
+ return(TRUE);
+ } else {
+ return(FALSE);
+ }
+ }
+# endif
if (GC_mark_stack_top >= GC_mark_stack) {
- GC_mark_from_mark_stack();
+ MARK_FROM_MARK_STACK();
return(FALSE);
} else {
GC_mark_state = MS_NONE;
@@ -329,7 +375,7 @@ ptr_t cold_gc_frame;
return(FALSE);
}
if (GC_mark_stack_top >= GC_mark_stack) {
- GC_mark_from_mark_stack();
+ MARK_FROM_MARK_STACK();
return(FALSE);
}
if (scan_ptr == 0 && GC_mark_state == MS_INVALID) {
@@ -413,16 +459,16 @@ register hdr * hhdr;
if ((word *)orig - (word *)current
>= (ptrdiff_t)(hhdr->hb_sz)) {
/* Pointer past the end of the block */
- GC_ADD_TO_BLACK_LIST_NORMAL(orig, source);
+ GC_ADD_TO_BLACK_LIST_NORMAL((word)orig, source);
return(0);
}
return(current);
} else {
- GC_ADD_TO_BLACK_LIST_NORMAL(current, source);
+ GC_ADD_TO_BLACK_LIST_NORMAL((word)current, source);
return(0);
}
# else
- GC_ADD_TO_BLACK_LIST_NORMAL(current, source);
+ GC_ADD_TO_BLACK_LIST_NORMAL((word)current, source);
return(0);
# endif
# undef source
@@ -442,11 +488,10 @@ mse * msp;
# ifdef PRINTSTATS
GC_printf1("Mark stack overflow; current size = %lu entries\n",
GC_mark_stack_size);
-# endif
- return(msp-INITIAL_MARK_STACK_SIZE/8);
+# endif
+ return(msp - GC_MARK_STACK_DISCARDS);
}
-
/*
* Mark objects pointed to by the regions described by
* mark stack entries between GC_mark_stack and GC_mark_stack_top,
@@ -461,11 +506,11 @@ mse * msp;
* encoding, we optionally maintain a cache for the block address to
* header mapping, we prefetch when an object is "grayed", etc.
*/
-void GC_mark_from_mark_stack()
+mse * GC_mark_from(mark_stack_top, mark_stack, mark_stack_limit)
+mse * mark_stack_top;
+mse * mark_stack;
+mse * mark_stack_limit;
{
- mse * GC_mark_stack_reg = GC_mark_stack;
- mse * GC_mark_stack_top_reg = GC_mark_stack_top;
- mse * mark_stack_limit = &(GC_mark_stack[GC_mark_stack_size]);
int credit = HBLKSIZE; /* Remaining credit for marking work */
register word * current_p; /* Pointer to current candidate ptr. */
register word current; /* Candidate pointer. */
@@ -481,16 +526,16 @@ void GC_mark_from_mark_stack()
GC_objects_are_marked = TRUE;
INIT_HDR_CACHE;
# ifdef OS2 /* Use untweaked version to circumvent compiler problem */
- while (GC_mark_stack_top_reg >= GC_mark_stack_reg && credit >= 0) {
+ while (mark_stack_top >= mark_stack && credit >= 0) {
# else
- while ((((ptr_t)GC_mark_stack_top_reg - (ptr_t)GC_mark_stack_reg) | credit)
+ while ((((ptr_t)mark_stack_top - (ptr_t)mark_stack) | credit)
>= 0) {
# endif
- current_p = GC_mark_stack_top_reg -> mse_start;
- descr = GC_mark_stack_top_reg -> mse_descr;
+ current_p = mark_stack_top -> mse_start;
+ descr = mark_stack_top -> mse_descr;
retry:
/* current_p and descr describe the current object. */
- /* *GC_mark_stack_top_reg is vacant. */
+ /* *mark_stack_top is vacant. */
/* The following is 0 only for small objects described by a simple */
/* length descriptor. For many applications this is the common */
/* case, so we try to detect it quickly. */
@@ -502,16 +547,33 @@ void GC_mark_from_mark_stack()
/* Large length. */
/* Process part of the range to avoid pushing too much on the */
/* stack. */
- GC_mark_stack_top_reg -> mse_start =
+# ifdef PARALLEL_MARK
+# define SHARE_BYTES 2048
+ if (descr > SHARE_BYTES && GC_parallel
+ && mark_stack_top < mark_stack_limit - 1) {
+ int new_size = (descr/2) & ~(sizeof(word)-1);
+ GC_ASSERT(descr < GC_greatest_plausible_heap_addr
+ - GC_least_plausible_heap_addr);
+ mark_stack_top -> mse_start = current_p;
+ mark_stack_top -> mse_descr = new_size + sizeof(word);
+ /* makes sure we handle */
+ /* misaligned pointers. */
+ mark_stack_top++;
+ current_p = (word *) ((char *)current_p + new_size);
+ descr -= new_size;
+ goto retry;
+ }
+# endif /* PARALLEL_MARK */
+ mark_stack_top -> mse_start =
limit = current_p + SPLIT_RANGE_WORDS-1;
- GC_mark_stack_top_reg -> mse_descr =
+ mark_stack_top -> mse_descr =
descr - WORDS_TO_BYTES(SPLIT_RANGE_WORDS-1);
/* Make sure that pointers overlapping the two ranges are */
/* considered. */
limit = (word *)((char *)limit + sizeof(word) - ALIGNMENT);
break;
case DS_BITMAP:
- GC_mark_stack_top_reg--;
+ mark_stack_top--;
descr &= ~DS_TAGS;
credit -= WORDS_TO_BYTES(WORDSZ/2); /* guess */
while (descr != 0) {
@@ -519,7 +581,7 @@ void GC_mark_from_mark_stack()
current = *current_p;
if ((ptr_t)current >= least_ha && (ptr_t)current < greatest_ha) {
PREFETCH(current);
- HC_PUSH_CONTENTS((ptr_t)current, GC_mark_stack_top_reg,
+ HC_PUSH_CONTENTS((ptr_t)current, mark_stack_top,
mark_stack_limit, current_p, exit1);
}
}
@@ -528,11 +590,11 @@ void GC_mark_from_mark_stack()
}
continue;
case DS_PROC:
- GC_mark_stack_top_reg--;
+ mark_stack_top--;
credit -= PROC_BYTES;
- GC_mark_stack_top_reg =
+ mark_stack_top =
(*PROC(descr))
- (current_p, GC_mark_stack_top_reg,
+ (current_p, mark_stack_top,
mark_stack_limit, ENV(descr));
continue;
case DS_PER_OBJECT:
@@ -552,23 +614,26 @@ void GC_mark_from_mark_stack()
/* object case explicitly. */
if (0 == type_descr) {
/* Rarely executed. */
- GC_mark_stack_top_reg--;
+ mark_stack_top--;
continue;
}
descr = *(word *)(type_descr
- (descr - (DS_PER_OBJECT - INDIR_PER_OBJ_BIAS)));
}
if (0 == descr) {
- GC_mark_stack_top_reg--;
- continue;
+ /* Can happen either because we generated a 0 descriptor */
+ /* or we saw a pointer to a free object. */
+ mark_stack_top--;
+ continue;
}
goto retry;
}
} else /* Small object with length descriptor */ {
- GC_mark_stack_top_reg--;
+ mark_stack_top--;
limit = (word *)(((ptr_t)current_p) + (word)descr);
}
/* The simple case in which we're scanning a range. */
+ GC_ASSERT(!((word)current_p & (ALIGNMENT-1)));
credit -= (ptr_t)limit - (ptr_t)current_p;
limit -= 1;
{
@@ -585,6 +650,7 @@ void GC_mark_from_mark_stack()
/* for this loop is still not great. */
for(;;) {
PREFETCH((ptr_t)limit - PREF_DIST*CACHE_LINE_SIZE);
+ GC_ASSERT(limit >= current_p);
deferred = *limit;
limit = (word *)((char *)limit - ALIGNMENT);
if ((ptr_t)deferred >= least_ha && (ptr_t)deferred < greatest_ha) {
@@ -614,7 +680,7 @@ void GC_mark_from_mark_stack()
/* Prefetch the contents of the object we just pushed. It's */
/* likely we will need them soon. */
PREFETCH(current);
- HC_PUSH_CONTENTS((ptr_t)current, GC_mark_stack_top_reg,
+ HC_PUSH_CONTENTS((ptr_t)current, mark_stack_top,
mark_stack_limit, current_p, exit2);
}
current_p = (word *)((char *)current_p + ALIGNMENT);
@@ -624,15 +690,320 @@ void GC_mark_from_mark_stack()
/* We still need to mark the entry we previously prefetched. */
/* We alrady know that it passes the preliminary pointer */
/* validity test. */
- HC_PUSH_CONTENTS((ptr_t)deferred, GC_mark_stack_top_reg,
+ HC_PUSH_CONTENTS((ptr_t)deferred, mark_stack_top,
mark_stack_limit, current_p, exit4);
next_object:;
# endif
}
}
- GC_mark_stack_top = GC_mark_stack_top_reg;
+ return mark_stack_top;
+}
+
+#ifdef PARALLEL_MARK
+
+/* We assume we have an ANSI C Compiler. */
+GC_bool GC_help_wanted = FALSE;
+unsigned GC_helper_count = 0;
+unsigned GC_active_count = 0;
+mse * VOLATILE GC_first_nonempty;
+word GC_mark_no = 0;
+
+#define LOCAL_MARK_STACK_SIZE HBLKSIZE
+ /* Under normal circumstances, this is big enough to guarantee */
+ /* We don't overflow half of it in a single call to */
+ /* GC_mark_from. */
+
+
+/* Steal mark stack entries starting at mse low into mark stack local */
+/* until we either steal mse high, or we have max entries. */
+/* Return a pointer to the top of the local mark stack. */
+/* *next is replaced by a pointer to the next unscanned mark stack */
+/* entry. */
+mse * GC_steal_mark_stack(mse * low, mse * high, mse * local,
+ unsigned max, mse **next)
+{
+ mse *p;
+ mse *top = local - 1;
+ unsigned i = 0;
+
+ GC_ASSERT(high >= low-1 && high - low + 1 <= GC_mark_stack_size);
+ for (p = low; p <= high && i <= max; ++p) {
+ word descr = *(volatile word *) &(p -> mse_descr);
+ if (descr != 0) {
+ *(volatile word *) &(p -> mse_descr) = 0;
+ ++top;
+ top -> mse_descr = descr;
+ top -> mse_start = p -> mse_start;
+ GC_ASSERT( top -> mse_descr & DS_TAGS != DS_LENGTH ||
+ top -> mse_descr < GC_greatest_plausible_heap_addr
+ - GC_least_plausible_heap_addr);
+ /* There is no synchronization here. We assume that at */
+ /* least one thread will see the original descriptor. */
+ /* Otherwise we need a barrier. */
+ /* More than one thread may get this entry, but that's only */
+ /* a minor performance problem. */
+ /* If this is a big object, count it as */
+ /* size/256 + 1 objects. */
+ ++i;
+ if ((descr & DS_TAGS) == DS_LENGTH) i += (descr >> 8);
+ }
+ }
+ *next = p;
+ return top;
+}
+
+/* Copy back a local mark stack. */
+/* low and high are inclusive bounds. */
+void GC_return_mark_stack(mse * low, mse * high)
+{
+ mse * my_top;
+ mse * my_start;
+ size_t stack_size;
+
+ if (high < low) return;
+ stack_size = high - low + 1;
+ GC_acquire_mark_lock();
+ my_top = GC_mark_stack_top;
+ my_start = my_top + 1;
+ if (my_start - GC_mark_stack + stack_size > GC_mark_stack_size) {
+# ifdef PRINTSTATS
+ GC_printf0("No room to copy back mark stack.");
+# endif
+ GC_mark_state = MS_INVALID;
+ GC_mark_stack_too_small = TRUE;
+ /* We drop the local mark stack. We'll fix things later. */
+ } else {
+ BCOPY(low, my_start, stack_size * sizeof(mse));
+ GC_ASSERT(GC_mark_stack_top = my_top);
+ GC_memory_barrier();
+ GC_mark_stack_top = my_top + stack_size;
+ }
+ GC_release_mark_lock();
+ GC_notify_all_marker();
+}
+
+/* Mark from the local mark stack. */
+/* On return, the local mark stack is empty. */
+/* But this may be achieved by copying the */
+/* local mark stack back into the global one. */
+void GC_do_local_mark(mse *local_mark_stack, mse *local_top)
+{
+ unsigned n;
+# define N_LOCAL_ITERS 1
+
+# ifdef GC_ASSERTIONS
+ /* Make sure we don't hold mark lock. */
+ GC_acquire_mark_lock();
+ GC_release_mark_lock();
+# endif
+ for (;;) {
+ for (n = 0; n < N_LOCAL_ITERS; ++n) {
+ local_top = GC_mark_from(local_top, local_mark_stack,
+ local_mark_stack + LOCAL_MARK_STACK_SIZE);
+ if (local_top < local_mark_stack) return;
+ if (local_top - local_mark_stack >= LOCAL_MARK_STACK_SIZE/2) {
+ GC_return_mark_stack(local_mark_stack, local_top);
+ return;
+ }
+ }
+ if (GC_mark_stack_top < GC_first_nonempty &&
+ GC_active_count < GC_helper_count
+ && local_top > local_mark_stack + 1) {
+ /* Try to share the load, since the main stack is empty, */
+ /* and helper threads are waiting for a refill. */
+ /* The entries near the bottom of the stack are likely */
+ /* to require more work. Thus we return those, eventhough */
+ /* it's harder. */
+ mse * p;
+ mse * new_bottom = local_mark_stack
+ + (local_top - local_mark_stack)/2;
+ GC_ASSERT(new_bottom > local_mark_stack
+ && new_bottom < local_top);
+ GC_return_mark_stack(local_mark_stack, new_bottom - 1);
+ memmove(local_mark_stack, new_bottom,
+ (local_top - new_bottom + 1) * sizeof(mse));
+ local_top -= (new_bottom - local_mark_stack);
+ }
+ }
}
+#define ENTRIES_TO_GET 5
+
+long GC_markers = 2; /* Normally changed by thread-library- */
+ /* -specific code. */
+
+/* Mark using the local mark stack until the global mark stack is empty */
+/* and ther are no active workers. Update GC_first_nonempty to reflect */
+/* progress. */
+/* Caller does not hold mark lock. */
+/* Caller has already incremented GC_helper_count. We decrement it, */
+/* and maintain GC_active_count. */
+void GC_mark_local(mse *local_mark_stack, int id)
+{
+ mse * my_first_nonempty;
+
+ GC_acquire_mark_lock();
+ GC_active_count++;
+ my_first_nonempty = GC_first_nonempty;
+ GC_ASSERT(GC_first_nonempty >= GC_mark_stack &&
+ GC_first_nonempty <= GC_mark_stack_top + 1);
+# ifdef PRINTSTATS
+ GC_printf1("Starting mark helper %lu\n", (unsigned long)id);
+# endif
+ GC_release_mark_lock();
+ for (;;) {
+ size_t n_on_stack;
+ size_t n_to_get;
+ mse *next;
+ mse * my_top;
+ mse * local_top;
+ mse * global_first_nonempty = GC_first_nonempty;
+
+ GC_ASSERT(my_first_nonempty >= GC_mark_stack &&
+ my_first_nonempty <= GC_mark_stack_top + 1);
+ GC_ASSERT(global_first_nonempty >= GC_mark_stack &&
+ global_first_nonempty <= GC_mark_stack_top + 1);
+ if (my_first_nonempty < global_first_nonempty) {
+ my_first_nonempty = global_first_nonempty;
+ } else if (global_first_nonempty < my_first_nonempty) {
+ GC_compare_and_exchange((word *)(&GC_first_nonempty),
+ (word) global_first_nonempty,
+ (word) my_first_nonempty);
+ /* If this fails, we just go ahead, without updating */
+ /* GC_first_nonempty. */
+ }
+ /* Perhaps we should also update GC_first_nonempty, if it */
+ /* is less. But that would require using atomic updates. */
+ my_top = GC_mark_stack_top;
+ n_on_stack = my_top - my_first_nonempty + 1;
+ if (0 == n_on_stack) {
+ GC_acquire_mark_lock();
+ my_top = GC_mark_stack_top;
+ n_on_stack = my_top - my_first_nonempty + 1;
+ if (0 == n_on_stack) {
+ GC_active_count--;
+ GC_ASSERT(GC_active_count <= GC_helper_count);
+ /* Other markers may redeposit objects */
+ /* on the stack. */
+ if (0 == GC_active_count) GC_notify_all_marker();
+ while (GC_active_count > 0
+ && GC_first_nonempty > GC_mark_stack_top) {
+ /* We will be notofied if either GC_active_count */
+ /* reaches zero, or if more objects are pushed on */
+ /* the global mark stack. */
+ GC_wait_marker();
+ }
+ if (GC_active_count == 0 &&
+ GC_first_nonempty > GC_mark_stack_top) {
+ GC_bool need_to_notify = FALSE;
+ /* The above conditions can't be falsified while we */
+ /* hold the mark lock, since neither */
+ /* GC_active_count nor GC_mark_stack_top can */
+ /* change. GC_first_nonempty can only be */
+ /* incremented asynchronously. Thus we know that */
+ /* both conditions actually held simultaneously. */
+ GC_helper_count--;
+ if (0 == GC_helper_count) need_to_notify = TRUE;
+# ifdef PRINTSTATS
+ GC_printf1(
+ "Finished mark helper %lu\n", (unsigned long)id);
+# endif
+ GC_release_mark_lock();
+ if (need_to_notify) GC_notify_all_marker();
+ return;
+ }
+ /* else there's something on the stack again, or */
+ /* another help may push something. */
+ GC_active_count++;
+ GC_ASSERT(GC_active_count > 0);
+ GC_release_mark_lock();
+ continue;
+ } else {
+ GC_release_mark_lock();
+ }
+ }
+ n_to_get = ENTRIES_TO_GET;
+ if (n_on_stack < 2 * ENTRIES_TO_GET) n_to_get = 1;
+ local_top = GC_steal_mark_stack(my_first_nonempty, my_top,
+ local_mark_stack, n_to_get,
+ &my_first_nonempty);
+ GC_ASSERT(my_first_nonempty >= GC_mark_stack &&
+ my_first_nonempty <= GC_mark_stack_top + 1);
+ GC_do_local_mark(local_mark_stack, local_top);
+ }
+}
+
+/* Perform Parallel mark. */
+/* We hold the GC lock, not the mark lock. */
+/* Currently runs until the mark stack is */
+/* empty. */
+void GC_do_parallel_mark()
+{
+ mse local_mark_stack[LOCAL_MARK_STACK_SIZE];
+ mse * local_top;
+ mse * my_top;
+
+ GC_acquire_mark_lock();
+ GC_ASSERT(I_HOLD_LOCK());
+ GC_ASSERT(!GC_help_wanted);
+ GC_ASSERT(GC_active_count == 0);
+# ifdef PRINTSTATS
+ GC_printf1("Starting marking for mark phase number %lu\n",
+ (unsigned long)GC_mark_no);
+# endif
+ GC_first_nonempty = GC_mark_stack;
+ GC_active_count = 0;
+ GC_helper_count = 1;
+ GC_help_wanted = TRUE;
+ GC_release_mark_lock();
+ GC_notify_all_marker();
+ /* Wake up potential helpers. */
+ GC_mark_local(local_mark_stack, 0);
+ GC_acquire_mark_lock();
+ GC_help_wanted = FALSE;
+ /* Done; clean up. */
+ while (GC_helper_count > 0) GC_wait_marker();
+ /* GC_helper_count cannot be incremented while GC_help_wanted == FALSE */
+# ifdef PRINTSTATS
+ GC_printf1(
+ "Finished marking for mark phase number %lu\n",
+ (unsigned long)GC_mark_no);
+# endif
+ GC_mark_no++;
+ GC_release_mark_lock();
+ GC_notify_all_marker();
+}
+
+
+/* Try to help out the marker, if it's running. */
+/* We do not hold the GC lock, but the requestor does. */
+void GC_help_marker(word my_mark_no)
+{
+ mse local_mark_stack[LOCAL_MARK_STACK_SIZE];
+ unsigned my_id;
+ mse * my_first_nonempty;
+
+ if (!GC_parallel) return;
+ GC_acquire_mark_lock();
+ while (GC_mark_no < my_mark_no
+ || !GC_help_wanted && GC_mark_no == my_mark_no) {
+ GC_wait_marker();
+ }
+ my_id = GC_helper_count;
+ if (GC_mark_no != my_mark_no || my_id >= GC_markers) {
+ /* Second test is useful only if original threads can also */
+ /* act as helpers. Under Linux they can't. */
+ GC_release_mark_lock();
+ return;
+ }
+ GC_helper_count = my_id + 1;
+ GC_release_mark_lock();
+ GC_mark_local(local_mark_stack, my_id);
+ /* GC_mark_local decrements GC_helper_count. */
+}
+
+#endif /* PARALLEL_MARK */
+
/* Allocate or reallocate space for mark stack of size s words */
/* May silently fail. */
static void alloc_mark_stack(n)
@@ -711,19 +1082,20 @@ ptr_t top;
}
/*
- * Analogous to the above, but push only those pages that may have been
- * dirtied. A block h is assumed dirty if dirty_fn(h) != 0.
+ * Analogous to the above, but push only those pages h with dirty_fn(h) != 0.
* We use push_fn to actually push the block.
+ * Used both to selectively push dirty pages, or to push a block
+ * in piecemeal fashion, to allow for more marking concurrency.
* Will not overflow mark stack if push_fn pushes a small fixed number
* of entries. (This is invoked only if push_fn pushes a single entry,
* or if it marks each object before pushing it, thus ensuring progress
* in the event of a stack overflow.)
*/
-void GC_push_dirty(bottom, top, dirty_fn, push_fn)
+void GC_push_selected(bottom, top, dirty_fn, push_fn)
ptr_t bottom;
ptr_t top;
-int (*dirty_fn)(/* struct hblk * h */);
-void (*push_fn)(/* ptr_t bottom, ptr_t top */);
+int (*dirty_fn) GC_PROTO((struct hblk * h));
+void (*push_fn) GC_PROTO((ptr_t bottom, ptr_t top));
{
register struct hblk * h;
@@ -765,6 +1137,17 @@ void (*push_fn)(/* ptr_t bottom, ptr_t top */);
}
# ifndef SMALL_CONFIG
+
+#ifdef PARALLEL_MARK
+ /* Break up root sections into page size chunks to better spread */
+ /* out work. */
+ GC_bool GC_true_func(struct hblk *h) { return TRUE; }
+# define GC_PUSH_ALL(b,t) GC_push_selected(b,t,GC_true_func,GC_push_all);
+#else
+# define GC_PUSH_ALL(b,t) GC_push_all(b,t);
+#endif
+
+
void GC_push_conditional(bottom, top, all)
ptr_t bottom;
ptr_t top;
@@ -774,7 +1157,7 @@ int all;
if (GC_dirty_maintained) {
# ifdef PROC_VDB
/* Pages that were never dirtied cannot contain pointers */
- GC_push_dirty(bottom, top, GC_page_was_ever_dirty, GC_push_all);
+ GC_push_selected(bottom, top, GC_page_was_ever_dirty, GC_push_all);
# else
GC_push_all(bottom, top);
# endif
@@ -782,24 +1165,18 @@ int all;
GC_push_all(bottom, top);
}
} else {
- GC_push_dirty(bottom, top, GC_page_was_dirty, GC_push_all);
+ GC_push_selected(bottom, top, GC_page_was_dirty, GC_push_all);
}
}
#endif
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
void __cdecl GC_push_one(p)
# else
void GC_push_one(p)
# endif
word p;
{
-# ifdef NURSERY
- if (0 != GC_push_proc) {
- GC_push_proc(p);
- return;
- }
-# endif
GC_PUSH_ONE_STACK(p, MARKED_FROM_REGISTER);
}
@@ -1005,7 +1382,7 @@ ptr_t top;
# endif
}
-#ifndef SMALL_CONFIG
+#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
/* Push all objects reachable from marked objects in the given block */
/* of size 1 objects. */
void GC_push_marked1(h, hhdr)
@@ -1164,12 +1541,13 @@ register hdr * hhdr;
}
switch(sz) {
-# if !defined(SMALL_CONFIG)
+# if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
case 1:
GC_push_marked1(h, hhdr);
break;
# endif
-# if !defined(SMALL_CONFIG) && !defined(UNALIGNED)
+# if !defined(SMALL_CONFIG) && !defined(UNALIGNED) && \
+ !defined(USE_MARK_BYTES)
case 2:
GC_push_marked2(h, hhdr);
break;
diff --git a/mark_rts.c b/mark_rts.c
index 5bafd07e..08ae8c97 100644
--- a/mark_rts.c
+++ b/mark_rts.c
@@ -11,9 +11,8 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, October 9, 1995 1:06 pm PDT */
# include <stdio.h>
-# include "gc_priv.h"
+# include "private/gc_priv.h"
/* Data structure for list of root sets. */
/* We keep a hash table, so that we can filter out duplicate additions. */
@@ -23,7 +22,7 @@
struct roots {
ptr_t r_start;
ptr_t r_end;
- # ifndef MSWIN32
+ # if !defined(MSWIN32) && !defined(MSWINCE)
struct roots * r_next;
# endif
GC_bool r_tmp;
@@ -69,11 +68,12 @@ void GC_print_static_roots()
GC_bool GC_is_static_root(p)
ptr_t p;
{
- static int last_root_set = 0;
+ static int last_root_set = MAX_ROOT_SETS;
register int i;
- if (p >= GC_static_roots[last_root_set].r_start
+ if (last_root_set < n_root_sets
+ && p >= GC_static_roots[last_root_set].r_start
&& p < GC_static_roots[last_root_set].r_end) return(TRUE);
for (i = 0; i < n_root_sets; i++) {
if (p >= GC_static_roots[i].r_start
@@ -85,7 +85,7 @@ ptr_t p;
return(FALSE);
}
-#ifndef MSWIN32
+#if !defined(MSWIN32) && !defined(MSWINCE)
/*
# define LOG_RT_SIZE 6
# define RT_SIZE (1 << LOG_RT_SIZE) -- Power of 2, may be != MAX_ROOT_SETS
@@ -137,7 +137,7 @@ struct roots *p;
GC_root_index[h] = p;
}
-# else /* MSWIN32 */
+# else /* MSWIN32 || MSWINCE */
# define add_roots_to_index(p)
@@ -173,7 +173,7 @@ GC_bool tmp;
{
struct roots * old;
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
/* Spend the time to ensure that there are no overlapping */
/* or adjacent intervals. */
/* This could be done faster with e.g. a */
@@ -242,7 +242,7 @@ GC_bool tmp;
GC_static_roots[n_root_sets].r_start = (ptr_t)b;
GC_static_roots[n_root_sets].r_end = (ptr_t)e;
GC_static_roots[n_root_sets].r_tmp = tmp;
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
GC_static_roots[n_root_sets].r_next = 0;
# endif
add_roots_to_index(GC_static_roots + n_root_sets);
@@ -258,7 +258,7 @@ void GC_clear_roots GC_PROTO((void))
LOCK();
n_root_sets = 0;
GC_root_size = 0;
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
{
register int i;
@@ -286,7 +286,7 @@ void GC_remove_tmp_roots()
i++;
}
}
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
{
register int i;
@@ -298,11 +298,41 @@ void GC_remove_tmp_roots()
}
+#if defined(MSWIN32) || defined(_WIN32_WCE_EMULATION)
+/* Workaround for the OS mapping and unmapping behind our back: */
+/* Is the address p in one of the temporary static root sections? */
+GC_bool GC_is_tmp_root(p)
+ptr_t p;
+{
+ static int last_root_set = MAX_ROOT_SETS;
+ register int i;
+
+ if (last_root_set < n_root_sets
+ && p >= GC_static_roots[last_root_set].r_start
+ && p < GC_static_roots[last_root_set].r_end)
+ return GC_static_roots[last_root_set].r_tmp;
+ for (i = 0; i < n_root_sets; i++) {
+ if (p >= GC_static_roots[i].r_start
+ && p < GC_static_roots[i].r_end) {
+ last_root_set = i;
+ return GC_static_roots[i].r_tmp;
+ }
+ }
+ return(FALSE);
+}
+#endif /* MSWIN32 || _WIN32_WCE_EMULATION */
+
ptr_t GC_approx_sp()
{
word dummy;
-
+
+# ifdef _MSC_VER
+# pragma warning(disable:4172)
+# endif
return((ptr_t)(&dummy));
+# ifdef _MSC_VER
+# pragma warning(default:4172)
+# endif
}
/*
@@ -483,8 +513,8 @@ ptr_t cold_gc_frame;
* not robust against mark stack overflow.
*/
/* Reregister dynamic libraries, in case one got added. */
-# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
- && !defined(SRC_M3)
+# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(MSWINCE) \
+ || defined(PCR)) && !defined(SRC_M3)
GC_remove_tmp_roots();
GC_register_dynamic_libraries();
# endif
diff --git a/misc.c b/misc.c
index 780dc7b5..9c196ec6 100644
--- a/misc.c
+++ b/misc.c
@@ -15,16 +15,21 @@
#include <stdio.h>
+#ifndef _WIN32_WCE
#include <signal.h>
+#endif
#define I_HIDE_POINTERS /* To make GC_call_with_alloc_lock visible */
-#include "gc_priv.h"
+#include "private/gc_priv.h"
#ifdef SOLARIS_THREADS
# include <sys/syscall.h>
#endif
-#ifdef MSWIN32
+#if defined(MSWIN32) || defined(MSWINCE)
+# define WIN32_LEAN_AND_MEAN
+# define NOSERVICE
# include <windows.h>
+# include <tchar.h>
#endif
# ifdef THREADS
@@ -40,15 +45,22 @@
mutex_t GC_allocate_ml; /* Implicitly initialized. */
# else
# ifdef WIN32_THREADS
- GC_API CRITICAL_SECTION GC_allocate_ml;
+# if defined(_DLL) || defined(GC_DLL)
+ __declspec(dllexport) CRITICAL_SECTION GC_allocate_ml;
+# else
+ CRITICAL_SECTION GC_allocate_ml;
+# endif
# else
-# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS) \
+# if defined(IRIX_THREADS) \
|| (defined(LINUX_THREADS) && defined(USE_SPIN_LOCK))
pthread_t GC_lock_holder = NO_THREAD;
# else
# if defined(HPUX_THREADS) \
|| defined(LINUX_THREADS) && !defined(USE_SPIN_LOCK)
pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER;
+ pthread_t GC_lock_holder = NO_THREAD;
+ /* Used only for assertions, and to prevent */
+ /* recursive reentry in the system call wrapper. */
# else
--> declare allocator lock here
# endif
@@ -65,9 +77,9 @@ GC_FAR struct _GC_arrays GC_arrays /* = { 0 } */;
GC_bool GC_debugging_started = FALSE;
/* defined here so we don't have to load debug_malloc.o */
-void (*GC_check_heap)() = (void (*)())0;
+void (*GC_check_heap) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
-void (*GC_start_call_back)() = (void (*)())0;
+void (*GC_start_call_back) GC_PROTO((void)) = (void (*) GC_PROTO((void)))0;
ptr_t GC_stackbottom = 0;
@@ -103,19 +115,20 @@ extern signed_word GC_mem_found;
{
register unsigned i;
- /* Map size 0 to 1. This avoids problems at lower levels. */
- GC_size_map[0] = 1;
- /* One word objects don't have to be 2 word aligned. */
- for (i = 1; i < sizeof(word); i++) {
- GC_size_map[i] = 1;
+ /* Map size 0 to something bigger. */
+ /* This avoids problems at lower levels. */
+ /* One word objects don't have to be 2 word aligned, */
+ /* unless we're using mark bytes. */
+ for (i = 0; i < sizeof(word); i++) {
+ GC_size_map[i] = MIN_WORDS;
}
- GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word));
+# ifdef USE_MARK_BYTES
+ GC_size_map[sizeof(word)] = ALIGNED_WORDS(sizeof(word));
+# else
+ GC_size_map[sizeof(word)] = ROUNDED_UP_WORDS(sizeof(word));
+# endif
for (i = sizeof(word) + 1; i <= 8 * sizeof(word); i++) {
-# ifdef ALIGN_DOUBLE
- GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
-# else
- GC_size_map[i] = ROUNDED_UP_WORDS(i);
-# endif
+ GC_size_map[i] = ALIGNED_WORDS(i);
}
for (i = 8*sizeof(word) + 1; i <= 16 * sizeof(word); i++) {
GC_size_map[i] = (ROUNDED_UP_WORDS(i) + 1) & (~1);
@@ -426,8 +439,12 @@ void GC_init()
}
+#if defined(MSWIN32) || defined(MSWINCE)
+ CRITICAL_SECTION GC_write_cs;
+#endif
+
#ifdef MSWIN32
- extern void GC_init_win32();
+ extern void GC_init_win32 GC_PROTO((void));
#endif
extern void GC_setpagesize();
@@ -439,12 +456,15 @@ void GC_init_inner()
# endif
if (GC_is_initialized) return;
+# if defined(MSWIN32) || defined(MSWINCE)
+ InitializeCriticalSection(&GC_write_cs);
+# endif
GC_setpagesize();
- GC_exclude_static_roots(beginGC_arrays, end_gc_area);
-# ifdef PRINTSTATS
- if ((ptr_t)endGC_arrays != (ptr_t)(&GC_obj_kinds)) {
- GC_printf0("Reordering linker, didn't exclude obj_kinds\n");
- }
+ GC_exclude_static_roots(beginGC_arrays, endGC_arrays);
+ GC_exclude_static_roots(beginGC_obj_kinds, endGC_obj_kinds);
+# ifdef SEPARATE_GLOBALS
+ GC_exclude_static_roots(beginGC_objfreelist, endGC_objfreelist);
+ GC_exclude_static_roots(beginGC_aobjfreelist, endGC_aobjfreelist);
# endif
# ifdef MSWIN32
GC_init_win32();
@@ -453,15 +473,14 @@ void GC_init_inner()
/* This doesn't really work if the collector is in a shared library. */
GC_init_linux_data_start();
# endif
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
+ || defined(HPUX_THREADS) || defined(SOLARIS_THREADS)
+ GC_thr_init();
+# endif
# ifdef SOLARIS_THREADS
- GC_thr_init();
/* We need dirty bits in order to find live stack sections. */
GC_dirty_init();
# endif
-# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
- GC_thr_init();
-# endif
# if !defined(THREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \
|| defined(IRIX_THREADS) || defined(LINUX_THREADS) \
|| defined(HPUX_THREADS)
@@ -469,15 +488,9 @@ void GC_init_inner()
GC_stackbottom = GC_get_stack_base();
}
# endif
- if (sizeof (ptr_t) != sizeof(word)) {
- ABORT("sizeof (ptr_t) != sizeof(word)\n");
- }
- if (sizeof (signed_word) != sizeof(word)) {
- ABORT("sizeof (signed_word) != sizeof(word)\n");
- }
- if (sizeof (struct hblk) != HBLKSIZE) {
- ABORT("sizeof (struct hblk) != HBLKSIZE\n");
- }
+ GC_ASSERT(sizeof (ptr_t) == sizeof(word));
+ GC_ASSERT(sizeof (signed_word) == sizeof(word));
+ GC_ASSERT(sizeof (struct hblk) == HBLKSIZE);
# ifndef THREADS
# if defined(STACK_GROWS_UP) && defined(STACK_GROWS_DOWN)
ABORT(
@@ -488,40 +501,16 @@ void GC_init_inner()
"One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd\n");
# endif
# ifdef STACK_GROWS_DOWN
- if ((word)(&dummy) > (word)GC_stackbottom) {
- GC_err_printf0(
- "STACK_GROWS_DOWN is defd, but stack appears to grow up\n");
-# ifndef UTS4 /* Compiler bug workaround */
- GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n",
- (unsigned long) (&dummy),
- (unsigned long) GC_stackbottom);
-# endif
- ABORT("stack direction 3\n");
- }
+ GC_ASSERT((word)(&dummy) <= (word)GC_stackbottom);
# else
- if ((word)(&dummy) < (word)GC_stackbottom) {
- GC_err_printf0(
- "STACK_GROWS_UP is defd, but stack appears to grow down\n");
- GC_err_printf2("sp = 0x%lx, GC_stackbottom = 0x%lx\n",
- (unsigned long) (&dummy),
- (unsigned long) GC_stackbottom);
- ABORT("stack direction 4");
- }
+ GC_ASSERT((word)(&dummy) >= (word)GC_stackbottom);
# endif
# endif
# if !defined(_AUX_SOURCE) || defined(__GNUC__)
- if ((word)(-1) < (word)0) {
- GC_err_printf0("The type word should be an unsigned integer type\n");
- GC_err_printf0("It appears to be signed\n");
- ABORT("word");
- }
+ GC_ASSERT((word)(-1) > (word)0);
+ /* word should be unsigned */
# endif
- if ((signed_word)(-1) >= (signed_word)0) {
- GC_err_printf0(
- "The type signed_word should be a signed integer type\n");
- GC_err_printf0("It appears to be unsigned\n");
- ABORT("signed_word");
- }
+ GC_ASSERT((signed_word)(-1) < (signed_word)0);
/* Add initial guess of root sets. Do this first, since sbrk(0) */
/* might be used. */
@@ -555,10 +544,13 @@ void GC_init_inner()
# endif
/* Get black list set up */
GC_gcollect_inner();
+ GC_is_initialized = TRUE;
# ifdef STUBBORN_ALLOC
GC_stubborn_init();
# endif
- GC_is_initialized = TRUE;
+# ifdef LINUX_THREADS
+ GC_thr_late_init();
+# endif
/* Convince lint that some things are used */
# ifdef LINT
{
@@ -623,25 +615,41 @@ out:
}
-#ifdef MSWIN32
-# define LOG_FILE "gc.log"
+#if defined(MSWIN32) || defined(MSWINCE)
+# define LOG_FILE _T("gc.log")
- HANDLE GC_stdout = 0, GC_stderr;
- int GC_tmp;
- DWORD GC_junk;
+ HANDLE GC_stdout = 0;
- void GC_set_files()
+ void GC_deinit()
{
- if (!GC_stdout) {
- GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
- NULL);
- if (INVALID_HANDLE_VALUE == GC_stdout) ABORT("Open of log file failed");
- }
- if (GC_stderr == 0) {
- GC_stderr = GC_stdout;
- }
+ if (GC_is_initialized) {
+ DeleteCriticalSection(&GC_write_cs);
+ }
+ }
+
+ int GC_write(buf, len)
+ char * buf;
+ size_t len;
+ {
+ BOOL tmp;
+ DWORD written;
+ if (len == 0)
+ return 0;
+ EnterCriticalSection(&GC_write_cs);
+ if (GC_stdout == INVALID_HANDLE_VALUE) {
+ return -1;
+ } else if (GC_stdout == 0) {
+ GC_stdout = CreateFile(LOG_FILE, GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH,
+ NULL);
+ if (GC_stdout == INVALID_HANDLE_VALUE) ABORT("Open of log file failed");
+ }
+ tmp = WriteFile(GC_stdout, buf, len, &written, NULL);
+ if (!tmp)
+ DebugBreak();
+ LeaveCriticalSection(&GC_write_cs);
+ return tmp ? (int)written : -1;
}
#endif
@@ -662,7 +670,7 @@ int GC_tmp; /* Should really be local ... */
}
#endif
-#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32)
+#if !defined(OS2) && !defined(MACOS) && !defined(MSWIN32) && !defined(MSWINCE)
int GC_stdout = 1;
int GC_stderr = 2;
# if !defined(AMIGA)
@@ -670,7 +678,7 @@ int GC_tmp; /* Should really be local ... */
# endif
#endif
-#if !defined(MSWIN32) && !defined(OS2) && !defined(MACOS)
+#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(OS2) && !defined(MACOS)
int GC_write(fd, buf, len)
int fd;
char *buf;
@@ -693,11 +701,8 @@ size_t len;
}
#endif /* UN*X */
-#ifdef MSWIN32
-# define WRITE(f, buf, len) (GC_set_files(), \
- GC_tmp = WriteFile((f), (buf), \
- (len), &GC_junk, NULL),\
- (GC_tmp? 1 : -1))
+#if defined(MSWIN32) || defined(MSWINCE)
+# define WRITE(f, buf, len) GC_write(buf, len)
#else
# if defined(OS2) || defined(MACOS)
# define WRITE(f, buf, len) (GC_set_files(), \
@@ -715,7 +720,7 @@ size_t len;
/* same size as long, and that the format conversions expect something */
/* of that size. */
void GC_printf(format, a, b, c, d, e, f)
-char * format;
+GC_CONST char * format;
long a, b, c, d, e, f;
{
char buf[1025];
@@ -728,7 +733,7 @@ long a, b, c, d, e, f;
}
void GC_err_printf(format, a, b, c, d, e, f)
-char * format;
+GC_CONST char * format;
long a, b, c, d, e, f;
{
char buf[1025];
@@ -740,7 +745,7 @@ long a, b, c, d, e, f;
}
void GC_err_puts(s)
-char *s;
+GC_CONST char *s;
{
if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed");
}
@@ -777,10 +782,28 @@ GC_warn_proc GC_current_warn_proc = GC_default_warn_proc;
#ifndef PCR
void GC_abort(msg)
-char * msg;
+GC_CONST char * msg;
{
- GC_err_printf1("%s\n", msg);
- (void) abort();
+# if defined(MSWIN32)
+ (void) MessageBoxA(NULL, msg, "Fatal error in gc", MB_ICONERROR|MB_OK);
+ DebugBreak();
+# else
+ GC_err_printf1("%s\n", msg);
+# endif
+# if defined(LINUX) || defined(HPUX) || defined(SUNOS5) || defined(IRIX)
+ if (getenv("GC_LOOP_ON_ABORT") != NULL) {
+ /* In many cases it's easier to debug a running process. */
+ /* It's arguably nicer to sleep, but that makes it harder */
+ /* to look at the thread if the debugger doesn't know much */
+ /* about threads. */
+ for(;;);
+ }
+# endif
+# ifdef MSWIN32
+ DebugBreak();
+# else
+ (void) abort();
+# endif
}
#endif
@@ -843,4 +866,4 @@ void GC_dump()
GC_print_block_list();
}
-# endif /* NO_DEBUGGING */
+#endif /* NO_DEBUGGING */
diff --git a/new_hblk.c b/new_hblk.c
index 1e1273f8..fdc13bba 100644
--- a/new_hblk.c
+++ b/new_hblk.c
@@ -1,6 +1,7 @@
/*
* Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -19,7 +20,7 @@
# include <stdio.h>
-# include "gc_priv.h"
+# include "private/gc_priv.h"
#ifndef SMALL_CONFIG
/*
@@ -150,71 +151,51 @@ ptr_t ofl;
#endif /* !SMALL_CONFIG */
-/*
- * Allocate a new heapblock for small objects of size n.
- * Add all of the heapblock's objects to the free list for objects
- * of that size.
- * Set all mark bits if objects are uncollectable.
- * Will fail to do anything if we are out of memory.
- */
-void GC_new_hblk(sz, kind)
-register word sz;
-int kind;
-{
- register word *p,
- *prev;
- word *last_object; /* points to last object in new hblk */
- register struct hblk *h; /* the new heap block */
- register GC_bool clear = GC_obj_kinds[kind].ok_init;
-
-# ifdef PRINTSTATS
- if ((sizeof (struct hblk)) > HBLKSIZE) {
- ABORT("HBLK SZ inconsistency");
- }
-# endif
-
- /* Allocate a new heap block */
- h = GC_allochblk(sz, kind, 0);
- if (h == 0) return;
- /* Mark all objects if appropriate. */
- if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
+/* Build a free list for objects of size sz inside heap block h. */
+/* Clear objects inside h if clear is set. Add list to the end of */
+/* the free list we build. Return the new free list. */
+/* This could be called without the main GC lock, if we ensure that */
+/* there is no concurrent collection which might reclaim objects that */
+/* we have not yet allocated. */
+ptr_t GC_build_fl(h, sz, clear, list)
+struct hblk *h;
+word sz;
+GC_bool clear;
+ptr_t list;
+{
+ word *p, *prev;
+ word *last_object; /* points to last object in new hblk */
- PREFETCH_FOR_WRITE((char *)h);
- PREFETCH_FOR_WRITE((char *)h + 128);
- PREFETCH_FOR_WRITE((char *)h + 256);
- PREFETCH_FOR_WRITE((char *)h + 378);
+ /* Do a few prefetches here, just because its cheap. */
+ /* If we were more serious about it, these should go inside */
+ /* the loops. But write prefetches usually don't seem to */
+ /* matter much. */
+ PREFETCH_FOR_WRITE((char *)h);
+ PREFETCH_FOR_WRITE((char *)h + 128);
+ PREFETCH_FOR_WRITE((char *)h + 256);
+ PREFETCH_FOR_WRITE((char *)h + 378);
/* Handle small objects sizes more efficiently. For larger objects */
/* the difference is less significant. */
# ifndef SMALL_CONFIG
switch (sz) {
- case 1: GC_obj_kinds[kind].ok_freelist[1] =
- GC_build_fl1(h, GC_obj_kinds[kind].ok_freelist[1]);
- return;
+ case 1: return GC_build_fl1(h, list);
case 2: if (clear) {
- GC_obj_kinds[kind].ok_freelist[2] =
- GC_build_fl_clear2(h, GC_obj_kinds[kind].ok_freelist[2]);
+ return GC_build_fl_clear2(h, list);
} else {
- GC_obj_kinds[kind].ok_freelist[2] =
- GC_build_fl2(h, GC_obj_kinds[kind].ok_freelist[2]);
+ return GC_build_fl2(h, list);
}
- return;
case 3: if (clear) {
- GC_obj_kinds[kind].ok_freelist[3] =
- GC_build_fl_clear3(h, GC_obj_kinds[kind].ok_freelist[3]);
- return;
+ return GC_build_fl_clear3(h, list);
} else {
/* It's messy to do better than the default here. */
break;
}
case 4: if (clear) {
- GC_obj_kinds[kind].ok_freelist[4] =
- GC_build_fl_clear4(h, GC_obj_kinds[kind].ok_freelist[4]);
+ return GC_build_fl_clear4(h, list);
} else {
- GC_obj_kinds[kind].ok_freelist[4] =
- GC_build_fl4(h, GC_obj_kinds[kind].ok_freelist[4]);
+ return GC_build_fl4(h, list);
}
- return;
default:
break;
}
@@ -243,7 +224,39 @@ int kind;
* put p (which is now head of list of objects in *h) as first
* pointer in the appropriate free list for this size.
*/
- obj_link(h -> hb_body) = GC_obj_kinds[kind].ok_freelist[sz];
- GC_obj_kinds[kind].ok_freelist[sz] = ((ptr_t)p);
+ obj_link(h -> hb_body) = list;
+ return ((ptr_t)p);
+}
+
+/*
+ * Allocate a new heapblock for small objects of size n.
+ * Add all of the heapblock's objects to the free list for objects
+ * of that size.
+ * Set all mark bits if objects are uncollectable.
+ * Will fail to do anything if we are out of memory.
+ */
+void GC_new_hblk(sz, kind)
+register word sz;
+int kind;
+{
+ register struct hblk *h; /* the new heap block */
+ register GC_bool clear = GC_obj_kinds[kind].ok_init;
+
+# ifdef PRINTSTATS
+ if ((sizeof (struct hblk)) > HBLKSIZE) {
+ ABORT("HBLK SZ inconsistency");
+ }
+# endif
+
+ /* Allocate a new heap block */
+ h = GC_allochblk(sz, kind, 0);
+ if (h == 0) return;
+
+ /* Mark all objects if appropriate. */
+ if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(HDR(h));
+
+ /* Build the free list */
+ GC_obj_kinds[kind].ok_freelist[sz] =
+ GC_build_fl(h, sz, clear, GC_obj_kinds[kind].ok_freelist[sz]);
}
diff --git a/nursery.c b/nursery.c
deleted file mode 100644
index ab83afba..00000000
--- a/nursery.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 1999 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-
-#ifdef NURSERY
-??? This implementation is incomplete. If you are trying to
-??? compile this you are doing something wrong.
-
-#include "nursery.h"
-
-#define SCAN_STATICS_FOR_NURSERY
- /* If this is not defined, the collector will not see */
- /* references from static data areas to the nursery. */
-
-struct copy_obj {
- ptr_t forward; /* Forwarding link for copied objects. */
- GC_copy_descriptor descr; /* Object descriptor */
- word data[1];
-}
-
-ptr_t GC_nursery_start; /* Start of nursery area. */
- /* Must be NURSERY_BLOCK_SIZE */
- /* aligned. */
-ptr_t GC_nursery_end; /* End of nursery area. */
-unsigned char * GC_nursery_map;
- /* GC_nursery_map[i] != 0 if an object */
- /* starts on the ith 64-bit "word" of */
- /* nursery. This simple structure has */
- /* the advantage that */
- /* allocation is cheap. Lookup is */
- /* cheap for pointers to the head of */
- /* an object, which should be the */
- /* usual case. */
-# define NURSERY_MAP_NOT_START 0 /* Not start of object. */
-# define NURSERY_MAP_START 1 /* Start of object. */
-# define NURSERY_MAP_PINNED 2 /* Start of pinned obj. */
-
-# ifdef ALIGN_DOUBLE
-# define NURSERY_WORD_SIZE (2 * sizeof(word))
-# else
-# define NURSERY_WORD_SIZE sizeof(word)
-# endif
-
-# define NURSERY_BLOCK_SIZE (HBLKSIZE/2)
- /* HBLKSIZE must be a multiple of NURSERY_BLOCK_SIZE */
-# define NURSERY_SIZE (1024 * NURSERY_BLOCK_SIZE)
-
-size_t GC_nursery_size = NURSERY_SIZE;
- /* Must be multiple of NURSERY_BLOCK_SIZE */
-
-size_t GC_nursery_blocks; /* Number of blocks in the nursery. */
-
-unsigned GC_next_nursery_block; /* index of next block we will attempt */
- /* allocate from during this cycle. */
- /* If it is pinned, we won't actually */
- /* use it. */
-
-unsigned short *GC_pinned; /* Number of pinned objects in ith */
- /* nursery block. */
- /* GC_pinned[i] != 0 if the ith nursery */
- /* block is pinned, and thus not used */
- /* for allocation. */
-
-GC_copy_alloc_state global_alloc_state = (ptr_t)(-1); /* will overflow. */
-
-/* Array of known rescuing pointers from the heap to the nursery. */
- ptr_t ** nursery_rescuers;
- /* Pointer to one past the last slot in rescuer table */
- ptr_t ** nursery_rescuers_end;
- /* Maximum number of known rescuing pointers. */
-# define MAX_NURSERY_RESCUERS 32*1024
- /* Add a rescuer to the list */
-# define ADD_NURSERY_RESCUER(p) \
- if (nursery_rescuers_end >= nursery_rescuers + MAX_NURSERY_RESCUERS) { \
- ABORT("Nursery recuers overflow"); /* Fix later !!! */ \
- } else { \
- *nursery_rescuers_end++ = p; \
- }
- /* Remove rescuer at the given position in the table */
-# define REMOVE_RESCUER(p) \
- *p = *--nursery_rescuers_end
-
-/* Should be called with allocator lock held. */
-GC_nursery_init() {
- GC_nursery_start = GET_MEM(GC_nursery_size);
- GC_nursery_end = GC_nursery_start + GC_nursery_size;
- GC_next_nursery_block = 0;
- if (GC_nursery_start < GC_least_plausible_heap_addr) {
- GC_least_plausible_heap_addr = GC_nursery_start;
- }
- if (GC_nursery_end > GC_greatest_plausible_heap_addr) {
- GC_greatest_plausible_heap_addr = GC_nursery_end;
- }
- if (GC_nursery_start & (NURSERY_BLOCK_SIZE-1)) {
- GC_err_printf1("Nursery area is misaligned!!");
- /* This should be impossible, since GET_MEM returns HBLKSIZE */
- /* aligned chunks, and that should be a multiple of */
- /* NURSERY_BLOCK_SIZE */
- ABORT("misaligned nursery");
- }
- GC_nursery_map = GET_MEM(GC_nursery_size/NURSERY_WORD_SIZE);
- /* Map is cleared a block at a time when we allocate from the block. */
- /* BZERO(GC_nursery_map, GC_nursery_size/NURSERY_WORD_SIZE); */
- GC_nursery_blocks = GC_nursery_size/NURSERY_BLOCK_SIZE;
- GC_pinned = GC_scratch_alloc(GC_nursery_blocks * sizeof(unsigned short));
- BZERO(GC_pinned, GC_nursery_blocks);
- nursery_rescuers = GET_MEM(MAX_NURSERY_RESCUERS * sizeof(ptr_t *));
- nursery_rescuers_end = nursery_rescuers;
- if (0 == GC_nursery_start || 0 == GC_nursery_map || 0 == nursery_rescuers)
- ABORT("Insufficient memory for nursery");
-}
-
-#define PIN_OBJ(p) \
- if (p >= GC_nursery_start && p < GC_nursery_end) { GC_pin_obj_checked(p); }
-
-/* Pin the object at p, if it's in the nursery. */
-void GC_pin_obj(ptr_t p) {
- PIN_OBJ(p);
-}
-
-void (*GC_push_proc)(ptr_t) = 0;
-
-/* Pin the object at p, which is known to be in the nursery. */
-void GC_pin_obj_checked(ptr_t p) {
- unsigned offset = p - GC_nursery_start;
- unsigned word_offset = BYTES_TO_WORDS(offset);
- unsigned blockno = (current - GC_nursery_start)/NURSERY_BLOCK_SIZE;
- while (GC_nursery_map[word_offset] == NURSERY_MAP_NOT_START) {
- --word_offset;
- }
- if (GC_nursery_map[word_offset] != NURSERY_MAP_PINNED) {
- GC_nursery_map[word_offset] = NURSERY_MAP_PINNED;
- ++GC_pinned[blockno];
- ??Push object at GC_nursery_start + WORDS_TO_BYTES(word_offset)
- ??onto mark stack.
- }
-}
-
-void GC_scan_region_for_nursery(ptr_t low, ptr_t high) {
-# if CPP_WORDSZ/8 != ALIGNMENT
- --> fix this
-# endif
- word * l = (word *)((word)low + ALIGNMENT - 1 & ~(ALIGNMENT - 1));
- word * h = (word *)((word)high & ~(ALIGNMENT - 1));
- word * p;
- for (p = l; p < h; ++p) {
- PIN_OBJ(p);
- }
-}
-
-/* Invoke GC_scan_region_for_nursery on ranges that are not excluded. */
-void GC_scan_region_for_nursery_with_exclusions(ptr_t bottom, ptr_t top)
-{
- struct exclusion * next;
- ptr_t excl_start;
-
- while (bottom < top) {
- next = GC_next_exclusion(bottom);
- if (0 == next || (excl_start = next -> e_start) >= top) {
- GC_scan_region_for_nursery(bottom, top);
- return;
- }
- if (excl_start > bottom)
- GC_scan_region_for_nursery(bottom, excl_start);
- bottom = next -> e_end;
- }
-}
-
-
-void GC_scan_stacks_for_nursery(void) {
-# ifdef THREADS
- --> fix this
-# endif
-# ifdef STACK_GROWS_DOWN
- ptr_t stack_low = GC_approx_sp();
- ptr_t stack_high = GC_stackbottom;
-# else
- ptr_t stack_low = GC_stackbottom;
- ptr_t stack_high = GC_approx_sp();
-# endif
- GC_scan_region_for_nursery(stack_low, stack_high);
-# ifdef IA64
- GC_scan_region_for_nursery(BACKING_STORE_BASE,
- (ptr_t) GC_save_regs_ret_val);
-# endif
-}
-
-void GC_scan_roots_for_nursery(void) {
- /* Scan registers. */
- /* Direct GC_push_one to call GC_pin_obj instead of marking */
- /* and pushing objects. */
- /* This is a bit ugly, but we don't have to touch the */
- /* platform-dependent code. */
-
- void (*old_push_proc)(ptr_t) = GC_push_proc;
- GC_push_proc = GC_pin_obj;
- GC_push_regs();
- GC_push_proc = old_push_proc;
- GC_scan_stacks_for_nursery();
-# ifdef SCAN_STATICS_FOR_NURSERY
-# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
- && !defined(SRC_M3)
- GC_remove_tmp_roots();
- GC_register_dynamic_libraries();
-# endif
- /* Mark everything in static data areas */
- for (i = 0; i < n_root_sets; i++) {
- GC_scan_region_for_nursery_with_exclusions (
- GC_static_roots[i].r_start,
- GC_static_roots[i].r_end);
- }
-# endif
-}
-
-/* Array of known rescuing pointers from the heap to the nursery. */
-ptr_t ** nursery_rescuers;
-
-/* Caller holds allocation lock. */
-void GC_collect_nursery(void) {
- int i;
- ptr_t scan_ptr = 0;
- STOP_WORLD;
- for (i = 0; i < GC_nursery_blocks; ++i) GC_pinned[i] = 0;
- GC_scan_roots_for_nursery();
- /* All objects referenced by roots are now pinned. */
- /* Their contents are described by */
- /* mark stack entries. */
-
- /* Pin blocks corresponding to valid allocation states. */
- /* that probably happens automagically if the allocation */
- /* states are kept where we can see them. */
- /* It will take work if static roots are not scanned. */
- /* We want to do this both for correctness and to avoid */
- /* promoting very young objects. */
-
- /* Somehow capture dirty bits. Update rescuers array to */
- /* reflect newly valid and invalid references from dirty */
- /* pages. Other references should remain valid, since the */
- /* referents should have been pinned. */
-
- /* Traverse the old object heap. Pin objects in the */
- /* nursery that are ambiguously referenced, copy those */
- /* that are unambiguously referenced. */
-
- /* Traverse objects in mark stack. */
- /* If referenced object is in pinned block, add contents */
- /* to mark stack. If referenced object is forwarded, */
- /* update pointer. Otherwise reallocate the object in the */
- /* old heap, copy its contents, and then enqueue its */
- /* contents in the mark stack. */
- START_WORLD;
-}
-
-/* Initialize an allocation state so that it can be used for */
-/* allocation. This implicitly reserves a small section of the */
-/* nursery for use with this allocator. */
-/* Also called to replenish an allocator that has been */
-/* exhausted. */
-void GC_init_copy_alloc_state(GC_copy_alloc_state *)
- unsigned next_block;
- ptr_t block_addr;
- LOCK();
- next_block = GC_next_nursery_block;
- while(is_pinned[next_block] && next_block < GC_nursery_blocks) {
- ++next_block;
- }
- if (next_block < GC_nursery_blocks) {
- block_addr = GC_nursery_start + NURSERY_BLOCK_SIZE * next_block;
- GC_next_nursery_block = next_block + 1;
- BZERO(GC_nursery_map + next_block *
- (NURSERY_BLOCK_SIZE/NURSERY_WORD_SIZE),
- NURSERY_BLOCK_SIZE/NURSERY_WORD_SIZE);
- *GC_copy_alloc_state = block_addr;
- UNLOCK();
- } else {
- GC_collect_nursery();
- GC_next_nursery_block = 0;
- UNLOCK();
- get_new_block(s);
- }
-}
-
-GC_PTR GC_copying_malloc2(GC_copy_descriptor *d, GC_copy_alloc_state *s) {
- size_t sz = GC_SIZE_FROM_DESCRIPTOR(d);
- ptrdiff_t offset;
- ptr_t result = *s;
- ptr_t new = result + sz;
- if (new & COPY_BLOCK_MASK <= result & COPY_BLOCK_MASK> {
- GC_init_copy_alloc_state(s);
- result = *s;
- new = result + sz;
- GC_ASSERT(new & COPY_BLOCK_MASK > result & COPY_BLOCK_MASK>
- }
- (struct copy_obj *)result -> descr = d;
- (struct copy_obj *)result -> forward = 0;
- offset = (result - GC_nursery_start)/NURSERY_WORD_SIZE;
- GC_nursery_map[offset] = NURSERY_MAP_NOT_START;
-}
-
-GC_PTR GC_copying_malloc(GC_copy_descriptor *d) {
-}
-
-#endif /* NURSERY */
diff --git a/obj_map.c b/obj_map.c
index 82ebf311..67647eeb 100644
--- a/obj_map.c
+++ b/obj_map.c
@@ -11,7 +11,6 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, October 9, 1995 1:09 pm PDT */
/* Routines for maintaining maps describing heap block
* layouts for various object sizes. Allows fast pointer validity checks
@@ -19,7 +18,7 @@
* with slow division.
*/
-# include "gc_priv.h"
+# include "private/gc_priv.h"
char * GC_invalid_map = 0;
diff --git a/os_dep.c b/os_dep.c
index 34b871d8..a8e95151 100644..100755
--- a/os_dep.c
+++ b/os_dep.c
@@ -14,7 +14,7 @@
* modified is included with the above copyright notice.
*/
-# include "gc_priv.h"
+# include "private/gc_priv.h"
# if defined(LINUX) && !defined(POWERPC)
# include <linux/version.h>
@@ -45,7 +45,8 @@
# endif /* 2 <= __GLIBC__ */
# endif
# endif
-# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS)
+# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) && !defined(MACOS) \
+ && !defined(MSWINCE)
# include <sys/types.h>
# if !defined(MSWIN32) && !defined(SUNOS4)
# include <unistd.h>
@@ -53,7 +54,11 @@
# endif
# include <stdio.h>
-# include <signal.h>
+# if defined(MSWINCE)
+# define SIGSEGV 0 /* value is irrelevant */
+# else
+# include <signal.h>
+# endif
/* Blatantly OS dependent routines, except for those that are related */
/* to dynamic loading. */
@@ -95,7 +100,7 @@
# include <workbench/startup.h>
#endif
-#ifdef MSWIN32
+#if defined(MSWIN32) || defined(MSWINCE)
# define WIN32_LEAN_AND_MEAN
# define NOSERVICE
# include <windows.h>
@@ -126,7 +131,7 @@
#endif
#ifdef DJGPP
- /* Apparently necessary for djgpp 2.01. May casuse problems with */
+ /* Apparently necessary for djgpp 2.01. May cause problems with */
/* other versions. */
typedef long unsigned int caddr_t;
#endif
@@ -265,6 +270,7 @@ void GC_enable_signals(void)
# else
# if !defined(PCR) && !defined(AMIGA) && !defined(MSWIN32) \
+ && !defined(MSWINCE) \
&& !defined(MACOS) && !defined(DJGPP) && !defined(DOS4GW)
# if defined(sigmask) && !defined(UTS4)
@@ -348,13 +354,11 @@ void GC_enable_signals()
/* Find the page size */
word GC_page_size;
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
void GC_setpagesize()
{
- SYSTEM_INFO sysinfo;
-
- GetSystemInfo(&sysinfo);
- GC_page_size = sysinfo.dwPageSize;
+ GetSystemInfo(&GC_sysinfo);
+ GC_page_size = GC_sysinfo.dwPageSize;
}
# else
@@ -379,7 +383,7 @@ word GC_page_size;
* With threads, GC_mark_roots needs to know how to do this.
* Called with allocator lock held.
*/
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# define is_writable(prot) ((prot) == PAGE_READWRITE \
|| (prot) == PAGE_WRITECOPY \
|| (prot) == PAGE_EXECUTE_READWRITE \
@@ -611,7 +615,7 @@ ptr_t GC_get_stack_base()
/* using direct I/O system calls in order to avoid calling malloc */
/* in case REDIRECT_MALLOC is defined. */
# define STAT_BUF_SIZE 4096
-# ifdef USE_LD_WRAP
+# if defined(GC_USE_LD_WRAP) && defined(MPROTECT_VDB)
# define STAT_READ __real_read
# else
# define STAT_READ read
@@ -698,7 +702,7 @@ ptr_t GC_get_stack_base()
# endif /* ! AMIGA */
# endif /* ! OS2 */
-# endif /* ! MSWIN32 */
+# endif /* ! MSWIN32 && !MSWINCE */
/*
* Register static data segment(s) as roots.
@@ -800,6 +804,8 @@ void GC_register_data_segments()
# else
+# if defined(MSWIN32) || defined(MSWINCE)
+
# ifdef MSWIN32
/* Unfortunately, we have to handle win32s very differently from NT, */
/* Since VirtualQuery has very different semantics. In particular, */
@@ -822,21 +828,19 @@ void GC_register_data_segments()
{
GC_win32s = GC_is_win32s();
}
-
+
/* Return the smallest address a such that VirtualQuery */
/* returns correct results for all addresses between a and start. */
/* Assumes VirtualQuery returns correct information for start. */
ptr_t GC_least_described_address(ptr_t start)
{
MEMORY_BASIC_INFORMATION buf;
- SYSTEM_INFO sysinfo;
DWORD result;
LPVOID limit;
ptr_t p;
LPVOID q;
- GetSystemInfo(&sysinfo);
- limit = sysinfo.lpMinimumApplicationAddress;
+ limit = GC_sysinfo.lpMinimumApplicationAddress;
p = (ptr_t)((word)start & ~(GC_page_size - 1));
for (;;) {
q = (LPVOID)(p - GC_page_size);
@@ -847,6 +851,7 @@ void GC_register_data_segments()
}
return(p);
}
+# endif
/* Is p the start of either the malloc heap, or of one of our */
/* heap sections? */
@@ -860,7 +865,11 @@ void GC_register_data_segments()
if (0 == malloc_heap_pointer) {
MEMORY_BASIC_INFORMATION buf;
- register DWORD result = VirtualQuery(malloc(1), &buf, sizeof(buf));
+ void *pTemp = malloc( 1 );
+ register DWORD result = VirtualQuery(pTemp, &buf, sizeof(buf));
+
+ free( pTemp );
+
if (result != sizeof(buf)) {
ABORT("Weird VirtualQuery result");
@@ -874,11 +883,11 @@ void GC_register_data_segments()
}
return(FALSE);
}
-
+
+# ifdef MSWIN32
void GC_register_root_section(ptr_t static_root)
{
MEMORY_BASIC_INFORMATION buf;
- SYSTEM_INFO sysinfo;
DWORD result;
DWORD protect;
LPVOID p;
@@ -887,8 +896,7 @@ void GC_register_data_segments()
if (!GC_win32s) return;
p = base = limit = GC_least_described_address(static_root);
- GetSystemInfo(&sysinfo);
- while (p < sysinfo.lpMaximumApplicationAddress) {
+ while (p < GC_sysinfo.lpMaximumApplicationAddress) {
result = VirtualQuery(p, &buf, sizeof(buf));
if (result != sizeof(buf) || buf.AllocationBase == 0
|| GC_is_heap_base(buf.AllocationBase)) break;
@@ -909,14 +917,18 @@ void GC_register_data_segments()
}
if (base != limit) GC_add_roots_inner(base, limit, FALSE);
}
+#endif
void GC_register_data_segments()
{
+# ifdef MSWIN32
static char dummy;
-
GC_register_root_section((ptr_t)(&dummy));
+# endif
}
+
# else
+
# ifdef AMIGA
void GC_register_data_segments()
@@ -1031,7 +1043,8 @@ void GC_register_data_segments()
# else
-# if (defined(SVR4) || defined(AUX) || defined(DGUX)) && !defined(PCR)
+# if (defined(SVR4) || defined(AUX) || defined(DGUX) \
+ || (defined(LINUX) && defined(SPARC))) && !defined(PCR)
char * GC_SysVGetDataStart(max_page_size, etext_addr)
int max_page_size;
int * etext_addr;
@@ -1124,7 +1137,7 @@ void GC_register_data_segments()
}
# endif /* ! AMIGA */
-# endif /* ! MSWIN32 */
+# endif /* ! MSWIN32 && ! MSWINCE*/
# endif /* ! OS2 */
/*
@@ -1132,7 +1145,8 @@ void GC_register_data_segments()
*/
# if !defined(OS2) && !defined(PCR) && !defined(AMIGA) \
- && !defined(MSWIN32) && !defined(MACOS) && !defined(DOS4GW)
+ && !defined(MSWIN32) && !defined(MSWINCE) \
+ && !defined(MACOS) && !defined(DOS4GW)
# ifdef SUNOS4
extern caddr_t sbrk();
@@ -1256,6 +1270,11 @@ void * os2_alloc(size_t bytes)
# endif /* OS2 */
+# if defined(MSWIN32) || defined(MSWINCE)
+SYSTEM_INFO GC_sysinfo;
+# endif
+
+
# ifdef MSWIN32
word GC_n_heap_bases = 0;
@@ -1263,7 +1282,7 @@ ptr_t GC_win32_get_mem(bytes)
word bytes;
{
ptr_t result;
-
+
if (GC_win32s) {
/* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */
/* There are also unconfirmed rumors of other */
@@ -1292,21 +1311,77 @@ void GC_win32_free_heap ()
}
}
}
+# endif
+
+# ifdef MSWINCE
+word GC_n_heap_bases = 0;
+ptr_t GC_wince_get_mem(bytes)
+word bytes;
+{
+ ptr_t result;
+ word i;
+
+ /* Round up allocation size to multiple of page size */
+ bytes = (bytes + GC_page_size-1) & ~(GC_page_size-1);
+
+ /* Try to find reserved, uncommitted pages */
+ for (i = 0; i < GC_n_heap_bases; i++) {
+ if (((word)(-(signed_word)GC_heap_lengths[i])
+ & (GC_sysinfo.dwAllocationGranularity-1))
+ >= bytes) {
+ result = GC_heap_bases[i] + GC_heap_lengths[i];
+ break;
+ }
+ }
+
+ if (i == GC_n_heap_bases) {
+ /* Reserve more pages */
+ word res_bytes = (bytes + GC_sysinfo.dwAllocationGranularity-1)
+ & ~(GC_sysinfo.dwAllocationGranularity-1);
+ result = (ptr_t) VirtualAlloc(NULL, res_bytes,
+ MEM_RESERVE | MEM_TOP_DOWN,
+ PAGE_EXECUTE_READWRITE);
+ if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
+ /* If I read the documentation correctly, this can */
+ /* only happen if HBLKSIZE > 64k or not a power of 2. */
+ if (GC_n_heap_bases >= MAX_HEAP_SECTS) ABORT("Too many heap sections");
+ GC_heap_bases[GC_n_heap_bases] = result;
+ GC_heap_lengths[GC_n_heap_bases] = 0;
+ GC_n_heap_bases++;
+ }
+
+ /* Commit pages */
+ result = (ptr_t) VirtualAlloc(result, bytes,
+ MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ if (result != NULL) {
+ if (HBLKDISPL(result) != 0) ABORT("Bad VirtualAlloc result");
+ GC_heap_lengths[i] += bytes;
+ }
+
+ return(result);
+}
# endif
#ifdef USE_MUNMAP
-/* For now, this only works on some Unix-like systems. If you */
-/* have something else, don't define USE_MUNMAP. */
+/* For now, this only works on Win32/WinCE and some Unix-like */
+/* systems. If you have something else, don't define */
+/* USE_MUNMAP. */
/* We assume ANSI C to support this feature. */
+
+#if !defined(MSWIN32) && !defined(MSWINCE)
+
#include <unistd.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
+#endif
+
/* Compute a page aligned starting address for the unmap */
/* operation on a block of size bytes starting at start. */
/* Return 0 if the block is too small to make this feasible. */
@@ -1329,6 +1404,14 @@ ptr_t GC_unmap_end(ptr_t start, word bytes)
return end_addr;
}
+/* Under Win32/WinCE we commit (map) and decommit (unmap) */
+/* memory using VirtualAlloc and VirtualFree. These functions */
+/* work on individual allocations of virtual memory, made */
+/* previously using VirtualAlloc with the MEM_RESERVE flag. */
+/* The ranges we need to (de)commit may span several of these */
+/* allocations; therefore we use VirtualQuery to check */
+/* allocation lengths, and split up the range as necessary. */
+
/* We assume that GC_remap is called on exactly the same range */
/* as a previous call to GC_unmap. It is safe to consistently */
/* round the endpoints in both places. */
@@ -1338,8 +1421,24 @@ void GC_unmap(ptr_t start, word bytes)
ptr_t end_addr = GC_unmap_end(start, bytes);
word len = end_addr - start_addr;
if (0 == start_addr) return;
- if (munmap(start_addr, len) != 0) ABORT("munmap failed");
- GC_unmapped_bytes += len;
+# if defined(MSWIN32) || defined(MSWINCE)
+ while (len != 0) {
+ MEMORY_BASIC_INFORMATION mem_info;
+ GC_word free_len;
+ if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
+ != sizeof(mem_info))
+ ABORT("Weird VirtualQuery result");
+ free_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
+ if (!VirtualFree(start_addr, free_len, MEM_DECOMMIT))
+ ABORT("VirtualFree failed");
+ GC_unmapped_bytes += free_len;
+ start_addr += free_len;
+ len -= free_len;
+ }
+# else
+ if (munmap(start_addr, len) != 0) ABORT("munmap failed");
+ GC_unmapped_bytes += len;
+# endif
}
@@ -1351,14 +1450,35 @@ void GC_remap(ptr_t start, word bytes)
word len = end_addr - start_addr;
ptr_t result;
- if (-1 == zero_descr) zero_descr = open("/dev/zero", O_RDWR);
- if (0 == start_addr) return;
- result = mmap(start_addr, len, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
- MAP_FIXED | MAP_PRIVATE, zero_descr, 0);
- if (result != start_addr) {
- ABORT("mmap remapping failed");
- }
- GC_unmapped_bytes -= len;
+# if defined(MSWIN32) || defined(MSWINCE)
+ if (0 == start_addr) return;
+ while (len != 0) {
+ MEMORY_BASIC_INFORMATION mem_info;
+ GC_word alloc_len;
+ if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
+ != sizeof(mem_info))
+ ABORT("Weird VirtualQuery result");
+ alloc_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
+ result = VirtualAlloc(start_addr, alloc_len,
+ MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ if (result != start_addr) {
+ ABORT("VirtualAlloc remapping failed");
+ }
+ GC_unmapped_bytes -= alloc_len;
+ start_addr += alloc_len;
+ len -= alloc_len;
+ }
+# else
+ if (-1 == zero_descr) zero_descr = open("/dev/zero", O_RDWR);
+ if (0 == start_addr) return;
+ result = mmap(start_addr, len, PROT_READ | PROT_WRITE | OPT_PROT_EXEC,
+ MAP_FIXED | MAP_PRIVATE, zero_descr, 0);
+ if (result != start_addr) {
+ ABORT("mmap remapping failed");
+ }
+ GC_unmapped_bytes -= len;
+# endif
}
/* Two adjacent blocks have already been unmapped and are about to */
@@ -1379,8 +1499,24 @@ void GC_unmap_gap(ptr_t start1, word bytes1, ptr_t start2, word bytes2)
if (0 == start2_addr) end_addr = GC_unmap_end(start1, bytes1 + bytes2);
if (0 == start_addr) return;
len = end_addr - start_addr;
- if (len != 0 && munmap(start_addr, len) != 0) ABORT("munmap failed");
- GC_unmapped_bytes += len;
+# if defined(MSWIN32) || defined(MSWINCE)
+ while (len != 0) {
+ MEMORY_BASIC_INFORMATION mem_info;
+ GC_word free_len;
+ if (VirtualQuery(start_addr, &mem_info, sizeof(mem_info))
+ != sizeof(mem_info))
+ ABORT("Weird VirtualQuery result");
+ free_len = (len < mem_info.RegionSize) ? len : mem_info.RegionSize;
+ if (!VirtualFree(start_addr, free_len, MEM_DECOMMIT))
+ ABORT("VirtualFree failed");
+ GC_unmapped_bytes += free_len;
+ start_addr += free_len;
+ len -= free_len;
+ }
+# else
+ if (len != 0 && munmap(start_addr, len) != 0) ABORT("munmap failed");
+ GC_unmapped_bytes += len;
+# endif
}
#endif /* USE_MUNMAP */
@@ -1415,7 +1551,7 @@ PCR_ERes GC_push_old_obj(void *p, size_t size, PCR_Any data)
}
-void GC_default_push_other_roots()
+void GC_default_push_other_roots GC_PROTO((void))
{
/* Traverse data allocated by previous memory managers. */
{
@@ -1479,7 +1615,7 @@ extern void GC_push_finalizer_structures();
# endif
-void GC_default_push_other_roots()
+void GC_default_push_other_roots GC_PROTO((void))
{
/* Use the M3 provided routine for finding static roots. */
/* This is a bit dubious, since it presumes no C roots. */
@@ -1502,24 +1638,24 @@ void GC_default_push_other_roots()
# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \
|| defined(IRIX_THREADS) || defined(LINUX_THREADS) \
- || defined(IRIX_JDK_THREADS) || defined(HPUX_THREADS)
+ || defined(HPUX_THREADS)
extern void GC_push_all_stacks();
-void GC_default_push_other_roots()
+void GC_default_push_other_roots GC_PROTO((void))
{
GC_push_all_stacks();
}
# endif /* SOLARIS_THREADS || ... */
-void (*GC_push_other_roots)() = GC_default_push_other_roots;
+void (*GC_push_other_roots) GC_PROTO((void)) = GC_default_push_other_roots;
#endif
/*
* Routines for accessing dirty bits on virtual pages.
- * We plan to eventaually implement four strategies for doing so:
+ * We plan to eventually implement four strategies for doing so:
* DEFAULT_VDB: A simple dummy implementation that treats every page
* as possibly dirty. This makes incremental collection
* useless, but the implementation is still correct.
@@ -1622,7 +1758,7 @@ struct hblk *h;
* not to work under a number of other systems.
*/
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
# include <sys/mman.h>
# include <signal.h>
@@ -1641,7 +1777,9 @@ struct hblk *h;
# else
-# include <signal.h>
+# ifndef MSWINCE
+# include <signal.h>
+# endif
static DWORD protect_junk;
# define PROTECT(addr, len) \
@@ -1662,7 +1800,7 @@ struct hblk *h;
#if defined(SUNOS4) || defined(FREEBSD)
typedef void (* SIG_PF)();
#endif
-#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX)
+#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) || defined(MACOSX)
# ifdef __STDC__
typedef void (* SIG_PF)(int);
# else
@@ -1674,6 +1812,11 @@ struct hblk *h;
# undef SIG_DFL
# define SIG_DFL (LPTOP_LEVEL_EXCEPTION_FILTER) (-1)
#endif
+#if defined(MSWINCE)
+ typedef LONG (WINAPI *SIG_PF)(struct _EXCEPTION_POINTERS *);
+# undef SIG_DFL
+# define SIG_DFL (SIG_PF) (-1)
+#endif
#if defined(IRIX5) || defined(OSF1)
typedef void (* REAL_SIG_PF)(int, int, struct sigcontext *);
@@ -1789,10 +1932,141 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
# define CODE_OK (scp -> si_code == SEGV_ACCERR)
# endif
# endif
-# if defined(MSWIN32)
+# if defined(MACOSX)
+ typedef void (* REAL_SIG_PF)(int, int, struct sigcontext *);
+
+/* Decodes the machine instruction which was responsible for the sending of the
+ SIGBUS signal. Sadly this is the only way to find the faulting address because
+ the signal handler doesn't get it directly from the kernel (although it is
+ available on the Mach level, but droppped by the BSD personality before it
+ calls our signal handler...)
+ This code should be able to deal correctly with all PPCs starting from the
+ 601 up to and including the G4s (including Velocity Engine). */
+#define EXTRACT_OP1(iw) (((iw) & 0xFC000000) >> 26)
+#define EXTRACT_OP2(iw) (((iw) & 0x000007FE) >> 1)
+#define EXTRACT_REGA(iw) (((iw) & 0x001F0000) >> 16)
+#define EXTRACT_REGB(iw) (((iw) & 0x03E00000) >> 21)
+#define EXTRACT_REGC(iw) (((iw) & 0x0000F800) >> 11)
+#define EXTRACT_DISP(iw) ((short *) &(iw))[1]
+
+static char *get_fault_addr(struct sigcontext *scp)
+{
+ unsigned int instr = *((unsigned int *) scp->sc_ir);
+ unsigned int * regs = &((unsigned int *) scp->sc_regs)[2];
+ int disp = 0, tmp;
+ unsigned int baseA = 0, baseB = 0;
+ unsigned int addr, alignmask = 0xFFFFFFFF;
+
+#ifdef GC_DEBUG_DECODER
+ GC_err_printf1("Instruction: 0x%lx\n", instr);
+ GC_err_printf1("Opcode 1: d\n", (int)EXTRACT_OP1(instr));
+#endif
+ switch(EXTRACT_OP1(instr)) {
+ case 38: /* stb */
+ case 39: /* stbu */
+ case 54: /* stfd */
+ case 55: /* stfdu */
+ case 52: /* stfs */
+ case 53: /* stfsu */
+ case 44: /* sth */
+ case 45: /* sthu */
+ case 47: /* stmw */
+ case 36: /* stw */
+ case 37: /* stwu */
+ tmp = EXTRACT_REGA(instr);
+ if(tmp > 0)
+ baseA = regs[tmp];
+ disp = EXTRACT_DISP(instr);
+ break;
+ case 31:
+#ifdef GC_DEBUG_DECODER
+ GC_err_printf1("Opcode 2: %d\n", (int)EXTRACT_OP2(instr));
+#endif
+ switch(EXTRACT_OP2(instr)) {
+ case 86: /* dcbf */
+ case 54: /* dcbst */
+ case 1014: /* dcbz */
+ case 247: /* stbux */
+ case 215: /* stbx */
+ case 759: /* stfdux */
+ case 727: /* stfdx */
+ case 983: /* stfiwx */
+ case 695: /* stfsux */
+ case 663: /* stfsx */
+ case 918: /* sthbrx */
+ case 439: /* sthux */
+ case 407: /* sthx */
+ case 661: /* stswx */
+ case 662: /* stwbrx */
+ case 150: /* stwcx. */
+ case 183: /* stwux */
+ case 151: /* stwx */
+ case 135: /* stvebx */
+ case 167: /* stvehx */
+ case 199: /* stvewx */
+ case 231: /* stvx */
+ case 487: /* stvxl */
+ tmp = EXTRACT_REGA(instr);
+ if(tmp > 0)
+ baseA = regs[tmp];
+ baseB = regs[EXTRACT_REGC(instr)];
+ /* determine Altivec alignment mask */
+ switch(EXTRACT_OP2(instr)) {
+ case 167: /* stvehx */
+ alignmask = 0xFFFFFFFE;
+ break;
+ case 199: /* stvewx */
+ alignmask = 0xFFFFFFFC;
+ break;
+ case 231: /* stvx */
+ alignmask = 0xFFFFFFF0;
+ break;
+ case 487: /* stvxl */
+ alignmask = 0xFFFFFFF0;
+ break;
+ }
+ break;
+ case 725: /* stswi */
+ tmp = EXTRACT_REGA(instr);
+ if(tmp > 0)
+ baseA = regs[tmp];
+ break;
+ default: /* ignore instruction */
+#ifdef GC_DEBUG_DECODER
+ GC_err_printf("Ignored by inner handler\n");
+#endif
+ return NULL;
+ break;
+ }
+ break;
+ default: /* ignore instruction */
+#ifdef GC_DEBUG_DECODER
+ GC_err_printf("Ignored by main handler\n");
+#endif
+ return NULL;
+ break;
+ }
+
+ addr = (baseA + baseB) + disp;
+ addr &= alignmask;
+#ifdef GC_DEBUG_DECODER
+ GC_err_printf1("BaseA: %d\n", baseA);
+ GC_err_printf1("BaseB: %d\n", baseB);
+ GC_err_printf1("Disp: %d\n", disp);
+ GC_err_printf1("Address: %d\n", addr);
+#endif
+ return (char *)addr;
+}
+
+ void GC_write_fault_handler(int sig, int code, struct sigcontext *scp)
+# define SIG_OK (sig == SIGBUS)
+# define CODE_OK (code == 0 /* experimentally determined */)
+# endif
+
+# if defined(MSWIN32) || defined(MSWINCE)
LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info)
# define SIG_OK (exc_info -> ExceptionRecord -> ExceptionCode == \
- EXCEPTION_ACCESS_VIOLATION)
+ STATUS_ACCESS_VIOLATION)
# define CODE_OK (exc_info -> ExceptionRecord -> ExceptionInformation[0] == 1)
/* Write fault */
# endif
@@ -1814,7 +2088,7 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
# if defined(M68K)
char * addr = NULL;
- struct sigcontext *scp = (struct sigcontext *)(&sc);
+ struct sigcontext *scp = (struct sigcontext *)(sc);
int format = (scp->sc_formatvec >> 12) & 0xf;
unsigned long *framedata = (unsigned long *)(scp + 1);
@@ -1826,6 +2100,10 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
} else if (format == 7) {
/* 68040 */
ea = framedata[3];
+ if (framedata[1] & 0x08000000) {
+ /* correct addr on misaligned access */
+ ea = (ea+4095)&(~4095);
+ }
} else if (format == 4) {
/* 68060 */
ea = framedata[0];
@@ -1855,7 +2133,10 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
# endif
# endif
# endif
-# if defined(MSWIN32)
+# if defined(MACOSX)
+ char * addr = get_fault_addr(scp);
+# endif
+# if defined(MSWIN32) || defined(MSWINCE)
char * addr = (char *) (exc_info -> ExceptionRecord
-> ExceptionInformation[1]);
# define sig SIGSEGV
@@ -1887,7 +2168,7 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
old_handler = GC_old_bus_handler;
}
if (old_handler == SIG_DFL) {
-# ifndef MSWIN32
+# if !defined(MSWIN32) && !defined(MSWINCE)
GC_err_printf1("Segfault at 0x%lx\n", addr);
ABORT("Unexpected bus error or segmentation fault");
# else
@@ -1918,6 +2199,9 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
(*(REAL_SIG_PF)old_handler) (sig, code, scp);
return;
# endif
+# ifdef MACOSX
+ (*(REAL_SIG_PF)old_handler) (sig, code, scp);
+# endif
# ifdef MSWIN32
return((*old_handler)(exc_info));
# endif
@@ -1935,13 +2219,13 @@ SIG_PF GC_old_segv_handler; /* Also old MSWIN32 ACCESS_VIOLATION filter */
# endif
/* The write may not take place before dirty bits are read. */
/* But then we'll fault again ... */
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
return(EXCEPTION_CONTINUE_EXECUTION);
# else
return;
# endif
}
-#ifdef MSWIN32
+#if defined(MSWIN32) || defined(MSWINCE)
return EXCEPTION_CONTINUE_SEARCH;
#else
GC_err_printf1("Segfault at 0x%lx\n", addr);
@@ -1978,17 +2262,24 @@ struct hblk *h;
void GC_dirty_init()
{
-#if defined(SUNOS5SIGS) || defined(IRIX5) /* || defined(OSF1) */
- struct sigaction act, oldact;
-# ifdef IRIX5
+# if defined(SUNOS5SIGS) || defined(IRIX5) /* || defined(OSF1) */
+ struct sigaction act, oldact;
+# ifdef IRIX5
act.sa_flags = SA_RESTART;
act.sa_handler = GC_write_fault_handler;
-# else
+# else
act.sa_flags = SA_RESTART | SA_SIGINFO;
act.sa_sigaction = GC_write_fault_handler;
+# endif
+ (void)sigemptyset(&act.sa_mask);
+# endif
+# if defined(MACOSX)
+ struct sigaction act, oldact;
+
+ act.sa_flags = SA_RESTART;
+ act.sa_handler = GC_write_fault_handler;
+ sigemptyset(&act.sa_mask);
# endif
- (void)sigemptyset(&act.sa_mask);
-#endif
# ifdef PRINTSTATS
GC_printf0("Inititalizing mprotect virtual dirty bit implementation\n");
# endif
@@ -2022,7 +2313,7 @@ void GC_dirty_init()
}
# endif
# if defined(SUNOS5SIGS) || defined(IRIX5)
-# if defined(IRIX_THREADS) || defined(IRIX_JDK_THREADS)
+# if defined(IRIX_THREADS)
sigaction(SIGSEGV, 0, &oldact);
sigaction(SIGSEGV, &act, 0);
# else
@@ -2048,16 +2339,20 @@ void GC_dirty_init()
GC_err_printf0("Replaced other SIGSEGV handler\n");
# endif
}
-# ifdef HPUX
- sigaction(SIGBUS, &act, &oldact);
- GC_old_bus_handler = oldact.sa_handler;
- if (GC_old_segv_handler != SIG_DFL) {
-# ifdef PRINTSTATS
- GC_err_printf0("Replaced other SIGBUS handler\n");
-# endif
- }
-# endif
-# endif
+# endif
+# if defined(MACOSX) || defined(HPUX)
+ sigaction(SIGBUS, &act, &oldact);
+ GC_old_bus_handler = oldact.sa_handler;
+ if (GC_old_bus_handler == SIG_IGN) {
+ GC_err_printf0("Previously ignored bus error!?");
+ GC_old_bus_handler = SIG_DFL;
+ }
+ if (GC_old_bus_handler != SIG_DFL) {
+# ifdef PRINTSTATS
+ GC_err_printf0("Replaced other SIGBUS handler\n");
+# endif
+ }
+# endif /* MACOS || HPUX */
# if defined(MSWIN32)
GC_old_segv_handler = SetUnhandledExceptionFilter(GC_write_fault_handler);
if (GC_old_segv_handler != NULL) {
@@ -2110,15 +2405,23 @@ struct hblk * h;
* happens to work.
* On other systems, SET_LOCK_HOLDER and friends must be suitably defined.
*/
+
+static GC_bool syscall_acquired_lock = FALSE; /* Protected by GC lock. */
void GC_begin_syscall()
{
- if (!I_HOLD_LOCK()) LOCK();
+ if (!I_HOLD_LOCK()) {
+ LOCK();
+ syscall_acquired_lock = TRUE;
+ }
}
void GC_end_syscall()
{
- if (!I_HOLD_LOCK()) UNLOCK();
+ if (syscall_acquired_lock) {
+ syscall_acquired_lock = FALSE;
+ UNLOCK();
+ }
}
void GC_unprotect_range(addr, len)
@@ -2148,7 +2451,7 @@ word len;
((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE);
}
-#if !defined(MSWIN32) && !defined(LINUX_THREADS)
+#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(LINUX_THREADS)
/* Replacement for UNIX system call. */
/* Other calls that write to the heap */
/* should be handled similarly. */
@@ -2185,14 +2488,17 @@ word len;
result = readv(fd, &iov, 1);
}
# else
- result = syscall(SYS_read, fd, buf, nbyte);
+ /* The two zero args at the end of this list are because one
+ IA-64 syscall() implementation actually requires six args
+ to be passed, even though they aren't always used. */
+ result = syscall(SYS_read, fd, buf, nbyte, 0, 0);
# endif
GC_end_syscall();
return(result);
}
-#endif /* !MSWIN32 && !LINUX */
+#endif /* !MSWIN32 && !MSWINCE && !LINUX_THREADS */
-#ifdef USE_LD_WRAP
+#ifdef GC_USE_LD_WRAP
/* We use the GNU ld call wrapping facility. */
/* This requires that the linker be invoked with "--wrap read". */
/* This can be done by passing -Wl,"--wrap read" to gcc. */
@@ -2547,29 +2853,56 @@ struct hblk *h;
* Call stack save code for debugging.
* Should probably be in mach_dep.c, but that requires reorganization.
*/
-#if defined(SPARC) && !defined(LINUX)
-# if defined(SUNOS4)
-# include <machine/frame.h>
-# else
-# if defined (DRSNX)
-# include <sys/sparc/frame.h>
-# else
-# if defined(OPENBSD)
-# include <frame.h>
-# else
-# include <sys/frame.h>
-# endif
-# endif
-# endif
-# if NARGS > 6
+
+/* I suspect the following works for most X86 *nix variants, so */
+/* long as the frame pointer is explicitly stored. In the case of gcc, */
+/* compiler flags (e.g. -fomit-frame-pointer) determine whether it is. */
+#if defined(I386) && defined(LINUX) && defined(SAVE_CALL_CHAIN)
+ struct frame {
+ struct frame *fr_savfp;
+ long fr_savpc;
+ long fr_arg[NARGS]; /* All the arguments go here. */
+ };
+#endif
+
+#if defined(SPARC)
+# if defined(LINUX)
+ struct frame {
+ long fr_local[8];
+ long fr_arg[6];
+ struct frame *fr_savfp;
+ long fr_savpc;
+# ifndef __arch64__
+ char *fr_stret;
+# endif
+ long fr_argd[6];
+ long fr_argx[0];
+ };
+# else
+# if defined(SUNOS4)
+# include <machine/frame.h>
+# else
+# if defined (DRSNX)
+# include <sys/sparc/frame.h>
+# else
+# if defined(OPENBSD)
+# include <frame.h>
+# else
+# include <sys/frame.h>
+# endif
+# endif
+# endif
+# endif
+# if NARGS > 6
--> We only know how to to get the first 6 arguments
-# endif
+# endif
+#endif /* SPARC */
#ifdef SAVE_CALL_CHAIN
/* Fill in the pc and argument information for up to NFRAMES of my */
/* callers. Ignore my frame and my callers frame. */
-#ifdef OPENBSD
+#if defined(OPENBSD) && defined(SPARC)
# define FR_SAVFP fr_fp
# define FR_SAVPC fr_pc
#else
@@ -2577,18 +2910,31 @@ struct hblk *h;
# define FR_SAVPC fr_savpc
#endif
+#if defined(SPARC) && (defined(__arch64__) || defined(__sparcv9))
+# define BIAS 2047
+#else
+# define BIAS 0
+#endif
+
void GC_save_callers (info)
struct callinfo info[NFRAMES];
{
struct frame *frame;
struct frame *fp;
int nframes = 0;
- word GC_save_regs_in_stack();
+# ifdef I386
+ /* We assume this is turned on only with gcc as the compiler. */
+ asm("movl %%ebp,%0" : "=r"(frame));
+ fp = frame;
+# else
+ word GC_save_regs_in_stack();
- frame = (struct frame *) GC_save_regs_in_stack ();
+ frame = (struct frame *) GC_save_regs_in_stack ();
+ fp = (struct frame *)((long) frame -> FR_SAVFP + BIAS);
+#endif
- for (fp = frame -> FR_SAVFP; fp != 0 && nframes < NFRAMES;
- fp = fp -> FR_SAVFP, nframes++) {
+ for (; fp != 0 && nframes < NFRAMES;
+ fp = (struct frame *)((long) fp -> FR_SAVFP + BIAS), nframes++) {
register int i;
info[nframes].ci_pc = fp->FR_SAVPC;
@@ -2600,7 +2946,6 @@ struct callinfo info[NFRAMES];
}
#endif /* SAVE_CALL_CHAIN */
-#endif /* SPARC */
diff --git a/pcr_interface.c b/pcr_interface.c
index 4c950933..65c3a261 100644
--- a/pcr_interface.c
+++ b/pcr_interface.c
@@ -10,8 +10,7 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, February 7, 1996 11:09 am PST */
-# include "gc_priv.h"
+# include "private/gc_priv.h"
# ifdef PCR
/*
diff --git a/powerpc_macosx_mach_dep.s b/powerpc_macosx_mach_dep.s
new file mode 100644
index 00000000..fad41d1c
--- /dev/null
+++ b/powerpc_macosx_mach_dep.s
@@ -0,0 +1,66 @@
+ .text
+
+ .set linkageArea,24
+ .set params,4
+ .set alignment,4
+
+ .set spaceToSave,linkageArea+params+alignment
+ .set spaceToSave8,spaceToSave+8
+
+; Mark from machine registers that are saved by C compiler
+ .globl _GC_push_regs
+_GC_push_regs:
+ ; PROLOG
+ mflr r0 ; get return address
+ stw r0,8(r1) ; save return address
+ stwu r1,-spaceToSave(r1) ; skip over caller save area
+ ;
+ mr r3,r2 ; mark from r2. Well I'm not really sure
+ ; that this is necessary or even the right
+ ; thing to do - at least it doesn't harm...
+ ; According to Apple's docs it points to
+ ; the direct data area, whatever that is...
+ bl _GC_push_one
+ mr r3,r13 ; mark from r13-r31
+ bl _GC_push_one
+ mr r3,r14
+ bl _GC_push_one
+ mr r3,r15
+ bl _GC_push_one
+ mr r3,r16
+ bl _GC_push_one
+ mr r3,r17
+ bl _GC_push_one
+ mr r3,r18
+ bl _GC_push_one
+ mr r3,r19
+ bl _GC_push_one
+ mr r3,r20
+ bl _GC_push_one
+ mr r3,r21
+ bl _GC_push_one
+ mr r3,r22
+ bl _GC_push_one
+ mr r3,r23
+ bl _GC_push_one
+ mr r3,r24
+ bl _GC_push_one
+ mr r3,r25
+ bl _GC_push_one
+ mr r3,r26
+ bl _GC_push_one
+ mr r3,r27
+ bl _GC_push_one
+ mr r3,r28
+ bl _GC_push_one
+ mr r3,r29
+ bl _GC_push_one
+ mr r3,r30
+ bl _GC_push_one
+ mr r3,r31
+ bl _GC_push_one
+ ; EPILOG
+ lwz r0,spaceToSave8(r1) ; get return address back
+ mtlr r0 ; reset link register
+ addic r1,r1,spaceToSave ; restore stack pointer
+ blr
diff --git a/ptr_chck.c b/ptr_chck.c
index f3451ee6..9c71576b 100644
--- a/ptr_chck.c
+++ b/ptr_chck.c
@@ -10,10 +10,9 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, September 19, 1995 1:26 pm PDT */
-#include "gc_priv.h"
-#include "gc_mark.h"
+#include "private/gc_priv.h"
+#include "private/gc_mark.h"
#ifdef __STDC__
void GC_default_same_obj_print_proc(GC_PTR p, GC_PTR q)
@@ -252,7 +251,8 @@ ptr_t p;
if (GC_is_static_root(p)) return(p);
/* Else do it again correctly: */
-# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || defined(PCR)) \
+# if (defined(DYNAMIC_LOADING) || defined(MSWIN32) || \
+ defined(MSWINCE) || defined(PCR)) \
&& !defined(SRC_M3)
DISABLE_SIGNALS();
GC_register_dynamic_libraries();
diff --git a/reclaim.c b/reclaim.c
index 4ace1107..7065cfaf 100644
--- a/reclaim.c
+++ b/reclaim.c
@@ -15,11 +15,18 @@
*/
#include <stdio.h>
-#include "gc_priv.h"
+#include "private/gc_priv.h"
signed_word GC_mem_found = 0;
/* Number of words of memory reclaimed */
+#ifdef PARALLEL_MARK
+ word GC_fl_builder_count = 0;
+ /* Number of threads currently building free lists without */
+ /* holding GC lock. It is not safe to collect if this is */
+ /* nonzero. */
+#endif /* PARALLEL_MARK */
+
static void report_leak(p, sz)
ptr_t p;
word sz;
@@ -54,9 +61,12 @@ word sz;
GC_bool GC_block_empty(hhdr)
register hdr * hhdr;
{
+ /* We treat hb_marks as an array of words here, even if it is */
+ /* actually an array of bytes. Since we only check for zero, there */
+ /* are no endian-ness issues. */
register word *p = (word *)(&(hhdr -> hb_marks[0]));
register word * plim =
- (word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
+ (word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
while (p < plim) {
if (*p++) return(FALSE);
}
@@ -70,7 +80,45 @@ register hdr * hhdr;
# define GC_block_nearly_full1(hhdr, pat1) DONT_KNOW
# define GC_block_nearly_full3(hhdr, pat1, pat2) DONT_KNOW
# define GC_block_nearly_full(hhdr) DONT_KNOW
-#else
+#endif
+
+#if !defined(SMALL_CONFIG) && defined(USE_MARK_BYTES)
+
+# define GC_block_nearly_full1(hhdr, pat1) GC_block_nearly_full(hhdr)
+# define GC_block_nearly_full3(hhdr, pat1, pat2) GC_block_nearly_full(hhdr)
+
+
+GC_bool GC_block_nearly_full(hhdr)
+register hdr * hhdr;
+{
+ /* We again treat hb_marks as an array of words, even though it */
+ /* isn't. We first sum up all the words, resulting in a word */
+ /* containing 4 or 8 separate partial sums. */
+ /* We then sum the bytes in the word of partial sums. */
+ /* This is still endian independant. This fails if the partial */
+ /* sums can overflow. */
+# if (BYTES_TO_WORDS(MARK_BITS_SZ)) >= 256
+ --> potential overflow; fix the code
+# endif
+ register word *p = (word *)(&(hhdr -> hb_marks[0]));
+ register word * plim =
+ (word *)(&(hhdr -> hb_marks[MARK_BITS_SZ]));
+ word sum_vector = 0;
+ unsigned sum;
+ while (p < plim) {
+ sum_vector += *p;
+ ++p;
+ }
+ sum = 0;
+ while (sum_vector > 0) {
+ sum += sum_vector & 0xff;
+ sum_vector >>= 8;
+ }
+ return (sum > BYTES_TO_WORDS(7*HBLKSIZE/8)/(hhdr -> hb_sz));
+}
+#endif /* USE_MARK_BYTES */
+
+#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
/*
* Test whether nearly all of the mark words consist of the same
@@ -194,12 +242,28 @@ hdr *hhdr;
}
# endif
}
-#endif /* !SMALL_CONFIG */
+#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
-# ifdef GATHERSTATS
+/* We keep track of reclaimed memory if we are either asked to, or */
+/* we are using the parallel marker. In the latter case, we assume */
+/* that most allocation goes through GC_malloc_many for scalability. */
+/* GC_malloc_many needs the count anyway. */
+# if defined(GATHERSTATS) || defined(PARALLEL_MARK)
# define INCR_WORDS(sz) n_words_found += (sz)
+# define COUNT_PARAM , count
+# define COUNT_ARG , count
+# define COUNT_DECL signed_word * count;
+# define NWORDS_DECL signed_word n_words_found = 0;
+# define COUNT_UPDATE *count += n_words_found;
+# define MEM_FOUND_ADDR , &GC_mem_found
# else
# define INCR_WORDS(sz)
+# define COUNT_PARAM
+# define COUNT_ARG
+# define COUNT_DECL
+# define NWORDS_DECL
+# define COUNT_UPDATE
+# define MEM_FOUND_ADDR
# endif
/*
* Restore unmarked small objects in h of size sz to the object
@@ -207,18 +271,18 @@ hdr *hhdr;
* Clears unmarked objects.
*/
/*ARGSUSED*/
-ptr_t GC_reclaim_clear(hbp, hhdr, sz, list)
+ptr_t GC_reclaim_clear(hbp, hhdr, sz, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
register hdr * hhdr;
register ptr_t list;
register word sz;
+COUNT_DECL
{
register int word_no;
register word *p, *q, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
+ NWORDS_DECL
+ GC_ASSERT(hhdr == GC_find_header((ptr_t)hbp));
p = (word *)(hbp->hb_body);
word_no = HDR_WORDS;
plim = (word *)((((word)hbp) + HBLKSIZE)
@@ -235,37 +299,45 @@ register word sz;
list = ((ptr_t)p);
/* Clear object, advance p to next object in the process */
q = p + sz;
- p++; /* Skip link field */
- while (p < q) {
+# ifdef USE_MARK_BYTES
+ GC_ASSERT(!(sz & 1)
+ && !((word)p & (2 * sizeof(word) - 1)));
+ p[1] = 0;
+ p += 2;
+ while (p < q) {
+ CLEAR_DOUBLE(p);
+ p += 2;
+ }
+# else
+ p++; /* Skip link field */
+ while (p < q) {
*p++ = 0;
- }
+ }
+# endif
}
word_no += sz;
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
}
-#ifndef SMALL_CONFIG
+#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
/*
* A special case for 2 word composite objects (e.g. cons cells):
*/
/*ARGSUSED*/
-ptr_t GC_reclaim_clear2(hbp, hhdr, list)
+ptr_t GC_reclaim_clear2(hbp, hhdr, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
hdr * hhdr;
register ptr_t list;
+COUNT_DECL
{
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
register word mark_word;
register int i;
+ NWORDS_DECL
# define DO_OBJ(start_displ) \
if (!(mark_word & ((word)1 << start_displ))) { \
p[start_displ] = (word)list; \
@@ -289,9 +361,7 @@ register ptr_t list;
mark_word >>= 8;
}
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
# undef DO_OBJ
}
@@ -300,17 +370,16 @@ register ptr_t list;
* Another special case for 4 word composite objects:
*/
/*ARGSUSED*/
-ptr_t GC_reclaim_clear4(hbp, hhdr, list)
+ptr_t GC_reclaim_clear4(hbp, hhdr, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
hdr * hhdr;
register ptr_t list;
+COUNT_DECL
{
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
register word mark_word;
+ NWORDS_DECL
# define DO_OBJ(start_displ) \
if (!(mark_word & ((word)1 << start_displ))) { \
p[start_displ] = (word)list; \
@@ -346,28 +415,25 @@ register ptr_t list;
# endif
p += WORDSZ;
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
# undef DO_OBJ
}
-#endif /* !SMALL_CONFIG */
+#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
/* The same thing, but don't clear objects: */
/*ARGSUSED*/
-ptr_t GC_reclaim_uninit(hbp, hhdr, sz, list)
+ptr_t GC_reclaim_uninit(hbp, hhdr, sz, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
register hdr * hhdr;
register ptr_t list;
register word sz;
+COUNT_DECL
{
register int word_no;
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
+ NWORDS_DECL
p = (word *)(hbp->hb_body);
word_no = HDR_WORDS;
@@ -385,9 +451,7 @@ register word sz;
p += sz;
word_no += sz;
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
}
@@ -419,23 +483,22 @@ register word sz;
}
}
-#ifndef SMALL_CONFIG
+#if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
/*
* Another special case for 2 word atomic objects:
*/
/*ARGSUSED*/
-ptr_t GC_reclaim_uninit2(hbp, hhdr, list)
+ptr_t GC_reclaim_uninit2(hbp, hhdr, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
hdr * hhdr;
register ptr_t list;
+COUNT_DECL
{
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
register word mark_word;
register int i;
+ NWORDS_DECL
# define DO_OBJ(start_displ) \
if (!(mark_word & ((word)1 << start_displ))) { \
p[start_displ] = (word)list; \
@@ -458,9 +521,7 @@ register ptr_t list;
mark_word >>= 8;
}
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
# undef DO_OBJ
}
@@ -469,17 +530,16 @@ register ptr_t list;
* Another special case for 4 word atomic objects:
*/
/*ARGSUSED*/
-ptr_t GC_reclaim_uninit4(hbp, hhdr, list)
+ptr_t GC_reclaim_uninit4(hbp, hhdr, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
hdr * hhdr;
register ptr_t list;
+COUNT_DECL
{
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
register word mark_word;
+ NWORDS_DECL
# define DO_OBJ(start_displ) \
if (!(mark_word & ((word)1 << start_displ))) { \
p[start_displ] = (word)list; \
@@ -513,27 +573,24 @@ register ptr_t list;
# endif
p += WORDSZ;
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
# undef DO_OBJ
}
/* Finally the one word case, which never requires any clearing: */
/*ARGSUSED*/
-ptr_t GC_reclaim1(hbp, hhdr, list)
+ptr_t GC_reclaim1(hbp, hhdr, list COUNT_PARAM)
register struct hblk *hbp; /* ptr to current heap block */
hdr * hhdr;
register ptr_t list;
+COUNT_DECL
{
register word * mark_word_addr = &(hhdr->hb_marks[divWORDSZ(HDR_WORDS)]);
register word *p, *plim;
-# ifdef GATHERSTATS
- register int n_words_found = 0;
-# endif
register word mark_word;
register int i;
+ NWORDS_DECL
# define DO_OBJ(start_displ) \
if (!(mark_word & ((word)1 << start_displ))) { \
p[start_displ] = (word)list; \
@@ -556,44 +613,32 @@ register ptr_t list;
mark_word >>= 4;
}
}
-# ifdef GATHERSTATS
- GC_mem_found += n_words_found;
-# endif
+ COUNT_UPDATE
return(list);
# undef DO_OBJ
}
-#endif /* !SMALL_CONFIG */
+#endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
/*
- * Restore unmarked small objects in the block pointed to by hbp
- * to the appropriate object free list.
- * If entirely empty blocks are to be completely deallocated, then
- * caller should perform that check.
+ * Generic procedure to rebuild a free list in hbp.
+ * Also called directly from GC_malloc_many.
*/
-void GC_reclaim_small_nonempty_block(hbp, report_if_found)
-register struct hblk *hbp; /* ptr to current heap block */
-int report_if_found; /* Abort if a reclaimable object is found */
+ptr_t GC_reclaim_generic(hbp, hhdr, sz, init, list COUNT_PARAM)
+struct hblk *hbp; /* ptr to current heap block */
+hdr * hhdr;
+GC_bool init;
+ptr_t list;
+word sz;
+COUNT_DECL
{
- hdr * hhdr;
- word sz; /* size of objects in current block */
- struct obj_kind * ok;
- ptr_t * flh;
- int kind;
GC_bool full;
-
- hhdr = HDR(hbp);
- sz = hhdr -> hb_sz;
- hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no;
- kind = hhdr -> hb_obj_kind;
- ok = &GC_obj_kinds[kind];
- flh = &(ok -> ok_freelist[sz]);
+ ptr_t result = list;
- if (report_if_found) {
- GC_reclaim_check(hbp, hhdr, sz);
- } else if (ok -> ok_init) {
+ GC_ASSERT(GC_find_header((ptr_t)hbp) == hhdr);
+ if (init) {
switch(sz) {
-# ifndef SMALL_CONFIG
+# if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
case 1:
# if CPP_WORDSZ == 64
full = GC_block_nearly_full1(hhdr, 0xffffffffffffffffl);
@@ -603,7 +648,7 @@ int report_if_found; /* Abort if a reclaimable object is found */
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
/* In the DONT_KNOW case, we let reclaim fault. */
- *flh = GC_reclaim1(hbp, hhdr, *flh);
+ result = GC_reclaim1(hbp, hhdr, list COUNT_ARG);
break;
case 2:
# if CPP_WORDSZ == 64
@@ -613,7 +658,7 @@ int report_if_found; /* Abort if a reclaimable object is found */
# endif
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_clear2(hbp, hhdr, *flh);
+ result = GC_reclaim_clear2(hbp, hhdr, list COUNT_ARG);
break;
case 4:
# if CPP_WORDSZ == 64
@@ -623,19 +668,19 @@ int report_if_found; /* Abort if a reclaimable object is found */
# endif
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_clear4(hbp, hhdr, *flh);
+ result = GC_reclaim_clear4(hbp, hhdr, list COUNT_ARG);
break;
-# endif
+# endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
default:
full = GC_block_nearly_full(hhdr);
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_clear(hbp, hhdr, sz, *flh);
+ result = GC_reclaim_clear(hbp, hhdr, sz, list COUNT_ARG);
break;
}
} else {
switch(sz) {
-# ifndef SMALL_CONFIG
+# if !defined(SMALL_CONFIG) && !defined(USE_MARK_BYTES)
case 1:
# if CPP_WORDSZ == 64
full = GC_block_nearly_full1(hhdr, 0xffffffffffffffffl);
@@ -644,7 +689,7 @@ int report_if_found; /* Abort if a reclaimable object is found */
# endif
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim1(hbp, hhdr, *flh);
+ result = GC_reclaim1(hbp, hhdr, list COUNT_ARG);
break;
case 2:
# if CPP_WORDSZ == 64
@@ -654,7 +699,7 @@ int report_if_found; /* Abort if a reclaimable object is found */
# endif
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_uninit2(hbp, hhdr, *flh);
+ result = GC_reclaim_uninit2(hbp, hhdr, list COUNT_ARG);
break;
case 4:
# if CPP_WORDSZ == 64
@@ -664,19 +709,47 @@ int report_if_found; /* Abort if a reclaimable object is found */
# endif
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_uninit4(hbp, hhdr, *flh);
+ result = GC_reclaim_uninit4(hbp, hhdr, list COUNT_ARG);
break;
-# endif
+# endif /* !SMALL_CONFIG && !USE_MARK_BYTES */
default:
full = GC_block_nearly_full(hhdr);
if (TRUE == full) goto out;
if (FALSE == full) GC_write_hint(hbp);
- *flh = GC_reclaim_uninit(hbp, hhdr, sz, *flh);
+ result = GC_reclaim_uninit(hbp, hhdr, sz, list COUNT_ARG);
break;
}
}
out:
- if (IS_UNCOLLECTABLE(kind)) GC_set_hdr_marks(hhdr);
+ if (IS_UNCOLLECTABLE(hhdr -> hb_obj_kind)) GC_set_hdr_marks(hhdr);
+ return result;
+}
+
+/*
+ * Restore unmarked small objects in the block pointed to by hbp
+ * to the appropriate object free list.
+ * If entirely empty blocks are to be completely deallocated, then
+ * caller should perform that check.
+ */
+void GC_reclaim_small_nonempty_block(hbp, report_if_found COUNT_PARAM)
+register struct hblk *hbp; /* ptr to current heap block */
+int report_if_found; /* Abort if a reclaimable object is found */
+COUNT_DECL
+{
+ hdr *hhdr = HDR(hbp);
+ word sz = hhdr -> hb_sz;
+ int kind = hhdr -> hb_obj_kind;
+ struct obj_kind * ok = &GC_obj_kinds[kind];
+ ptr_t * flh = &(ok -> ok_freelist[sz]);
+
+ hhdr -> hb_last_reclaimed = (unsigned short) GC_gc_no;
+
+ if (report_if_found) {
+ GC_reclaim_check(hbp, hhdr, sz);
+ } else {
+ *flh = GC_reclaim_generic(hbp, hhdr, sz, ok -> ok_init,
+ *flh MEM_FOUND_ADDR);
+ }
}
/*
@@ -687,9 +760,13 @@ out:
* If report_if_found is TRUE, then process any block immediately, and
* simply report free objects; do not actually reclaim them.
*/
-void GC_reclaim_block(hbp, report_if_found)
-register struct hblk *hbp; /* ptr to current heap block */
-word report_if_found; /* Abort if a reclaimable object is found */
+# if defined(__STDC__) || defined(__cplusplus)
+ void GC_reclaim_block(register struct hblk *hbp, word report_if_found)
+# else
+ void GC_reclaim_block(hbp, report_if_found)
+ register struct hblk *hbp; /* ptr to current heap block */
+ word report_if_found; /* Abort if a reclaimable object is found */
+# endif
{
register hdr * hhdr;
register word sz; /* size of objects in current block */
@@ -714,7 +791,8 @@ word report_if_found; /* Abort if a reclaimable object is found */
} else {
GC_bool empty = GC_block_empty(hhdr);
if (report_if_found) {
- GC_reclaim_small_nonempty_block(hbp, (int)report_if_found);
+ GC_reclaim_small_nonempty_block(hbp, (int)report_if_found
+ MEM_FOUND_ADDR);
} else if (empty) {
# ifdef GATHERSTATS
GC_mem_found += BYTES_TO_WORDS(HBLKSIZE);
@@ -736,6 +814,23 @@ word report_if_found; /* Abort if a reclaimable object is found */
static size_t number_of_blocks;
static size_t total_bytes;
+#ifdef USE_MARK_BYTES
+
+/* Return the number of set mark bits in the given header */
+int GC_n_set_marks(hhdr)
+hdr * hhdr;
+{
+ register int result = 0;
+ register int i;
+
+ for (i = 0; i < MARK_BITS_SZ; i++) {
+ result += hhdr -> hb_marks[i];
+ }
+ return(result);
+}
+
+#else
+
/* Number of set bits in a word. Not performance critical. */
static int set_bits(n)
word n;
@@ -763,10 +858,16 @@ hdr * hhdr;
return(result);
}
+#endif /* !USE_MARK_BYTES */
+
/*ARGSUSED*/
-void GC_print_block_descr(h, dummy)
-struct hblk *h;
-word dummy;
+# if defined(__STDC__) || defined(__cplusplus)
+ void GC_print_block_descr(struct hblk *h, word dummy)
+# else
+ void GC_print_block_descr(h, dummy)
+ struct hblk *h;
+ word dummy;
+# endif
{
register hdr * hhdr = HDR(h);
register size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz);
@@ -861,7 +962,7 @@ int kind;
while ((hbp = *rlh) != 0) {
hhdr = HDR(hbp);
*rlh = hhdr -> hb_next;
- GC_reclaim_small_nonempty_block(hbp, FALSE);
+ GC_reclaim_small_nonempty_block(hbp, FALSE MEM_FOUND_ADDR);
if (*flh != 0) break;
}
}
@@ -909,7 +1010,7 @@ GC_bool ignore_old;
/* It's likely we'll need it this time, too */
/* It's been touched recently, so this */
/* shouldn't trigger paging. */
- GC_reclaim_small_nonempty_block(hbp, FALSE);
+ GC_reclaim_small_nonempty_block(hbp, FALSE MEM_FOUND_ADDR);
}
}
}
diff --git a/setjmp_t.c b/setjmp_t.c
index 1c9253e9..a4a8cae4 100644
--- a/setjmp_t.c
+++ b/setjmp_t.c
@@ -10,7 +10,6 @@
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
-/* Boehm, September 21, 1995 5:39 pm PDT */
/* Check whether setjmp actually saves registers in jmp_buf. */
/* If it doesn't, the generic mark_regs code won't work. */
@@ -25,7 +24,7 @@
#include <stdio.h>
#include <setjmp.h>
#include <string.h>
-#include "gcconfig.h"
+#include "private/gcconfig.h"
#ifdef OS2
/* GETPAGESIZE() is set to getpagesize() by default, but that */
diff --git a/solaris_pthreads.c b/solaris_pthreads.c
index 467de484..02c33801 100644
--- a/solaris_pthreads.c
+++ b/solaris_pthreads.c
@@ -18,8 +18,8 @@
/* Boehm, September 14, 1994 4:44 pm PDT */
/* $Id: solaris_pthreads.c,v 1.10 1997/05/13 23:09:09 peterc Exp $ */
-# if defined(_SOLARIS_PTHREADS)
-# include "gc_priv.h"
+# if defined(GC_SOLARIS_PTHREADS) || defined(_SOLARIS_PTHREADS)
+# include "private/gc_priv.h"
# include <pthread.h>
# include <thread.h>
# include <signal.h>
@@ -36,7 +36,7 @@
# define _CLASSIC_XOPEN_TYPES
# include <unistd.h>
# include <errno.h>
-# include "solaris_threads.h"
+# include "private/solaris_threads.h"
# include <stdio.h>
#undef pthread_join
diff --git a/solaris_threads.c b/solaris_threads.c
index c3b0b15b..3b449e43 100644
--- a/solaris_threads.c
+++ b/solaris_threads.c
@@ -16,10 +16,10 @@
*/
/* Boehm, September 14, 1994 4:44 pm PDT */
-# if defined(SOLARIS_THREADS)
+# if defined(GC_SOLARIS_THREADS) || defined(SOLARIS_THREADS)
-# include "gc_priv.h"
-# include "solaris_threads.h"
+# include "private/gc_priv.h"
+# include "private/solaris_threads.h"
# include <thread.h>
# include <synch.h>
# include <signal.h>
@@ -573,7 +573,7 @@ GC_thread GC_new_thread(thread_t id)
/* Dont acquire allocation lock, since we may already hold it. */
} else {
result = (struct GC_Thread_Rep *)
- GC_generic_malloc_inner(sizeof(struct GC_Thread_Rep), NORMAL);
+ GC_INTERNAL_MALLOC(sizeof(struct GC_Thread_Rep), NORMAL);
}
if (result == 0) return(0);
result -> id = id;
@@ -627,7 +627,7 @@ word GC_get_orig_stack_size() {
result = (word)rl.rlim_cur & ~(HBLKSIZE-1);
if (result > MAX_ORIG_STACK_SIZE) {
if (!warned) {
- WARN("Large stack limit(%ld): only scanning 8 MB", result);
+ WARN("Large stack limit(%ld): only scanning 8 MB\n", result);
warned = 1;
}
result = MAX_ORIG_STACK_SIZE;
diff --git a/specific.c b/specific.c
new file mode 100644
index 00000000..7425cf5c
--- /dev/null
+++ b/specific.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#if defined(LINUX_THREADS) || defined(GC_LINUX_THREADS)
+
+#include "private/gc_priv.h" /* For GC_compare_and_exchange, GC_memory_barrier */
+#include "private/specific.h"
+
+static tse invalid_tse; /* 0 qtid is guaranteed to be invalid */
+
+int PREFIXED(key_create) (tsd ** key_ptr, void (* destructor)(void *)) {
+ int i;
+ tsd * result = (tsd *)MALLOC_CLEAR(sizeof (tsd));
+
+ if (0 == result) return ENOMEM;
+ pthread_mutex_init(&(result -> lock), NULL);
+ for (i = 0; i < TS_CACHE_SIZE; ++i) {
+ result -> cache[i] = &invalid_tse;
+ }
+ *key_ptr = result;
+ return 0;
+}
+
+int PREFIXED(setspecific) (tsd * key, void * value) {
+ pthread_t self = pthread_self();
+ int hash_val = HASH(self);
+ tse * entry = (tse *)MALLOC_CLEAR(sizeof (tse));
+
+ if (0 == entry) return ENOMEM;
+ pthread_mutex_lock(&(key -> lock));
+ /* Could easily check for an existing entry here. */
+ entry -> next = key -> hash[hash_val];
+ entry -> thread = self;
+ entry -> value = value;
+ key -> hash[hash_val] = entry;
+ pthread_mutex_unlock(&(key -> lock));
+ return 0;
+}
+
+/* Remove thread-specific data for this thread. Should be called on */
+/* thread exit. */
+int PREFIXED(remove_specific) (tsd * key) {
+ pthread_t self = pthread_self();
+ unsigned hash_val = HASH(self);
+ tse *entry;
+ tse **link = key -> hash + hash_val;
+
+ pthread_mutex_lock(&(key -> lock));
+ entry = *link;
+ while (entry != NULL && entry -> thread != self) {
+ link = &(entry -> next);
+ entry = *link;
+ }
+ if (entry != NULL) {
+ *link = entry -> next;
+ /* Atomic! concurrent accesses still work. */
+ /* They must, since readers don't lock. */
+ }
+ /* If we wanted to deallocate the entry, we'd first have to clear */
+ /* any cache entries pointing to it. That probably requires */
+ /* additional synchronization, since we can't prevent a concurrent */
+ /* cache lookup, which should still be examining deallocated memory.*/
+ /* This can only happen if the concurrent access is from another */
+ /* thread, and hence has missed the cache, but still... */
+
+ /* With GC, we're done, since the pointers from the cache will */
+ /* be overwritten, all local pointers to the entries will be */
+ /* dropped, and the entry will then be reclaimed. */
+ pthread_mutex_unlock(&(key -> lock));
+}
+
+void * PREFIXED(slow_getspecific) (tsd * key, unsigned long qtid,
+ tse * volatile * cache_ptr) {
+ pthread_t self = pthread_self();
+ unsigned hash_val = HASH(self);
+ tse *entry = key -> hash[hash_val];
+ unsigned random = 1; /* A (somewhat) random value */
+
+ while (entry != NULL && entry -> thread != self) {
+ entry = entry -> next;
+ }
+ if (entry == NULL) return NULL;
+ /* Set cache_entry. */
+ entry -> qtid = qtid;
+ /* It's safe to do this asynchronously. Either value */
+ /* is safe, though may produce spurious misses. */
+ *cache_ptr = entry;
+ /* Again this is safe since pointer assignments are */
+ /* presumed atomic, and either pointer is valid. */
+ return entry -> value;
+}
+
+#endif /* LINUX_THREADS */
diff --git a/stubborn.c b/stubborn.c
index bef7b98a..6f213618 100644
--- a/stubborn.c
+++ b/stubborn.c
@@ -14,7 +14,7 @@
/* Boehm, July 31, 1995 5:02 pm PDT */
-#include "gc_priv.h"
+#include "private/gc_priv.h"
# ifdef STUBBORN_ALLOC
/* Stubborn object (hard to change, nearly immutable) allocation. */
@@ -50,7 +50,7 @@ void GC_stubborn_init()
# define INIT_SIZE 10
GC_changing_list_start = (GC_PTR *)
- GC_generic_malloc_inner(
+ GC_INTERNAL_MALLOC(
(word)(INIT_SIZE * sizeof(GC_PTR)),
PTRFREE);
BZERO(GC_changing_list_start,
@@ -88,7 +88,7 @@ GC_bool GC_compact_changing_list()
}
if (2 * count > old_size) new_size = 2 * count;
new_list = (GC_PTR *)
- GC_generic_malloc_inner(
+ GC_INTERNAL_MALLOC(
new_size * sizeof(GC_PTR), PTRFREE);
/* PTRFREE is a lie. But we don't want the collector to */
/* consider these. We do want the list itself to be */
diff --git a/test.c b/test.c
index 96a54150..c18c35e9 100644
--- a/test.c
+++ b/test.c
@@ -17,19 +17,33 @@
# undef GC_BUILD
+#ifdef DBG_HDRS_ALL
+# define GC_DEBUG
+#endif
+
# if defined(mips) && defined(SYSTYPE_BSD43)
/* MIPS RISCOS 4 */
# else
# include <stdlib.h>
# endif
# include <stdio.h>
+# ifdef _WIN32_WCE
+# include <winbase.h>
+# define assert ASSERT
+# else
+# include <assert.h> /* Not normally used, but handy for debugging. */
+# endif
# include <assert.h> /* Not normally used, but handy for debugging. */
-# include "gc.h"
-# include "gc_typed.h"
-# include "gc_priv.h" /* For output, locking, and some statistics */
-# include "gcconfig.h"
+# include "include/gc.h"
+# include "include/gc_typed.h"
+# ifdef THREAD_LOCAL_ALLOC
+# include "include/gc_local_alloc.h"
+# endif
+# include "include/private/gc_priv.h" /* For output, locking, MIN_WORDS, */
+ /* and some statistics. */
+# include "include/private/gcconfig.h"
-# ifdef MSWIN32
+# if defined(MSWIN32) || defined(MSWINCE)
# include <windows.h>
# endif
@@ -52,7 +66,10 @@
# endif
# ifdef WIN32_THREADS
-# include <process.h>
+# ifndef MSWINCE
+# include <process.h>
+# define GC_CreateThread(a,b,c,d,e,f) ((HANDLE) _beginthreadex(a,b,c,d,e,f))
+# endif
static CRITICAL_SECTION incr_cs;
# endif
@@ -60,9 +77,26 @@
long __stack = 200000;
# endif
-# define FAIL (void)abort()
-/* AT_END may be defined to excercise the interior pointer test */
+/* Allocation Statistics */
+int stubborn_count = 0;
+int uncollectable_count = 0;
+int collectable_count = 0;
+int atomic_count = 0;
+int realloc_count = 0;
+
+
+# ifdef PCR
+# define FAIL (void)abort()
+# else
+# ifdef MSWINCE
+# define FAIL DebugBreak()
+# else
+# define FAIL GC_abort("Test failed");
+# endif
+# endif
+
+/* AT_END may be defined to exercise the interior pointer test */
/* if the collector is configured with ALL_INTERIOR_POINTERS. */
/* As it stands, this test should succeed with either */
/* configuration. In the FIND_LEAK configuration, it should */
@@ -89,6 +123,9 @@ int extra_count = 0; /* Amount of space wasted in cons node */
/* Silly implementation of Lisp cons. Intentionally wastes lots of space */
/* to test collector. */
+# ifdef VERY_SMALL_CONFIG
+# define cons small_cons
+# else
sexpr cons (x, y)
sexpr x;
sexpr y;
@@ -97,6 +134,7 @@ sexpr y;
register int *p;
register int my_extra = extra_count;
+ stubborn_count++;
r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra);
if (r == 0) {
(void)GC_printf0("Out of memory\n");
@@ -125,6 +163,7 @@ sexpr y;
GC_END_STUBBORN_CHANGE((char *)r);
return(r);
}
+# endif
sexpr small_cons (x, y)
sexpr x;
@@ -132,6 +171,7 @@ sexpr y;
{
register sexpr r;
+ collectable_count++;
r = (sexpr) GC_MALLOC(sizeof(struct SEXPR));
if (r == 0) {
(void)GC_printf0("Out of memory\n");
@@ -148,6 +188,7 @@ sexpr y;
{
register sexpr r;
+ uncollectable_count++;
r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR));
if (r == 0) {
(void)GC_printf0("Out of memory\n");
@@ -211,7 +252,11 @@ sexpr y;
static int count = 0;
if (++count & 1) {
+# ifdef USE_MARK_BYTES
+ r = (GC_word *) GC_GCJ_FAST_MALLOC(4, &gcj_class_struct1);
+# else
r = (GC_word *) GC_GCJ_FAST_MALLOC(3, &gcj_class_struct1);
+# endif
} else {
r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR)
+ sizeof(struct fake_vtable*),
@@ -322,7 +367,6 @@ void check_uncollectable_ints(list, low, up)
sexpr list;
int low, up;
{
-assert(GC_is_marked(list));
if ((int)(GC_word)(car(car(list))) != low) {
(void)GC_printf0(
"Uncollectable list corrupted - collector is broken\n");
@@ -400,9 +444,8 @@ struct {
{
unsigned thread_id;
HANDLE h;
- h = (HANDLE)_beginthreadex(NULL, 0, tiny_reverse_test,
- 0, 0, &thread_id);
- if (h == (HANDLE)-1) {
+ h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
+ if (h == (HANDLE)NULL) {
(void)GC_printf1("Small thread creation failed %lu\n",
(unsigned long)GetLastError());
FAIL;
@@ -448,7 +491,12 @@ void reverse_test()
/* PCR default stack is 100K. Stack frames are up to 120 bytes. */
# define BIG 700
# else
-# define BIG 4500
+# if defined MSWINCE
+ /* WinCE only allows 64K stacks */
+# define BIG 500
+# else
+# define BIG 4500
+# endif
# endif
# endif
@@ -459,13 +507,19 @@ void reverse_test()
d = uncollectable_ints(1, 100);
e = uncollectable_ints(1, 1);
/* Check that realloc updates object descriptors correctly */
+ collectable_count++;
f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr));
+ realloc_count++;
f = (sexpr *)GC_REALLOC((GC_PTR)f, 6 * sizeof(sexpr));
f[5] = ints(1,17);
+ collectable_count++;
g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr));
+ realloc_count++;
g = (sexpr *)GC_REALLOC((GC_PTR)g, 800 * sizeof(sexpr));
g[799] = ints(1,18);
+ collectable_count++;
h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr));
+ realloc_count++;
h = (sexpr *)GC_REALLOC((GC_PTR)h, 2000 * sizeof(sexpr));
# ifdef GC_GCJ_SUPPORT
h[1999] = gcj_ints(1,200);
@@ -477,9 +531,11 @@ void reverse_test()
for (i = 0; i < 10; i++) {
(void)ints(1, BIG);
}
- /* Superficially test interior pointer recognition on stack */
- c = (sexpr)((char *)c + sizeof(char *));
- d = (sexpr)((char *)d + sizeof(char *));
+# ifdef ALL_INTERIOR_POINTERS
+ /* Superficially test interior pointer recognition on stack */
+ c = (sexpr)((char *)c + sizeof(char *));
+ d = (sexpr)((char *)d + sizeof(char *));
+# endif
# ifdef __STDC__
GC_FREE((void *)e);
@@ -511,8 +567,10 @@ void reverse_test()
}
check_ints(a,1,49);
check_ints(b,1,50);
- c = (sexpr)((char *)c - sizeof(char *));
- d = (sexpr)((char *)d - sizeof(char *));
+# ifdef ALL_INTERIOR_POINTERS
+ c = (sexpr)((char *)c - sizeof(char *));
+ d = (sexpr)((char *)d - sizeof(char *));
+# endif
check_ints(c,1,BIG);
check_uncollectable_ints(d, 1, 100);
check_ints(f[5], 1,17);
@@ -600,18 +658,23 @@ int live_indicators_count = 0;
tn * mktree(n)
int n;
{
- tn * result = (tn *)GC_MALLOC(sizeof(tn));
+# ifdef THREAD_LOCAL_ALLOC
+ tn * result = (tn *)GC_LOCAL_MALLOC(sizeof(tn));
+# else
+ tn * result = (tn *)GC_MALLOC(sizeof(tn));
+# endif
-#if defined(MACOS)
+ collectable_count++;
+# if defined(MACOS)
/* get around static data limitations. */
if (!live_indicators)
live_indicators =
(GC_word*)NewPtrClear(MAX_FINALIZED * sizeof(GC_word));
if (!live_indicators) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
-#endif
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+# endif
if (n == 0) return(0);
if (result == 0) {
(void)GC_printf0("Out of memory\n");
@@ -706,9 +769,15 @@ int n;
(unsigned long)n);
FAIL;
}
- if (counter++ % 373 == 0) (void) GC_MALLOC(counter%5001);
+ if (counter++ % 373 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%5001);
+ }
chktree(t -> lchild, n-1);
- if (counter++ % 73 == 0) (void) GC_MALLOC(counter%373);
+ if (counter++ % 73 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%373);
+ }
chktree(t -> rchild, n-1);
}
@@ -718,6 +787,7 @@ thread_key_t fl_key;
void * alloc8bytes()
{
# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
return(GC_MALLOC(8));
# else
void ** my_free_list_ptr;
@@ -728,6 +798,7 @@ void * alloc8bytes()
FAIL;
}
if (my_free_list_ptr == 0) {
+ uncollectable_count++;
my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
if (thr_setspecific(fl_key, my_free_list_ptr) != 0) {
(void)GC_printf0("thr_setspecific failed\n");
@@ -736,6 +807,7 @@ void * alloc8bytes()
}
my_free_list = *my_free_list_ptr;
if (my_free_list == 0) {
+ collectable_count++;
my_free_list = GC_malloc_many(8);
if (my_free_list == 0) {
(void)GC_printf0("alloc8bytes out of memory\n");
@@ -750,20 +822,23 @@ void * alloc8bytes()
#else
-# if defined(_SOLARIS_PTHREADS) || defined(IRIX_THREADS) \
- || defined(LINUX_THREADS) || defined(HPUX_THREADS)
+# if defined(GC_SOLARIS_PTHREADS) || defined(GC_IRIX_THREADS) \
+ || defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS) \
+ || defined(GC_SOLARIS_THREADS)
pthread_key_t fl_key;
void * alloc8bytes()
{
-# ifdef SMALL_CONFIG
- return(GC_malloc(8));
+# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
+ return(GC_MALLOC(8));
# else
void ** my_free_list_ptr;
void * my_free_list;
my_free_list_ptr = (void **)pthread_getspecific(fl_key);
if (my_free_list_ptr == 0) {
+ uncollectable_count++;
my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
if (pthread_setspecific(fl_key, my_free_list_ptr) != 0) {
(void)GC_printf0("pthread_setspecific failed\n");
@@ -780,6 +855,7 @@ void * alloc8bytes()
}
*my_free_list_ptr = GC_NEXT(my_free_list);
GC_NEXT(my_free_list) = 0;
+ collectable_count++;
return(my_free_list);
# endif
}
@@ -795,6 +871,7 @@ int n;
register int i;
for (i = 0; i < n; i += 8) {
+ atomic_count++;
if (alloc8bytes() == 0) {
(void)GC_printf0("Out of memory\n");
FAIL;
@@ -803,9 +880,17 @@ int n;
}
# if defined(THREADS) && defined(GC_DEBUG)
-# define TREE_HEIGHT 15
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 12
+# else
+# define TREE_HEIGHT 15
+# endif
# else
-# define TREE_HEIGHT 16
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 13
+# else
+# define TREE_HEIGHT 16
+# endif
# endif
void tree_test()
{
@@ -813,7 +898,9 @@ void tree_test()
register int i;
root = mktree(TREE_HEIGHT);
- alloc_small(5000000);
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
chktree(root, TREE_HEIGHT);
if (finalized_count && ! dropped_something) {
(void)GC_printf0("Premature finalization - collector is broken\n");
@@ -828,7 +915,9 @@ void tree_test()
root = mktree(i);
chktree(root, i);
}
- alloc_small(5000000);
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
}
unsigned n_tests = 0;
@@ -846,7 +935,6 @@ GC_word bm_huge[10] = {
0x00ffffff,
};
-
/* A very simple test of explicitly typed allocation */
void typed_test()
{
@@ -864,8 +952,10 @@ void typed_test()
GC_word * x = (GC_word *)GC_malloc_explicitly_typed(2000, d4);
register int i;
+ collectable_count++;
old = 0;
for (i = 0; i < 4000; i++) {
+ collectable_count++;
new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d1);
if (0 != new[0] || 0 != new[1]) {
GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
@@ -874,19 +964,23 @@ void typed_test()
new[0] = 17;
new[1] = (GC_word)old;
old = new;
+ collectable_count++;
new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d2);
new[0] = 17;
new[1] = (GC_word)old;
old = new;
+ collectable_count++;
new = (GC_word *) GC_malloc_explicitly_typed(33 * sizeof(GC_word), d3);
new[0] = 17;
new[1] = (GC_word)old;
old = new;
+ collectable_count++;
new = (GC_word *) GC_calloc_explicitly_typed(4, 2 * sizeof(GC_word),
d1);
new[0] = 17;
new[1] = (GC_word)old;
old = new;
+ collectable_count++;
if (i & 0xff) {
new = (GC_word *) GC_calloc_explicitly_typed(7, 3 * sizeof(GC_word),
d2);
@@ -958,68 +1052,76 @@ void run_one_test()
"This test program is not designed for leak detection mode\n");
(void)GC_printf0("Expect lots of problems.\n");
# endif
- if (GC_size(GC_malloc(7)) != 8
+ GC_FREE(0);
+# ifndef DBG_HDRS_ALL
+ collectable_count += 3;
+ if (GC_size(GC_malloc(7)) != 8 &&
+ GC_size(GC_malloc(7)) != MIN_WORDS * sizeof(GC_word)
|| GC_size(GC_malloc(15)) != 16) {
(void)GC_printf0("GC_size produced unexpected results\n");
FAIL;
- }
- if (GC_size(GC_malloc(0)) != 4 && GC_size(GC_malloc(0)) != 8) {
- (void)GC_printf0("GC_malloc(0) failed\n");
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc(0)) != MIN_WORDS * sizeof(GC_word)) {
+ (void)GC_printf1("GC_malloc(0) failed: GC_size returns %ld\n",
+ GC_size(GC_malloc(0)));
FAIL;
- }
- if (GC_size(GC_malloc_uncollectable(0)) != 4
- && GC_size(GC_malloc_uncollectable(0)) != 8) {
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc_uncollectable(0)) != MIN_WORDS * sizeof(GC_word)) {
(void)GC_printf0("GC_malloc_uncollectable(0) failed\n");
FAIL;
- }
- GC_FREE(0);
- GC_is_valid_displacement_print_proc = fail_proc1;
- GC_is_visible_print_proc = fail_proc1;
- x = GC_malloc(16);
- if (GC_base(x + 13) != x) {
+ }
+ GC_is_valid_displacement_print_proc = fail_proc1;
+ GC_is_visible_print_proc = fail_proc1;
+ collectable_count += 1;
+ x = GC_malloc(16);
+ if (GC_base(x + 13) != x) {
(void)GC_printf0("GC_base(heap ptr) produced incorrect result\n");
FAIL;
- }
-# ifndef PCR
- if (GC_base(y) != 0) {
- (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n");
- FAIL;
}
-# endif
- if (GC_same_obj(x+5, x) != x + 5) {
+# ifndef PCR
+ if (GC_base(y) != 0) {
+ (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n");
+ FAIL;
+ }
+# endif
+ if (GC_same_obj(x+5, x) != x + 5) {
(void)GC_printf0("GC_same_obj produced incorrect result\n");
FAIL;
- }
- if (GC_is_visible(y) != y || GC_is_visible(x) != x) {
+ }
+ if (GC_is_visible(y) != y || GC_is_visible(x) != x) {
(void)GC_printf0("GC_is_visible produced incorrect result\n");
FAIL;
- }
- if (!TEST_FAIL_COUNT(1)) {
+ }
+ if (!TEST_FAIL_COUNT(1)) {
# if!(defined(RS6000) || defined(POWERPC) || defined(IA64))
/* ON RS6000s function pointers point to a descriptor in the */
/* data segment, so there should have been no failures. */
(void)GC_printf0("GC_is_visible produced wrong failure indication\n");
FAIL;
# endif
- }
- if (GC_is_valid_displacement(y) != y
+ }
+ if (GC_is_valid_displacement(y) != y
|| GC_is_valid_displacement(x) != x
|| GC_is_valid_displacement(x + 3) != x + 3) {
(void)GC_printf0(
"GC_is_valid_displacement produced incorrect result\n");
FAIL;
- }
-# ifndef ALL_INTERIOR_POINTERS
-# if defined(RS6000) || defined(POWERPC)
- if (!TEST_FAIL_COUNT(1)) {
-# else
- if (!TEST_FAIL_COUNT(2)) {
-# endif
- (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n");
- FAIL;
}
-# endif
+# ifndef ALL_INTERIOR_POINTERS
+# if defined(RS6000) || defined(POWERPC)
+ if (!TEST_FAIL_COUNT(1)) {
+# else
+ if (!TEST_FAIL_COUNT(2)) {
+# endif
+ (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n");
+ FAIL;
+ }
+# endif
+# endif /* DBG_HDRS_ALL */
/* Test floating point alignment */
+ collectable_count += 2;
*(double *)GC_MALLOC(sizeof(double)) = 1.0;
*(double *)GC_MALLOC(sizeof(double)) = 1.0;
# ifdef GC_GCJ_SUPPORT
@@ -1031,10 +1133,12 @@ void run_one_test()
# ifdef PRINTSTATS
GC_printf0("-------------Finished reverse_test\n");
# endif
- typed_test();
-# ifdef PRINTSTATS
+# ifndef DBG_HDRS_ALL
+ typed_test();
+# ifdef PRINTSTATS
GC_printf0("-------------Finished typed_test\n");
-# endif
+# endif
+# endif /* DBG_HDRS_ALL */
tree_test();
LOCK();
n_tests++;
@@ -1049,14 +1153,23 @@ void check_heap_stats()
int still_live;
int late_finalize_count = 0;
+# ifdef VERY_SMALL_CONFIG
+ /* these are something of a guess */
+ if (sizeof(char *) > 4) {
+ max_heap_sz = 4500000;
+ } else {
+ max_heap_sz = 2800000;
+ }
+# else
if (sizeof(char *) > 4) {
max_heap_sz = 15000000;
} else {
max_heap_sz = 11000000;
}
+# endif
# ifdef GC_DEBUG
max_heap_sz *= 2;
-# ifdef SPARC
+# ifdef SAVE_CALL_CHAIN
max_heap_sz *= 2;
# endif
# endif
@@ -1068,6 +1181,10 @@ void check_heap_stats()
late_finalize_count += GC_invoke_finalizers();
}
(void)GC_printf1("Completed %lu tests\n", (unsigned long)n_tests);
+ (void)GC_printf1("Allocated %lu collectable objects\n", (unsigned long)collectable_count);
+ (void)GC_printf1("Allocated %lu uncollectable objects\n", (unsigned long)uncollectable_count);
+ (void)GC_printf1("Allocated %lu atomic objects\n", (unsigned long)atomic_count);
+ (void)GC_printf1("Allocated %lu stubborn objects\n", (unsigned long)stubborn_count);
(void)GC_printf2("Finalized %lu/%lu objects - ",
(unsigned long)finalized_count,
(unsigned long)finalizable_count);
@@ -1093,8 +1210,8 @@ void check_heap_stats()
i = finalizable_count - finalized_count - still_live;
if (0 != i) {
(void)GC_printf2
- ("%lu disappearing links remain and %lu more objects were not finalized\n",
- (unsigned long) still_live, (unsigned long)i);
+ ("%lu disappearing links remain and %ld more objects were not finalized\n",
+ (unsigned long) still_live, (long)i);
if (i > 10) {
GC_printf0("\tVery suspicious!\n");
} else {
@@ -1107,7 +1224,11 @@ void check_heap_stats()
(void)GC_printf1("Final heap size is %lu bytes\n",
(unsigned long)GC_get_heap_size());
if (WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc)
+# ifdef VERY_SMALL_CONFIG
+ < 2700000*n_tests) {
+# else
< 33500000*n_tests) {
+# endif
(void)GC_printf0("Incorrect execution - missed some allocations\n");
FAIL;
}
@@ -1145,15 +1266,16 @@ void SetMinimumStack(long minSize)
#endif
{
GC_printf1(msg, (unsigned long)p);
- FAIL;
+ /*FAIL;*/
}
-#if !defined(PCR) && !defined(SOLARIS_THREADS) && !defined(WIN32_THREADS) \
- && !defined(IRIX_THREADS) && !defined(LINUX_THREADS) \
- && !defined(HPUX_THREADS) || defined(LINT)
+#if !defined(PCR) && !defined(GC_SOLARIS_THREADS) \
+ && !defined(GC_WIN32_THREADS) \
+ && !defined(GC_IRIX_THREADS) && !defined(GC_LINUX_THREADS) \
+ && !defined(GC_HPUX_THREADS) || defined(LINT)
#if defined(MSWIN32) && !defined(__MINGW32__)
- int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
+ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n)
#else
int main()
#endif
@@ -1187,7 +1309,9 @@ void SetMinimumStack(long minSize)
# endif
run_one_test();
check_heap_stats();
+# ifndef MSWINE
(void)fflush(stdout);
+# endif
# ifdef LINT
/* Entry points we should be testing, but aren't. */
/* Some can be tested by defining GC_DEBUG at the top of this file */
@@ -1212,7 +1336,7 @@ void SetMinimumStack(long minSize)
}
# endif
-#ifdef WIN32_THREADS
+#ifdef GC_WIN32_THREADS
unsigned __stdcall thr_run_one_test(void *arg)
{
@@ -1220,24 +1344,119 @@ unsigned __stdcall thr_run_one_test(void *arg)
return 0;
}
-#define NTEST 2
+#ifdef MSWINCE
+HANDLE win_created_h;
+HWND win_handle;
+
+LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret = 0;
+ switch (uMsg) {
+ case WM_HIBERNATE:
+ GC_printf0("Received WM_HIBERNATE, calling GC_gcollect\n");
+ GC_gcollect();
+ break;
+ case WM_CLOSE:
+ GC_printf0("Received WM_CLOSE, closing window\n");
+ DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ ret = DefWindowProc(hwnd, uMsg, wParam, lParam);
+ break;
+ }
+ return ret;
+}
+
+unsigned __stdcall thr_window(void *arg)
+{
+ WNDCLASS win_class = {
+ CS_NOCLOSE,
+ window_proc,
+ 0,
+ 0,
+ GetModuleHandle(NULL),
+ NULL,
+ NULL,
+ (HBRUSH)(COLOR_APPWORKSPACE+1),
+ NULL,
+ L"GCtestWindow"
+ };
+ MSG msg;
+
+ if (!RegisterClass(&win_class))
+ FAIL;
+
+ win_handle = CreateWindowEx(
+ 0,
+ L"GCtestWindow",
+ L"GCtest",
+ 0,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL);
+
+ if (win_handle == NULL)
+ FAIL;
+
+ SetEvent(win_created_h);
+
+ ShowWindow(win_handle, SW_SHOW);
+ UpdateWindow(win_handle);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+#endif
+
+#define NTEST 2
+# ifdef MSWINCE
+int APIENTRY GC_WinMain(HINSTANCE instance, HINSTANCE prev, LPWSTR cmd, int n)
+# else
int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
+# endif
{
# if NTEST > 0
HANDLE h[NTEST];
+ int i;
+# endif
+# ifdef MSWINCE
+ HANDLE win_thr_h;
# endif
- int i;
unsigned thread_id;
# if 0
GC_enable_incremental();
# endif
InitializeCriticalSection(&incr_cs);
(void) GC_set_warn_proc(warn_proc);
+# ifdef MSWINCE
+ win_created_h = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (win_created_h == (HANDLE)NULL) {
+ (void)GC_printf1("Event creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ win_thr_h = GC_CreateThread(NULL, 0, thr_window, 0, 0, &thread_id);
+ if (win_thr_h == (HANDLE)NULL) {
+ (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ if (WaitForSingleObject(win_created_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+ CloseHandle(win_created_h);
+# endif
# if NTEST > 0
for (i = 0; i < NTEST; i++) {
- h[i] = (HANDLE)_beginthreadex(NULL, 0, thr_run_one_test, 0, 0, &thread_id);
- if (h[i] == (HANDLE)-1) {
+ h[i] = GC_CreateThread(NULL, 0, thr_run_one_test, 0, 0, &thread_id);
+ if (h[i] == (HANDLE)NULL) {
(void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
FAIL;
}
@@ -1252,12 +1471,16 @@ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
}
}
# endif /* NTEST > 0 */
+# ifdef MSWINCE
+ PostMessage(win_handle, WM_CLOSE, 0, 0);
+ if (WaitForSingleObject(win_thr_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+# endif
check_heap_stats();
- (void)fflush(stdout);
return(0);
}
-#endif /* WIN32_THREADS */
+#endif /* GC_WIN32_THREADS */
#ifdef PCR
@@ -1282,13 +1505,12 @@ test()
(void)GC_printf0("Thread 2 failed\n");
}
check_heap_stats();
- (void)fflush(stdout);
return(0);
}
#endif
-#if defined(SOLARIS_THREADS) || defined(IRIX_THREADS) \
- || defined(HPUX_THREADS) || defined(LINUX_THREADS)
+#if defined(GC_SOLARIS_THREADS) || defined(GC_IRIX_THREADS) \
+ || defined(GC_HPUX_THREADS) || defined(GC_LINUX_THREADS)
void * thr_run_one_test(void * arg)
{
run_one_test();
@@ -1299,7 +1521,7 @@ void * thr_run_one_test(void * arg)
# define GC_free GC_debug_free
#endif
-#ifdef SOLARIS_THREADS
+#ifdef GC_SOLARIS_THREADS
main()
{
thread_t th1;
@@ -1343,17 +1565,17 @@ main()
pthread_attr_t attr;
int code;
-# ifdef IRIX_THREADS
+# ifdef GC_IRIX_THREADS
/* Force a larger stack to be preallocated */
/* Since the initial cant always grow later. */
*((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */
-# endif /* IRIX_THREADS */
+# endif /* GC_IRIX_THREADS */
pthread_attr_init(&attr);
-# if defined(IRIX_THREADS) || defined(HPUX_THREADS)
+# if defined(GC_IRIX_THREADS) || defined(GC_HPUX_THREADS)
pthread_attr_setstacksize(&attr, 1000000);
# endif
n_tests = 0;
-# ifdef MPROTECT_VDB
+# if defined(MPROTECT_VDB) && !defined(PARALLEL_MARK)
GC_enable_incremental();
(void) GC_printf0("Switched to incremental mode\n");
(void) GC_printf0("Emulating dirty bits with mprotect/signals\n");
diff --git a/test_cpp.cc b/test_cpp.cc
index 0d450776..a01dd566 100644
--- a/test_cpp.cc
+++ b/test_cpp.cc
@@ -28,11 +28,13 @@ few minutes to complete.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef __GNUC__
-# include "gc_alloc.h"
+#ifdef __GNUC__
+# include "include/new_gc_alloc.h"
+#else
+# include "include/gc_alloc.h"
#endif
extern "C" {
-#include "gc_priv.h"
+#include "private/gc_priv.h"
}
#ifdef MSWIN32
# include <windows.h>
@@ -193,8 +195,12 @@ int APIENTRY WinMain(
argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
# endif
int i, iters, n;
-# if !defined(__GNUC__) && !defined(MACOS)
- int *x = (int *)alloc::allocate(sizeof(int));
+# if !defined(MACOS)
+# ifdef __GNUC__
+ int *x = (int *)gc_alloc::allocate(sizeof(int));
+# else
+ int *x = (int *)alloc::allocate(sizeof(int));
+# endif
*x = 29;
x -= 3;
diff --git a/threadlibs.c b/threadlibs.c
index 7379454c..2af2b0c5 100644
--- a/threadlibs.c
+++ b/threadlibs.c
@@ -1,16 +1,15 @@
-# include "gcconfig.h"
+# include "private/gcconfig.h"
# include <stdio.h>
int main()
{
-# if defined(LINUX_THREADS)
-# ifdef USE_LD_WRAP
+# if defined(GC_USE_LD_WRAP)
printf("-Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen "
"-Wl,--wrap -Wl,pthread_create -Wl,--wrap -Wl,pthread_join "
- "-Wl,--wrap -Wl,pthread_sigmask -lpthread -ldl\n");
-# else
- printf("-lpthread -ldl\n");
-# endif
+ "-Wl,--wrap -Wl,pthread_sigmask\n");
+# endif
+# if defined(LINUX_THREADS)
+ printf("-lpthread -ldl\n");
# endif
# if defined(IRIX_THREADS)
printf("-lpthread\n");
diff --git a/typd_mlc.c b/typd_mlc.c
index a198f6c1..4c5969f3 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
+ * opyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved.
*
* THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
* OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
@@ -11,7 +12,6 @@
* modified is included with the above copyright notice.
*
*/
-/* Boehm, July 31, 1995 5:02 pm PDT */
/*
@@ -36,8 +36,8 @@
* since they are not accessible through the current interface.
*/
-#include "gc_priv.h"
-#include "gc_mark.h"
+#include "private/gc_priv.h"
+#include "private/gc_mark.h"
#include "gc_typed.h"
# ifdef ADD_BYTE_AT_END
@@ -343,9 +343,15 @@ ptr_t * GC_eobjfreelist;
ptr_t * GC_arobjfreelist;
-mse * GC_typed_mark_proc();
+mse * GC_typed_mark_proc GC_PROTO((register word * addr,
+ register mse * mark_stack_ptr,
+ mse * mark_stack_limit,
+ word env));
-mse * GC_array_mark_proc();
+mse * GC_array_mark_proc GC_PROTO((register word * addr,
+ register mse * mark_stack_ptr,
+ mse * mark_stack_limit,
+ word env));
GC_descr GC_generic_array_descr;
@@ -370,7 +376,7 @@ void GC_init_explicit_typing()
GC_explicit_typing_initialized = TRUE;
/* Set up object kind with simple indirect descriptor. */
GC_eobjfreelist = (ptr_t *)
- GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
+ GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
if (GC_eobjfreelist == 0) ABORT("Couldn't allocate GC_eobjfreelist");
BZERO(GC_eobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
GC_explicit_kind = GC_n_kinds++;
@@ -387,7 +393,7 @@ void GC_init_explicit_typing()
/* Moving this up breaks DEC AXP compiler. */
/* Set up object kind with array descriptor. */
GC_arobjfreelist = (ptr_t *)
- GC_generic_malloc_inner((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
+ GC_INTERNAL_MALLOC((MAXOBJSZ+1)*sizeof(ptr_t), PTRFREE);
if (GC_arobjfreelist == 0) ABORT("Couldn't allocate GC_arobjfreelist");
BZERO(GC_arobjfreelist, (MAXOBJSZ+1)*sizeof(ptr_t));
if (GC_n_mark_procs >= MAX_MARK_PROCS)
@@ -414,11 +420,18 @@ void GC_init_explicit_typing()
ENABLE_SIGNALS();
}
-mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
-register word * addr;
-register mse * mark_stack_ptr;
-mse * mark_stack_limit;
-word env;
+# if defined(__STDC__) || defined(__cplusplus)
+ mse * GC_typed_mark_proc(register word * addr,
+ register mse * mark_stack_ptr,
+ mse * mark_stack_limit,
+ word env)
+# else
+ mse * GC_typed_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
+ register word * addr;
+ register mse * mark_stack_ptr;
+ mse * mark_stack_limit;
+ word env;
+# endif
{
register word bm = GC_ext_descriptors[env].ed_bitmap;
register word * current_p = addr;
@@ -533,11 +546,18 @@ mse * msl;
}
/*ARGSUSED*/
-mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
-register word * addr;
-register mse * mark_stack_ptr;
-mse * mark_stack_limit;
-word env;
+# if defined(__STDC__) || defined(__cplusplus)
+ mse * GC_array_mark_proc(register word * addr,
+ register mse * mark_stack_ptr,
+ mse * mark_stack_limit,
+ word env)
+# else
+ mse * GC_array_mark_proc(addr, mark_stack_ptr, mark_stack_limit, env)
+ register word * addr;
+ register mse * mark_stack_ptr;
+ mse * mark_stack_limit;
+ word env;
+# endif
{
register hdr * hhdr = HDR(addr);
register word sz = hhdr -> hb_sz;
diff --git a/version.h b/version.h
index 5319f56d..c60b07fc 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
-#define GC_VERSION_MAJOR 5
-#define GC_VERSION_MINOR 3
-#define GC_ALPHA_VERSION GC_NOT_ALPHA
+#define GC_VERSION_MAJOR 6
+#define GC_VERSION_MINOR 0
+#define GC_ALPHA_VERSION 3
# define GC_NOT_ALPHA 0xff
diff --git a/weakpointer.h b/weakpointer.h
deleted file mode 100644
index 84906b00..00000000
--- a/weakpointer.h
+++ /dev/null
@@ -1,221 +0,0 @@
-#ifndef _weakpointer_h_
-#define _weakpointer_h_
-
-/****************************************************************************
-
-WeakPointer and CleanUp
-
- Copyright (c) 1991 by Xerox Corporation. All rights reserved.
-
- THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
-
- Permission is hereby granted to copy this code for any purpose,
- provided the above notices are retained on all copies.
-
- Last modified on Mon Jul 17 18:16:01 PDT 1995 by ellis
-
-****************************************************************************/
-
-/****************************************************************************
-
-WeakPointer
-
-A weak pointer is a pointer to a heap-allocated object that doesn't
-prevent the object from being garbage collected. Weak pointers can be
-used to track which objects haven't yet been reclaimed by the
-collector. A weak pointer is deactivated when the collector discovers
-its referent object is unreachable by normal pointers (reachability
-and deactivation are defined more precisely below). A deactivated weak
-pointer remains deactivated forever.
-
-****************************************************************************/
-
-
-template< class T > class WeakPointer {
-public:
-
-WeakPointer( T* t = 0 )
- /* Constructs a weak pointer for *t. t may be null. It is an error
- if t is non-null and *t is not a collected object. */
- {impl = _WeakPointer_New( t );}
-
-T* Pointer()
- /* wp.Pointer() returns a pointer to the referent object of wp or
- null if wp has been deactivated (because its referent object
- has been discovered unreachable by the collector). */
- {return (T*) _WeakPointer_Pointer( this->impl );}
-
-int operator==( WeakPointer< T > wp2 )
- /* Given weak pointers wp1 and wp2, if wp1 == wp2, then wp1 and
- wp2 refer to the same object. If wp1 != wp2, then either wp1
- and wp2 don't refer to the same object, or if they do, one or
- both of them has been deactivated. (Note: If objects t1 and t2
- are never made reachable by their clean-up functions, then
- WeakPointer<T>(t1) == WeakPointer<T>(t2) if and only t1 == t2.) */
- {return _WeakPointer_Equal( this->impl, wp2.impl );}
-
-int Hash()
- /* Returns a hash code suitable for use by multiplicative- and
- division-based hash tables. If wp1 == wp2, then wp1.Hash() ==
- wp2.Hash(). */
- {return _WeakPointer_Hash( this->impl );}
-
-private:
-void* impl;
-};
-
-/*****************************************************************************
-
-CleanUp
-
-A garbage-collected object can have an associated clean-up function
-that will be invoked some time after the collector discovers the
-object is unreachable via normal pointers. Clean-up functions can be
-used to release resources such as open-file handles or window handles
-when their containing objects become unreachable. If a C++ object has
-a non-empty explicit destructor (i.e. it contains programmer-written
-code), the destructor will be automatically registered as the object's
-initial clean-up function.
-
-There is no guarantee that the collector will detect every unreachable
-object (though it will find almost all of them). Clients should not
-rely on clean-up to cause some action to occur immediately -- clean-up
-is only a mechanism for improving resource usage.
-
-Every object with a clean-up function also has a clean-up queue. When
-the collector finds the object is unreachable, it enqueues it on its
-queue. The clean-up function is applied when the object is removed
-from the queue. By default, objects are enqueued on the garbage
-collector's queue, and the collector removes all objects from its
-queue after each collection. If a client supplies another queue for
-objects, it is his responsibility to remove objects (and cause their
-functions to be called) by polling it periodically.
-
-Clean-up queues allow clean-up functions accessing global data to
-synchronize with the main program. Garbage collection can occur at any
-time, and clean-ups invoked by the collector might access data in an
-inconsistent state. A client can control this by defining an explicit
-queue for objects and polling it at safe points.
-
-The following definitions are used by the specification below:
-
-Given a pointer t to a collected object, the base object BO(t) is the
-value returned by new when it created the object. (Because of multiple
-inheritance, t and BO(t) may not be the same address.)
-
-A weak pointer wp references an object *t if BO(wp.Pointer()) ==
-BO(t).
-
-***************************************************************************/
-
-template< class T, class Data > class CleanUp {
-public:
-
-static void Set( T* t, void c( Data* d, T* t ), Data* d = 0 )
- /* Sets the clean-up function of object BO(t) to be <c, d>,
- replacing any previously defined clean-up function for BO(t); c
- and d can be null, but t cannot. Sets the clean-up queue for
- BO(t) to be the collector's queue. When t is removed from its
- clean-up queue, its clean-up will be applied by calling c(d,
- t). It is an error if *t is not a collected object. */
- {_CleanUp_Set( t, c, d );}
-
-static void Call( T* t )
- /* Sets the new clean-up function for BO(t) to be null and, if the
- old one is non-null, calls it immediately, even if BO(t) is
- still reachable. Deactivates any weak pointers to BO(t). */
- {_CleanUp_Call( t );}
-
-class Queue {public:
- Queue()
- /* Constructs a new queue. */
- {this->head = _CleanUp_Queue_NewHead();}
-
- void Set( T* t )
- /* q.Set(t) sets the clean-up queue of BO(t) to be q. */
- {_CleanUp_Queue_Set( this->head, t );}
-
- int Call()
- /* If q is non-empty, q.Call() removes the first object and
- calls its clean-up function; does nothing if q is
- empty. Returns true if there are more objects in the
- queue. */
- {return _CleanUp_Queue_Call( this->head );}
-
- private:
- void* head;
- };
-};
-
-/**********************************************************************
-
-Reachability and Clean-up
-
-An object O is reachable if it can be reached via a non-empty path of
-normal pointers from the registers, stacks, global variables, or an
-object with a non-null clean-up function (including O itself),
-ignoring pointers from an object to itself.
-
-This definition of reachability ensures that if object B is accessible
-from object A (and not vice versa) and if both A and B have clean-up
-functions, then A will always be cleaned up before B. Note that as
-long as an object with a clean-up function is contained in a cycle of
-pointers, it will always be reachable and will never be cleaned up or
-collected.
-
-When the collector finds an unreachable object with a null clean-up
-function, it atomically deactivates all weak pointers referencing the
-object and recycles its storage. If object B is accessible from object
-A via a path of normal pointers, A will be discovered unreachable no
-later than B, and a weak pointer to A will be deactivated no later
-than a weak pointer to B.
-
-When the collector finds an unreachable object with a non-null
-clean-up function, the collector atomically deactivates all weak
-pointers referencing the object, redefines its clean-up function to be
-null, and enqueues it on its clean-up queue. The object then becomes
-reachable again and remains reachable at least until its clean-up
-function executes.
-
-The clean-up function is assured that its argument is the only
-accessible pointer to the object. Nothing prevents the function from
-redefining the object's clean-up function or making the object
-reachable again (for example, by storing the pointer in a global
-variable).
-
-If the clean-up function does not make its object reachable again and
-does not redefine its clean-up function, then the object will be
-collected by a subsequent collection (because the object remains
-unreachable and now has a null clean-up function). If the clean-up
-function does make its object reachable again and a clean-up function
-is subsequently redefined for the object, then the new clean-up
-function will be invoked the next time the collector finds the object
-unreachable.
-
-Note that a destructor for a collected object cannot safely redefine a
-clean-up function for its object, since after the destructor executes,
-the object has been destroyed into "raw memory". (In most
-implementations, destroying an object mutates its vtbl.)
-
-Finally, note that calling delete t on a collected object first
-deactivates any weak pointers to t and then invokes its clean-up
-function (destructor).
-
-**********************************************************************/
-
-extern "C" {
- void* _WeakPointer_New( void* t );
- void* _WeakPointer_Pointer( void* wp );
- int _WeakPointer_Equal( void* wp1, void* wp2 );
- int _WeakPointer_Hash( void* wp );
- void _CleanUp_Set( void* t, void (*c)( void* d, void* t ), void* d );
- void _CleanUp_Call( void* t );
- void* _CleanUp_Queue_NewHead ();
- void _CleanUp_Queue_Set( void* h, void* t );
- int _CleanUp_Queue_Call( void* h );
-}
-
-#endif /* _weakpointer_h_ */
-
-
diff --git a/win32_threads.c b/win32_threads.c
index 7c8de4d2..4f2569f0 100755
--- a/win32_threads.c
+++ b/win32_threads.c
@@ -1,6 +1,6 @@
-#ifdef WIN32_THREADS
+#if defined(GC_WIN32_THREADS) || defined(WIN32_THREADS)
-#include "gc_priv.h"
+#include "private/gc_priv.h"
#if 0
#define STRICT
@@ -33,22 +33,28 @@ void GC_stop_world()
for (i = 0; i < MAX_THREADS; i++)
if (thread_table[i].stack != 0
&& thread_table[i].id != thread_id) {
- /* Apparently the Windows 95 GetOpenFileName call creates */
- /* a thread that does not properly get cleaned up, and */
- /* SuspendThread on its descriptor may provoke a crash. */
- /* This reduces the probability of that event, though it still */
- /* appears there's a race here. */
- DWORD exitCode;
- if (GetExitCodeThread(thread_table[i].handle,&exitCode) &&
+# ifdef MSWINCE
+ /* SuspendThread will fail if thread is running kernel code */
+ while (SuspendThread(thread_table[i].handle) == (DWORD)-1)
+ Sleep(10);
+# else
+ /* Apparently the Windows 95 GetOpenFileName call creates */
+ /* a thread that does not properly get cleaned up, and */
+ /* SuspendThread on its descriptor may provoke a crash. */
+ /* This reduces the probability of that event, though it still */
+ /* appears there's a race here. */
+ DWORD exitCode;
+ if (GetExitCodeThread(thread_table[i].handle,&exitCode) &&
exitCode != STILL_ACTIVE) {
thread_table[i].stack = 0;
- thread_table[i].in_use = FALSE;
- CloseHandle(thread_table[i].handle);
- BZERO(&thread_table[i].context, sizeof(CONTEXT));
- continue;
- }
- if (SuspendThread(thread_table[i].handle) == (DWORD)-1)
- ABORT("SuspendThread failed");
+ thread_table[i].in_use = FALSE;
+ CloseHandle(thread_table[i].handle);
+ BZERO(&thread_table[i].context, sizeof(CONTEXT));
+ continue;
+ }
+ if (SuspendThread(thread_table[i].handle) == (DWORD)-1)
+ ABORT("SuspendThread failed");
+# endif
thread_table[i].suspended = TRUE;
}
}
@@ -67,6 +73,9 @@ void GC_start_world()
GC_please_stop = FALSE;
}
+# ifdef _MSC_VER
+# pragma warning(disable:4715)
+# endif
ptr_t GC_current_stackbottom()
{
DWORD thread_id = GetCurrentThreadId();
@@ -76,18 +85,30 @@ ptr_t GC_current_stackbottom()
return thread_table[i].stack;
ABORT("no thread table entry for current thread");
}
+# ifdef _MSC_VER
+# pragma warning(default:4715)
+# endif
-static ptr_t GC_get_lo_stack_addr(ptr_t s)
-{
- ptr_t bottom;
- MEMORY_BASIC_INFORMATION info;
- VirtualQuery(s, &info, sizeof(info));
- do {
- bottom = info.BaseAddress;
- VirtualQuery(bottom - 1, &info, sizeof(info));
- } while ((info.Protect & PAGE_READWRITE) && !(info.Protect & PAGE_GUARD));
- return(bottom);
-}
+# ifdef MSWINCE
+ /* The VirtualQuery calls below won't work properly on WinCE, but */
+ /* since each stack is restricted to an aligned 64K region of */
+ /* virtual memory we can just take the next lowest multiple of 64K. */
+# define GC_get_lo_stack_addr(s) \
+ ((ptr_t)(((DWORD)(s) - 1) & 0xFFFF0000))
+# else
+ static ptr_t GC_get_lo_stack_addr(ptr_t s)
+ {
+ ptr_t bottom;
+ MEMORY_BASIC_INFORMATION info;
+ VirtualQuery(s, &info, sizeof(info));
+ do {
+ bottom = info.BaseAddress;
+ VirtualQuery(bottom - 1, &info, sizeof(info));
+ } while ((info.Protect & PAGE_READWRITE)
+ && !(info.Protect & PAGE_GUARD));
+ return(bottom);
+ }
+# endif
void GC_push_all_stacks()
{
@@ -97,23 +118,186 @@ void GC_push_all_stacks()
if (thread_table[i].stack) {
ptr_t bottom = GC_get_lo_stack_addr(thread_table[i].stack);
if (thread_table[i].id == thread_id)
- GC_push_all_stack(&i, thread_table[i].stack);
+ GC_push_all_stack((ptr_t)&i, thread_table[i].stack);
else {
thread_table[i].context.ContextFlags
= (CONTEXT_INTEGER|CONTEXT_CONTROL);
if (!GetThreadContext(thread_table[i].handle,
- &thread_table[i].context))
+ /* cast away volatile qualifier */
+ (LPCONTEXT)&thread_table[i].context))
ABORT("GetThreadContext failed");
- if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
- || thread_table[i].context.Esp < (DWORD)bottom)
- ABORT("Thread stack pointer out of range");
- GC_push_one ((word) thread_table[i].context.Edi);
- GC_push_one ((word) thread_table[i].context.Esi);
- GC_push_one ((word) thread_table[i].context.Ebx);
- GC_push_one ((word) thread_table[i].context.Edx);
- GC_push_one ((word) thread_table[i].context.Ecx);
- GC_push_one ((word) thread_table[i].context.Eax);
- GC_push_all_stack(thread_table[i].context.Esp, thread_table[i].stack);
+# ifdef I386
+ if (thread_table[i].context.Esp >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.Esp < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.Edi);
+ GC_push_one ((word) thread_table[i].context.Esi);
+ GC_push_one ((word) thread_table[i].context.Ebp);
+ GC_push_one ((word) thread_table[i].context.Ebx);
+ GC_push_one ((word) thread_table[i].context.Edx);
+ GC_push_one ((word) thread_table[i].context.Ecx);
+ GC_push_one ((word) thread_table[i].context.Eax);
+ GC_push_all_stack((char *) thread_table[i].context.Esp,
+ thread_table[i].stack);
+# else
+# ifdef ARM32
+ if (thread_table[i].context.Sp >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.Sp < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.R0);
+ GC_push_one ((word) thread_table[i].context.R1);
+ GC_push_one ((word) thread_table[i].context.R2);
+ GC_push_one ((word) thread_table[i].context.R3);
+ GC_push_one ((word) thread_table[i].context.R4);
+ GC_push_one ((word) thread_table[i].context.R5);
+ GC_push_one ((word) thread_table[i].context.R6);
+ GC_push_one ((word) thread_table[i].context.R7);
+ GC_push_one ((word) thread_table[i].context.R8);
+ GC_push_one ((word) thread_table[i].context.R9);
+ GC_push_one ((word) thread_table[i].context.R10);
+ GC_push_one ((word) thread_table[i].context.R11);
+ GC_push_one ((word) thread_table[i].context.R12);
+ GC_push_all_stack((char *) thread_table[i].context.Sp,
+ thread_table[i].stack);
+# else
+# ifdef SHx
+ if (thread_table[i].context.R15 >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.R15 < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.R0);
+ GC_push_one ((word) thread_table[i].context.R1);
+ GC_push_one ((word) thread_table[i].context.R2);
+ GC_push_one ((word) thread_table[i].context.R3);
+ GC_push_one ((word) thread_table[i].context.R4);
+ GC_push_one ((word) thread_table[i].context.R5);
+ GC_push_one ((word) thread_table[i].context.R6);
+ GC_push_one ((word) thread_table[i].context.R7);
+ GC_push_one ((word) thread_table[i].context.R8);
+ GC_push_one ((word) thread_table[i].context.R9);
+ GC_push_one ((word) thread_table[i].context.R10);
+ GC_push_one ((word) thread_table[i].context.R11);
+ GC_push_one ((word) thread_table[i].context.R12);
+ GC_push_one ((word) thread_table[i].context.R13);
+ GC_push_one ((word) thread_table[i].context.R14);
+ GC_push_all_stack((char *) thread_table[i].context.R15,
+ thread_table[i].stack);
+# else
+# ifdef MIPS
+ if (thread_table[i].context.IntSp >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.IntSp < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.IntAt);
+ GC_push_one ((word) thread_table[i].context.IntV0);
+ GC_push_one ((word) thread_table[i].context.IntV1);
+ GC_push_one ((word) thread_table[i].context.IntA0);
+ GC_push_one ((word) thread_table[i].context.IntA1);
+ GC_push_one ((word) thread_table[i].context.IntA2);
+ GC_push_one ((word) thread_table[i].context.IntA3);
+ GC_push_one ((word) thread_table[i].context.IntT0);
+ GC_push_one ((word) thread_table[i].context.IntT1);
+ GC_push_one ((word) thread_table[i].context.IntT2);
+ GC_push_one ((word) thread_table[i].context.IntT3);
+ GC_push_one ((word) thread_table[i].context.IntT4);
+ GC_push_one ((word) thread_table[i].context.IntT5);
+ GC_push_one ((word) thread_table[i].context.IntT6);
+ GC_push_one ((word) thread_table[i].context.IntT7);
+ GC_push_one ((word) thread_table[i].context.IntS0);
+ GC_push_one ((word) thread_table[i].context.IntS1);
+ GC_push_one ((word) thread_table[i].context.IntS2);
+ GC_push_one ((word) thread_table[i].context.IntS3);
+ GC_push_one ((word) thread_table[i].context.IntS4);
+ GC_push_one ((word) thread_table[i].context.IntS5);
+ GC_push_one ((word) thread_table[i].context.IntS6);
+ GC_push_one ((word) thread_table[i].context.IntS7);
+ GC_push_one ((word) thread_table[i].context.IntT8);
+ GC_push_one ((word) thread_table[i].context.IntT9);
+ GC_push_one ((word) thread_table[i].context.IntK0);
+ GC_push_one ((word) thread_table[i].context.IntK1);
+ GC_push_one ((word) thread_table[i].context.IntS8);
+ GC_push_all_stack((char *) thread_table[i].context.IntSp,
+ thread_table[i].stack);
+# else
+# ifdef PPC
+ if (thread_table[i].context.Gpr1 >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.Gpr1 < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.Gpr0);
+ /* Gpr1 is stack pointer */
+ /* Gpr2 is global pointer */
+ GC_push_one ((word) thread_table[i].context.Gpr3);
+ GC_push_one ((word) thread_table[i].context.Gpr4);
+ GC_push_one ((word) thread_table[i].context.Gpr5);
+ GC_push_one ((word) thread_table[i].context.Gpr6);
+ GC_push_one ((word) thread_table[i].context.Gpr7);
+ GC_push_one ((word) thread_table[i].context.Gpr8);
+ GC_push_one ((word) thread_table[i].context.Gpr9);
+ GC_push_one ((word) thread_table[i].context.Gpr10);
+ GC_push_one ((word) thread_table[i].context.Gpr11);
+ GC_push_one ((word) thread_table[i].context.Gpr12);
+ /* Gpr13 is reserved for the kernel */
+ GC_push_one ((word) thread_table[i].context.Gpr14);
+ GC_push_one ((word) thread_table[i].context.Gpr15);
+ GC_push_one ((word) thread_table[i].context.Gpr16);
+ GC_push_one ((word) thread_table[i].context.Gpr17);
+ GC_push_one ((word) thread_table[i].context.Gpr18);
+ GC_push_one ((word) thread_table[i].context.Gpr19);
+ GC_push_one ((word) thread_table[i].context.Gpr20);
+ GC_push_one ((word) thread_table[i].context.Gpr21);
+ GC_push_one ((word) thread_table[i].context.Gpr22);
+ GC_push_one ((word) thread_table[i].context.Gpr23);
+ GC_push_one ((word) thread_table[i].context.Gpr24);
+ GC_push_one ((word) thread_table[i].context.Gpr25);
+ GC_push_one ((word) thread_table[i].context.Gpr26);
+ GC_push_one ((word) thread_table[i].context.Gpr27);
+ GC_push_one ((word) thread_table[i].context.Gpr28);
+ GC_push_one ((word) thread_table[i].context.Gpr29);
+ GC_push_one ((word) thread_table[i].context.Gpr30);
+ GC_push_one ((word) thread_table[i].context.Gpr31);
+ GC_push_all_stack((char *) thread_table[i].context.Gpr1,
+ thread_table[i].stack);
+# else
+# ifdef ALPHA
+ if (thread_table[i].context.IntSp >= (DWORD)thread_table[i].stack
+ || thread_table[i].context.IntSp < (DWORD)bottom)
+ ABORT("Thread stack pointer out of range");
+ GC_push_one ((word) thread_table[i].context.IntV0);
+ GC_push_one ((word) thread_table[i].context.IntT0);
+ GC_push_one ((word) thread_table[i].context.IntT1);
+ GC_push_one ((word) thread_table[i].context.IntT2);
+ GC_push_one ((word) thread_table[i].context.IntT3);
+ GC_push_one ((word) thread_table[i].context.IntT4);
+ GC_push_one ((word) thread_table[i].context.IntT5);
+ GC_push_one ((word) thread_table[i].context.IntT6);
+ GC_push_one ((word) thread_table[i].context.IntT7);
+ GC_push_one ((word) thread_table[i].context.IntS0);
+ GC_push_one ((word) thread_table[i].context.IntS1);
+ GC_push_one ((word) thread_table[i].context.IntS2);
+ GC_push_one ((word) thread_table[i].context.IntS3);
+ GC_push_one ((word) thread_table[i].context.IntS4);
+ GC_push_one ((word) thread_table[i].context.IntS5);
+ GC_push_one ((word) thread_table[i].context.IntFp);
+ GC_push_one ((word) thread_table[i].context.IntA0);
+ GC_push_one ((word) thread_table[i].context.IntA1);
+ GC_push_one ((word) thread_table[i].context.IntA2);
+ GC_push_one ((word) thread_table[i].context.IntA3);
+ GC_push_one ((word) thread_table[i].context.IntA4);
+ GC_push_one ((word) thread_table[i].context.IntA5);
+ GC_push_one ((word) thread_table[i].context.IntT8);
+ GC_push_one ((word) thread_table[i].context.IntT9);
+ GC_push_one ((word) thread_table[i].context.IntT10);
+ GC_push_one ((word) thread_table[i].context.IntT11);
+ GC_push_one ((word) thread_table[i].context.IntT12);
+ GC_push_one ((word) thread_table[i].context.IntAt);
+ GC_push_all_stack((char *) thread_table[i].context.IntSp,
+ thread_table[i].stack);
+# else
+ --> architecture not supported
+# endif /* !ALPHA */
+# endif /* !PPC */
+# endif /* !MIPS */
+# endif /* !SHx */
+# endif /* !ARM32 */
+# endif /* !I386 */
}
}
}
@@ -140,6 +324,177 @@ void GC_get_next_stack(char *start, char **lo, char **hi)
if (*lo < start) *lo = start;
}
+
+# ifdef MSWINCE
+
+typedef struct {
+ HANDLE child_ready_h, parent_ready_h;
+ volatile struct thread_entry * entry;
+ LPTHREAD_START_ROUTINE start;
+ LPVOID param;
+} thread_args;
+
+DWORD WINAPI thread_start(LPVOID arg);
+
+HANDLE WINAPI GC_CreateThread(
+ LPSECURITY_ATTRIBUTES lpThreadAttributes,
+ DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
+ LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId )
+{
+ HANDLE thread_h = NULL;
+ HANDLE child_ready_h, parent_ready_h;
+
+ int i;
+ thread_args args;
+
+ /* allocate thread slot */
+ LOCK();
+ for (i = 0; i != MAX_THREADS && thread_table[i].in_use; i++)
+ ;
+ if (i != MAX_THREADS) {
+ thread_table[i].in_use = TRUE;
+ }
+ UNLOCK();
+
+ if (i != MAX_THREADS) {
+
+ /* create unnamed unsignalled events */
+ if (child_ready_h = CreateEvent(NULL, FALSE, FALSE, NULL)) {
+ if (parent_ready_h = CreateEvent(NULL, FALSE, FALSE, NULL)) {
+
+ /* set up thread arguments */
+ args.child_ready_h = child_ready_h;
+ args.parent_ready_h = parent_ready_h;
+ args.entry = &thread_table[i];
+ args.start = lpStartAddress;
+ args.param = lpParameter;
+
+ thread_h = CreateThread(lpThreadAttributes,
+ dwStackSize, thread_start,
+ &args,
+ dwCreationFlags & ~CREATE_SUSPENDED,
+ lpThreadId);
+
+ if (thread_h) {
+
+ /* fill in ID and handle; tell child this is done */
+ thread_table[i].id = *lpThreadId;
+ thread_table[i].handle = thread_h;
+ SetEvent (parent_ready_h);
+
+ /* wait for child to fill in stack and copy args */
+ WaitForSingleObject (child_ready_h, INFINITE);
+
+ /* suspend the child if requested */
+ if (dwCreationFlags & CREATE_SUSPENDED)
+ SuspendThread (thread_h);
+
+ /* let child call given function now (or when resumed) */
+ SetEvent (parent_ready_h);
+
+ } else {
+ CloseHandle (parent_ready_h);
+ }
+ }
+ }
+
+ CloseHandle (child_ready_h);
+
+ if (thread_h == NULL)
+ thread_table[i].in_use = FALSE;
+
+ } else { /* no thread slot found */
+ SetLastError (ERROR_TOO_MANY_TCBS);
+ }
+
+ return thread_h;
+}
+
+static DWORD WINAPI thread_start(LPVOID arg)
+{
+ DWORD ret = 0;
+ thread_args args = *(thread_args *)arg;
+
+ /* wait for parent to fill in ID and handle */
+ WaitForSingleObject (args.parent_ready_h, INFINITE);
+ ResetEvent (args.parent_ready_h);
+
+ /* fill in stack; tell parent this is done */
+ args.entry->stack = GC_get_stack_base();
+ SetEvent (args.child_ready_h);
+
+ /* wait for parent to tell us to go (in case it needs to suspend us) */
+ WaitForSingleObject (args.parent_ready_h, INFINITE);
+ CloseHandle (args.parent_ready_h);
+
+ /* Clear the thread entry even if we exit with an exception. */
+ /* This is probably pointless, since an uncaught exception is */
+ /* supposed to result in the process being killed. */
+ __try {
+ ret = args.start (args.param);
+ } __finally {
+ LOCK();
+ args.entry->stack = 0;
+ args.entry->in_use = FALSE;
+ /* cast away volatile qualifier */
+ BZERO((void *) &args.entry->context, sizeof(CONTEXT));
+ UNLOCK();
+ }
+
+ return ret;
+}
+
+typedef struct {
+ HINSTANCE hInstance;
+ HINSTANCE hPrevInstance;
+ LPWSTR lpCmdLine;
+ int nShowCmd;
+} main_thread_args;
+
+DWORD WINAPI main_thread_start(LPVOID arg);
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
+ LPWSTR lpCmdLine, int nShowCmd)
+{
+ DWORD exit_code = 1;
+
+ main_thread_args args = {
+ hInstance, hPrevInstance, lpCmdLine, nShowCmd
+ };
+ HANDLE thread_h;
+ DWORD thread_id;
+
+ /* initialize everything */
+ InitializeCriticalSection(&GC_allocate_ml);
+ GC_init();
+
+ /* start the main thread */
+ thread_h = GC_CreateThread(
+ NULL, 0, main_thread_start, &args, 0, &thread_id);
+
+ if (thread_h != NULL)
+ {
+ WaitForSingleObject (thread_h, INFINITE);
+ GetExitCodeThread (thread_h, &exit_code);
+ CloseHandle (thread_h);
+ }
+
+ GC_deinit();
+ DeleteCriticalSection(&GC_allocate_ml);
+
+ return (int) exit_code;
+}
+
+DWORD WINAPI main_thread_start(LPVOID arg)
+{
+ main_thread_args * args = (main_thread_args *) arg;
+
+ return (DWORD) GC_WinMain (args->hInstance, args->hPrevInstance,
+ args->lpCmdLine, args->nShowCmd);
+}
+
+# else /* !MSWINCE */
+
LONG WINAPI GC_write_fault_handler(struct _EXCEPTION_POINTERS *exc_info);
/*
@@ -167,11 +522,14 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
/* The following should be a noop according to the win32 */
/* documentation. There is empirical evidence that it */
/* isn't. - HB */
-# ifndef SMALL_CONFIG
+# ifdef MPROTECT_VDB
if (GC_incremental) SetUnhandledExceptionFilter(GC_write_fault_handler);
# endif
- for (i = 0; InterlockedExchange(&thread_table[i].in_use,1) != 0; i++) {
+ for (i = 0;
+ /* cast away volatile qualifier */
+ InterlockedExchange((LPLONG) &thread_table[i].in_use, 1) != 0;
+ i++) {
/* Compare-and-swap would make this cleaner, but that's not */
/* supported before Windows 98 and NT 4.0. In Windows 2000, */
/* InterlockedExchange is supposed to be replaced by */
@@ -182,15 +540,16 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
}
thread_table[i].id = GetCurrentThreadId();
if (!DuplicateHandle(GetCurrentProcess(),
- GetCurrentThread(),
+ GetCurrentThread(),
GetCurrentProcess(),
- &thread_table[i].handle,
+ /* cast away volatile qualifier */
+ (HANDLE *) &thread_table[i].handle,
0,
0,
DUPLICATE_SAME_ACCESS)) {
- DWORD last_error = GetLastError();
- GC_printf1("Last error code: %lx\n", last_error);
- ABORT("DuplicateHandle failed");
+ DWORD last_error = GetLastError();
+ GC_printf1("Last error code: %lx\n", last_error);
+ ABORT("DuplicateHandle failed");
}
thread_table[i].stack = GC_get_stack_base();
/* If this thread is being created while we are trying to stop */
@@ -199,7 +558,6 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
while (GC_please_stop) Sleep(20);
}
break;
- case DLL_PROCESS_DETACH:
case DLL_THREAD_DETACH:
{
int i;
@@ -214,12 +572,37 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved)
thread_table[i].stack = 0;
thread_table[i].in_use = FALSE;
CloseHandle(thread_table[i].handle);
- BZERO(&thread_table[i].context, sizeof(CONTEXT));
+ /* cast away volatile qualifier */
+ BZERO((void *) &thread_table[i].context, sizeof(CONTEXT));
UNLOCK();
}
break;
+ case DLL_PROCESS_DETACH:
+ {
+ int i;
+
+ LOCK();
+ for (i = 0; i < MAX_THREADS; ++i)
+ {
+ if (thread_table[i].in_use)
+ {
+ thread_table[i].stack = 0;
+ thread_table[i].in_use = FALSE;
+ CloseHandle(thread_table[i].handle);
+ BZERO((void *) &thread_table[i].context, sizeof(CONTEXT));
+ }
+ }
+ UNLOCK();
+
+ GC_deinit();
+ DeleteCriticalSection(&GC_allocate_ml);
+ }
+ break;
+
}
return TRUE;
}
+# endif /* !MSWINCE */
+
#endif /* WIN32_THREADS */