* *: update from upstream changes.
svn path=/trunk/mono/; revision=55979
+
+Tue Jan 24 12:34:06 CET 2006 Paolo Molaro <lupus@ximian.com>
+
+ * *: update from upstream changes.
+
2006-01-21 Martin Baulig <martin@ximian.com>
* include/Makefile.am: Don't install libgc-mono-debugger.h.
endif
libmonogc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \
-dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c aix_irix_threads.c \
+dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
pthread_support.c pthread_stop_world.c darwin_stop_world.c \
$(asm_libgc_sources)
-
-# Include THREADLIBS here to ensure that the correct versions of
+# Include THREADDLLIBS here to ensure that the correct versions of
# linuxthread semaphore functions get linked:
-libmonogc_la_LIBADD = @addobjs@ $(THREADLIBS) $(UNWINDLIBS)
+libmonogc_la_LIBADD = @addobjs@ $(THREADDLLIBS) $(UNWINDLIBS)
libmonogc_la_DEPENDENCIES = @addobjs@
libmonogc_la_LDFLAGS = -version-info 1:2:0
AM_CFLAGS = @GC_CFLAGS@
+if CPLUSPLUS
+extra_checks = test_cpp
+else
+extra_checks =
+endif
+
+check_PROGRAMS = gctest $(extra_checks)
+
+test.o: $(srcdir)/tests/test.c
+ $(COMPILE) -c $(srcdir)/tests/test.c
+# Using $< in the above seems to fail with the HP/UX on Itanium make.
+test_cpp.o: $(srcdir)/tests/test_cpp.cc
+ $(CXXCOMPILE) -c $(srcdir)/tests/test_cpp.cc
+
+## FIXME: this is probably the reason why some files from BUILT_SOURCES
+## are included in the distribution
+# gctest_OBJECTS = test.o
+gctest_SOURCES = tests/test.c
+gctest_LDADD = ./libgc.la $(THREADDLLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
+test_cpp_SOURCES = tests/test_cpp.cc
+test_cpp_LDADD = ./libgc.la ./libgccpp.la $(THREADDLLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
+
+TESTS = gctest $(extra_checks)
+
## FIXME: relies on internal code generated by automake.
all_objs = @addobjs@ $(libgc_la_OBJECTS)
$(all_objs) : include/private/gcconfig.h include/private/gc_priv.h \
include/private/gc_hdrs.h include/gc.h include/gc_gcj.h include/gc_mark.h
## FIXME: we shouldn't have to do this, but automake forces us to.
+if COMPILER_XLC
+ ## XLC neither requires nor tolerates the unnecessary assembler goop
+ ASM_CPP_OPTIONS =
+else
+ ## We use -Wp,-P to strip #line directives. Irix `as' chokes on
+ ## these.
+ ASM_CPP_OPTIONS = -Wp,-P -x assembler-with-cpp
+endif
.s.lo:
## We use -Wp,-P to strip #line directives. Irix `as' chokes on
## these.
- $(LTCOMPILE) -Wp,-P -x assembler-with-cpp -c $<
+ $(LTCOMPILE) $(ASM_CPP_OPTIONS) -c $<
## We have our own definition of LTCOMPILE because we want to use our
## CFLAGS, not those passed in from the top level make.
# -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC
# To build the parallel collector in a static library on HP/UX,
# add to the above:
-# -DGC_HPUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC -D_POSIX_C_SOURCE=199506L
+# -DGC_HPUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC -D_POSIX_C_SOURCE=199506L -mt
# To build the thread-safe collector on Tru64, add to the above:
# -pthread -DGC_OSF1_THREADS
# Also requires -D_REENTRANT or -D_POSIX_C_SOURCE=199506L. See README.hp.
# -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads.
# see README.linux. -D_REENTRANT may also be required.
-# -DGC_OSF1_THREADS enables support for Tru64 pthreads. Untested.
-# -DGC_FREEBSD_THREADS enables support for FreeBSD pthreads. Untested.
+# -DGC_OSF1_THREADS enables support for Tru64 pthreads.
+# -DGC_FREEBSD_THREADS enables support for FreeBSD pthreads.
# Appeared to run into some underlying thread problems.
-# -DGC_DARWIN_THREADS enables support for Mac OS X pthreads. Untested.
+# -DGC_DARWIN_THREADS enables support for Mac OS X pthreads.
+# -DGC_AIX_THREADS enables support for IBM AIX threads.
# -DGC_DGUX386_THREADS enables support for DB/UX on I386 threads.
# See README.DGUX386.
# -DGC_WIN32_THREADS enables support for win32 threads. That makes sense
# -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.
+# Currently works only on platforms such as Linux which use pthread_support.c.
+# Recommended for multiprocessors.
# -DUSE_COMPILER_TLS causes thread local allocation to use compiler-supported
# "__thread" thread-local variables. This is the default in HP/UX. It
# may help performance on recent Linux installations. (It failed for
# -DPOINTER_SHIFT=n causes the collector to left shift candidate pointers
# by the indicated amount before trying to interpret them. Applied
# after POINTER_MASK. EXPERIMENTAL. See also the preceding macro.
+# -DDARWIN_DONT_PARSE_STACK Causes the Darwin port to discover thread
+# stack bounds in the same way as other pthread ports, without trying to
+# walk the frames onthe stack. This is recommended only as a fallback
+# for applications that don't support proper stack unwinding.
#
CXXFLAGS= $(CFLAGS)
RANLIB= ranlib
-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 aix_irix_threads.o pthread_support.o pthread_stop_world.o darwin_stop_world.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o backgraph.o win32_threads.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 pthread_support.o pthread_stop_world.o darwin_stop_world.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o backgraph.o win32_threads.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 aix_irix_threads.c pthread_support.c pthread_stop_world.c darwin_stop_world.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c backgraph.c win32_threads.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 pthread_support.c pthread_stop_world.c darwin_stop_world.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c backgraph.c win32_threads.c
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
doc/simple_example.html
TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \
- tests/leak_test.c tests/thread_leak_test.c
+ tests/leak_test.c tests/thread_leak_test.c tests/middle.c
GNU_BUILD_FILES= configure.in Makefile.am configure acinclude.m4 \
libtool.m4 install-sh configure.host Makefile.in \
-# Makefile for Windows NT. Assumes Microsoft compiler, and a single thread.
+# Makefile for Windows NT. Assumes Microsoft compiler.
# DLLs are included in the root set under NT, but not under win32S.
# Use "nmake nodebug=1 all" for optimized versions of library, gctest and editor.
for (i = 0; i <= N_HBLK_FLS; ++i) {
h = GC_hblkfreelist[i];
# ifdef USE_MUNMAP
- if (0 != h) GC_printf1("Free list %ld (Total size %ld):\n",
+ if (0 != h) GC_printf1("Free list %ld:\n",
(unsigned long)i);
# else
if (0 != h) GC_printf2("Free list %ld (Total size %ld):\n",
h = hhdr -> hb_next;
}
}
- if (total_free != GC_large_free_bytes) {
+# ifndef USE_MUNMAP
+ if (total_free != GC_large_free_bytes) {
GC_printf1("GC_large_free_bytes = %lu (INCONSISTENT!!)\n",
(unsigned long) GC_large_free_bytes);
- }
+ }
+# endif
GC_printf1("Total of %lu bytes on free list\n", (unsigned long)total_free);
}
hhdr = HDR(p);
GC_printf1("\t0x%lx ", (unsigned long)p);
if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
- GC_printf1("Missing header!!\n", hhdr);
+ GC_printf1("Missing header!!(%ld)\n", hhdr);
p += HBLKSIZE;
continue;
}
GET_HDR(hhdr -> hb_prev, phdr);
phdr -> hb_next = hhdr -> hb_next;
}
+ FREE_ASSERT(GC_free_bytes[index] >= hhdr -> hb_sz);
INCR_FREE_BYTES(index, - (signed_word)(hhdr -> hb_sz));
- FREE_ASSERT(GC_free_bytes[index] >= 0);
if (0 != hhdr -> hb_next) {
hdr * nhdr;
GC_ASSERT(!IS_FORWARDING_ADDR_OR_NIL(NHDR(hhdr)));
if (total_size == bytes) return h;
rest = (struct hblk *)((word)h + bytes);
rest_hdr = GC_install_header(rest);
- if (0 == rest_hdr) return(0);
+ if (0 == rest_hdr) {
+ /* This may be very bad news ... */
+ WARN("Header allocation failed: Dropping block.\n", 0);
+ return(0);
+ }
rest_hdr -> hb_sz = total_size - bytes;
rest_hdr -> hb_flags = 0;
# ifdef GC_ASSERTIONS
GET_HDR(hbp, hhdr);
size_avail = hhdr->hb_sz;
if (size_avail < size_needed) continue;
- if (!GC_use_entire_heap
- && size_avail != size_needed
+ if (size_avail != size_needed
+ && !GC_use_entire_heap
+ && !GC_dont_gc
&& USED_HEAP_SIZE >= GC_requested_heapsize
&& !TRUE_INCREMENTAL && GC_should_collect()) {
# ifdef USE_MUNMAP
/* If we are deallocating lots of memory from */
/* finalizers, fail and collect sooner rather */
/* than later. */
- if (GC_finalizer_mem_freed > (GC_heapsize >> 4)) {
+ if (WORDS_TO_BYTES(GC_finalizer_mem_freed)
+ > (GC_heapsize >> 4)) {
continue;
}
# endif /* !USE_MUNMAP */
struct hblk * h;
struct hblk * prev = hhdr -> hb_prev;
- GC_words_wasted += total_size;
+ GC_words_wasted += BYTES_TO_WORDS(total_size);
GC_large_free_bytes -= total_size;
GC_remove_from_fl(hhdr, n);
for (h = hbp; h < limit; h++) {
# include "version.h"
+#if defined(SAVE_CALL_CHAIN) && \
+ !(defined(REDIRECT_MALLOC) && defined(GC_HAVE_BUILTIN_BACKTRACE))
+# define SAVE_CALL_CHAIN_IN_GC
+ /* This is only safe if the call chain save mechanism won't end up */
+ /* calling GC_malloc. The GNU C library documentation suggests */
+ /* that backtrace doesn't use malloc, but at least the initial */
+ /* call in some versions does seem to invoke the dynamic linker, */
+ /* which uses malloc. */
+#endif
+
/* some more variables */
extern signed_word GC_mem_found; /* Number of reclaimed longwords */
extern GC_bool GC_collection_in_progress();
/* Collection is in progress, or was abandoned. */
-extern GC_bool GC_print_back_height;
-
int GC_never_stop_func GC_PROTO((void)) { return(0); }
unsigned long GC_time_limit = TIME_LIMIT;
if (GC_print_stats) {
GC_printf0("Abandoning stopped marking after ");
GC_printf1("%lu msecs", (unsigned long)time_diff);
- GC_printf1("(attempt %d)\n", (unsigned long) GC_n_attempts);
+ GC_printf1("(attempt %ld)\n", (unsigned long) GC_n_attempts);
}
# endif
return(1);
/* had been reallocated this round. Finalization is user */
/* visible progress. And if we don't count this, we have */
/* stability problems for programs that finalize all objects. */
- result += GC_words_wasted;
+ if ((GC_words_wasted >> 3) < result)
+ result += GC_words_wasted;
/* This doesn't reflect useful work. But if there is lots of */
/* new fragmentation, the same is probably true of the heap, */
/* and the collection will be correspondingly cheaper. */
{
# define NWORDS 64
word frames[NWORDS];
+ /* Some compilers will warn that frames was set but never used. */
+ /* That's the whole idea ... */
register int i;
for (i = 0; i < NWORDS; i++) frames[i] = 0;
# endif
if (GC_stopped_mark(GC_time_limit == GC_TIME_UNLIMITED?
GC_never_stop_func : GC_timeout_stop_func)) {
-# ifdef SAVE_CALL_CHAIN
+# ifdef SAVE_CALL_CHAIN_IN_GC
GC_save_callers(GC_last_stack);
# endif
GC_finish_collection();
}
GC_invalidate_mark_state(); /* Flush mark stack. */
GC_clear_marks();
-# ifdef SAVE_CALL_CHAIN
+# ifdef SAVE_CALL_CHAIN_IN_GC
GC_save_callers(GC_last_stack);
# endif
GC_is_full_gc = TRUE;
for (i = GC_deficit; i < GC_RATE*n; i++) {
if (GC_mark_some((ptr_t)0)) {
/* Need to finish a collection */
-# ifdef SAVE_CALL_CHAIN
+# ifdef SAVE_CALL_CHAIN_IN_GC
GC_save_callers(GC_last_stack);
# endif
# ifdef PARALLEL_MARK
# endif
expansion_slop = WORDS_TO_BYTES(min_words_allocd()) + 4*MAXHINCR*HBLKSIZE;
if (GC_last_heap_addr == 0 && !((word)space & SIGNB)
- || GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space) {
+ || (GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space)) {
/* Assume the heap is growing up */
GC_greatest_plausible_heap_addr =
(GC_PTR)GC_max((ptr_t)GC_greatest_plausible_heap_addr,
GC_bool ignore_off_page;
{
if (!GC_incremental && !GC_dont_gc &&
- (GC_dont_expand && GC_words_allocd > 0
- || (GC_fo_entries > (last_fo_entries + 500) && (last_words_finalized || GC_words_finalized))
- || GC_should_collect())) {
+ ((GC_dont_expand && GC_words_allocd > 0)
+ || (GC_fo_entries > (last_fo_entries + 500) && (last_words_finalized || GC_words_finalized))
+ || GC_should_collect())) {
GC_gcollect_inner();
last_fo_entries = GC_fo_entries;
last_words_finalized = GC_words_finalized;
if (blocks_to_get > MAXHINCR) {
word slop;
+ /* Get the minimum required to make it likely that we */
+ /* can satisfy the current request in the presence of black- */
+ /* listing. This will probably be more than MAXHINCR. */
if (ignore_off_page) {
slop = 4;
} else {
- # $Id$
.arch ev6
.text
.mask 0x04000000, 0
.frame $sp, 16, $26, 0
- # $0 integer result
- # $1-$8 temp regs - not preserved cross calls
- # $9-$15 call saved regs
- # $16-$21 argument regs - not preserved cross calls
- # $22-$28 temp regs - not preserved cross calls
- # $29 global pointer - not preserved cross calls
- # $30 stack pointer
+/* $0 integer result */
+/* $1-$8 temp regs - not preserved cross calls */
+/* $9-$15 call saved regs */
+/* $16-$21 argument regs - not preserved cross calls */
+/* $22-$28 temp regs - not preserved cross calls */
+/* $29 global pointer - not preserved cross calls */
+/* $30 stack pointer */
# define call_push(x) \
mov x, $16; \
call_push($14)
call_push($15)
- # $f0-$f1 floating point results
- # $f2-$f9 call saved regs
- # $f10-$f30 temp regs - not preserved cross calls
+/* $f0-$f1 floating point results */
+/* $f2-$f9 call saved regs */
+/* $f10-$f30 temp regs - not preserved cross calls */
- # Use the most efficient transfer method for this hardware.
- # Bit 1 detects the FIX extension, which includes ftoit.
+ /* Use the most efficient transfer method for this hardware. */
+ /* Bit 1 detects the FIX extension, which includes ftoit. */
amask 2, $0
bne $0, $use_stack
{
if (0 == back_edge_space) {
back_edge_space = (back_edges *)
- sbrk(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
+ GET_MEM(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges));
}
if (0 != avail_back_edges) {
back_edges * result = avail_back_edges;
/* Table of objects that are currently on the depth-first search */
/* stack. Only objects with in-degree one are in this table. */
/* Other objects are identified using HEIGHT_IN_PROGRESS. */
-/* This data structure NEEDS IMPROVEMENT. */
-#define MAX_IN_PROGRESS 10000
+/* FIXME: This data structure NEEDS IMPROVEMENT. */
+#define INITIAL_IN_PROGRESS 10000
static ptr_t * in_progress_space = 0;
-static int n_in_progress = 0;
+static size_t in_progress_size = 0;
+static size_t n_in_progress = 0;
static void push_in_progress(ptr_t p)
{
+ if (n_in_progress >= in_progress_size)
+ if (in_progress_size == 0) {
+ in_progress_size = INITIAL_IN_PROGRESS;
+ in_progress_space = (ptr_t *)GET_MEM(in_progress_size * sizeof(ptr_t));
+ } else {
+ ptr_t * new_in_progress_space;
+ in_progress_size *= 2;
+ new_in_progress_space = (ptr_t *)
+ GET_MEM(in_progress_size * sizeof(ptr_t));
+ BCOPY(in_progress_space, new_in_progress_space,
+ n_in_progress * sizeof(ptr_t));
+ in_progress_space = new_in_progress_space;
+ /* FIXME: This just drops the old space. */
+ }
if (in_progress_space == 0)
- in_progress_space = sbrk(MAX_IN_PROGRESS * sizeof(ptr_t));
- if (n_in_progress == MAX_IN_PROGRESS)
- ABORT("Exceeded MAX_IN_PROGRESS");
+ ABORT("MAKE_BACK_GRAPH: Out of in-progress space: "
+ "Huge linear data structure?");
in_progress_space[n_in_progress++] = p;
}
}
}
-/* Rebuild the reprentation of the backward reachability graph. */
-/* Does not examine mark bits. Can be called before GC. */
+/* Rebuild the representation of the backward reachability graph. */
+/* Does not examine mark bits. Can be called before GC. */
void GC_build_back_graph(void)
{
GC_apply_to_each_object(add_back_edges);
}
}
+word GC_max_max_height = 0;
+
void GC_traverse_back_graph(void)
{
- static word max_max_height = 0;
GC_max_height = 0;
GC_apply_to_each_object(update_max_height);
+}
+
+void GC_print_back_graph_stats(void)
+{
GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n",
(unsigned long) GC_gc_no, GC_max_height);
- if (GC_max_height > max_max_height) {
- max_max_height = GC_max_height;
+ if (GC_max_height > GC_max_max_height) {
+ GC_max_max_height = GC_max_height;
GC_printf0("The following unreachable object is last in a longest chain "
"of unreachable objects:\n");
GC_print_heap_obj(GC_deepest_obj);
dnl Process this file with autoconf to produce configure.
AC_PREREQ(2.53)
-AC_INIT(libgc-mono, 6.3alpha6, Hans_Boehm@hp.com)
+AC_INIT(libgc-mono, 6.6, Hans_Boehm@hp.com)
-AM_INIT_AUTOMAKE(libgc-mono, 6.2, no-define)
+AM_INIT_AUTOMAKE(libgc-mono, 6.6, no-define)
AC_CONFIG_SRCDIR(gcj_mlc.c)
AC_CANONICAL_HOST
)
INCLUDES=-I${srcdir}/include
-THREADLIBS=
+THREADDLLIBS=
+## Libraries needed to support dynamic loading and/or threads.
case "$THREADS" in
no | none | single)
THREADS=none
;;
posix | pthreads)
THREADS=posix
- THREADLIBS=-lpthread
+ THREADDLLIBS=-lpthread
case "$host" in
x86-*-linux* | ia64-*-linux* | i386-*-linux* | i486-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* | alpha-*-linux* | s390*-*-linux* | powerpc-*-linux*)
AC_DEFINE(GC_LINUX_THREADS)
AC_DEFINE(PARALLEL_MARK)
fi
AC_DEFINE(THREAD_LOCAL_ALLOC)
- THREADLIBS="-lpthread -lrt"
+ THREADDLLIBS="-lpthread -lrt"
;;
*-*-freebsd4*)
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
fi
if test "x$PTHREAD_LIBS" = "x"; then
- THREADLIBS=-pthread
+ THREADDLLIBS=-pthread
else
- THREADLIBS="$PTHREAD_LIBS"
+ THREADDLLIBS=$PTHREAD_LIBS
fi
;;
*-*-freebsd5*)
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
AC_DEFINE(GC_FREEBSD_THREADS)
- if test "x$PTHREAD_CFLAGS" != "x"; then
- INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
- fi
- if test "x$PTHREAD_LIBS" = "x"; then
- THREADLIBS=-pthread
- else
- THREADLIBS="$PTHREAD_LIBS"
- fi
+ INCLUDES="$INCLUDES -pthread"
+ THREADDLLIBS=-pthread
;;
*-*-freebsd6*)
AC_DEFINE(GC_FREEBSD_THREADS)
INCLUDES="$INCLUDES $PTHREAD_CFLAGS"
fi
if test "x$PTHREAD_LIBS" = "x"; then
- THREADLIBS=-pthread
+ THREADDLLIBS=-pthread
else
- THREADLIBS="$PTHREAD_LIBS"
+ THREADDLLIBS="$PTHREAD_LIBS"
fi
;;
*-*-solaris*)
# Measurements havent yet been done.
fi
INCLUDES="$INCLUDES -pthread"
- THREADLIBS="-lpthread -lrt"
+ THREADDLLIBS="-lpthread -lrt"
+ ;;
+ *)
+ AC_MSG_ERROR("Pthreads not supported by the GC on this platform.")
;;
esac
;;
;;
dgux386)
THREADS=dgux386
- AC_MSG_RESULT($THREADLIBS)
+ AC_MSG_RESULT($THREADDLLIBS)
# Use pthread GCC switch
- THREADLIBS=-pthread
+ THREADDLLIBS=-pthread
if test "${enable_parallel_mark}" = yes; then
AC_DEFINE(PARALLEL_MARK)
fi
;;
aix)
THREADS=posix
- THREADLIBS=-lpthread
+ THREADDLLIBS=-lpthread
AC_DEFINE(GC_AIX_THREADS)
AC_DEFINE(_REENTRANT)
;;
AC_MSG_ERROR($THREADS is an unknown thread package)
;;
esac
-AC_SUBST(THREADLIBS)
+AC_SUBST(THREADDLLIBS)
case "$host" in
powerpc-*-darwin*)
esac
AM_CONDITIONAL(POWERPC_DARWIN,test x$powerpc_darwin = xtrue)
+AC_MSG_CHECKING(for xlc)
+AC_TRY_COMPILE([],[
+ #ifndef __xlC__
+ # error
+ #endif
+], [compiler_xlc=yes], [compiler_xlc=no])
+AC_MSG_RESULT($compiler_xlc)
+AM_CONDITIONAL(COMPILER_XLC,test $compiler_xlc = yes)
+if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
+ # the darwin stack-frame-walking code is completely broken on xlc
+ AC_DEFINE(DARWIN_DONT_PARSE_STACK)
+fi
+
# We never want libdl on darwin. It is a fake libdl that just ends up making
# dyld calls anyway
case "$host" in
*-*-darwin*) ;;
*)
- AC_CHECK_LIB(dl, dlopen, EXTRA_TEST_LIBS="$EXTRA_TEST_LIBS -ldl")
+ AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
;;
esac
machdep="sparc_mach_dep.lo"
AC_DEFINE(SUNOS53_SHARED_LIB)
;;
- sparc-sun-solaris2.*)
+ sparc*-sun-solaris2.*)
machdep="sparc_mach_dep.lo"
;;
ia64-*-*)
dnl As of 4.13a2, the collector will not properly work on Solaris when
dnl built with gcc and -O. So we remove -O in the appropriate case.
-dnl
+dnl Not needed anymore on Solaris.
AC_MSG_CHECKING(whether Solaris gcc optimization fix is necessary)
case "$host" in
- sparc-sun-solaris2*|*aix*)
+ *aix*)
if test "$GCC" = yes; then
AC_MSG_RESULT(yes)
new_CFLAGS=
register int result = 0;
register int current_number = 0;
register int saw_period = 0;
- register int saw_number;
+ register int saw_number = 0;
register int chars_so_far = 0;
register char current;
char * str = va_arg(args, char *);
register char c;
- while (c = *str++) {
+ while ((c = *str++)) {
CORD_ec_append(result, c);
}
goto done;
if (buf != result[0].ec_bufptr) {
register char c;
- while (c = *buf++) {
+ while ((c = *buf++)) {
CORD_ec_append(result, c);
}
} else {
if (CORD_cmp(result, result2) != 0)ABORT("CORD_sprintf goofed 5");
}
-main()
+int main()
{
# ifdef THINK_C
printf("cordtest:\n");
Page 50: "If a leaf procedure's red zone usage would exceed 224 bytes, then
it must set up a stack frame just like routines that call other routines."
*/
-#define PPC_RED_ZONE_SIZE 224
+#ifdef POWERPC
+# if CPP_WORDSZ == 32
+# define PPC_RED_ZONE_SIZE 224
+# elif CPP_WORDSZ == 64
+# define PPC_RED_ZONE_SIZE 320
+# endif
+#endif
-/* Not 64-bit clean. Wait until Apple defines their 64-bit ABI */
typedef struct StackFrame {
- unsigned int savedSP;
- unsigned int savedCR;
- unsigned int savedLR;
- unsigned int reserved[2];
- unsigned int savedRTOC;
+ unsigned long savedSP;
+ unsigned long savedCR;
+ unsigned long savedLR;
+ unsigned long reserved[2];
+ unsigned long savedRTOC;
} StackFrame;
-
-unsigned int FindTopOfStack(unsigned int stack_start) {
+unsigned long FindTopOfStack(unsigned int stack_start) {
StackFrame *frame;
if (stack_start == 0) {
- __asm__ volatile("lwz %0,0(r1)" : "=r" (frame));
+# ifdef POWERPC
+# if CPP_WORDSZ == 32
+ __asm__ volatile("lwz %0,0(r1)" : "=r" (frame));
+# else
+ __asm__ volatile("ldz %0,0(r1)" : "=r" (frame));
+# endif
+# endif
} else {
frame = (StackFrame *)stack_start;
}
/* GC_printf1("FindTopOfStack start at sp = %p\n", frame); */
# endif
do {
- if (frame->savedSP == NULL) break;
+ if (frame->savedSP == 0) break;
/* if there are no more stack frames, stop */
frame = (StackFrame*)frame->savedSP;
/* GC_printf1("FindTopOfStack finish at sp = %p\n", frame); */
# endif
- return (unsigned int)frame;
+ return (unsigned long)frame;
}
+#ifdef DARWIN_DONT_PARSE_STACK
+void GC_push_all_stacks() {
+ int i;
+ kern_return_t r;
+ GC_thread p;
+ pthread_t me;
+ ptr_t lo, hi;
+ ppc_thread_state_t state;
+ mach_msg_type_number_t thread_state_count = MACHINE_THREAD_STATE_COUNT;
+
+ me = pthread_self();
+ if (!GC_thr_initialized) GC_thr_init();
+
+ for(i=0;i<THREAD_TABLE_SZ;i++) {
+ 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();
+ } else {
+ /* Get the thread state (registers, etc) */
+ r = thread_get_state(
+ p->stop_info.mach_thread,
+ MACHINE_THREAD_STATE,
+ (natural_t*)&state,
+ &thread_state_count);
+ if(r != KERN_SUCCESS) ABORT("thread_get_state failed");
+
+ lo = (void*)(state.r1 - PPC_RED_ZONE_SIZE);
+
+ GC_push_one(state.r0);
+ GC_push_one(state.r2);
+ GC_push_one(state.r3);
+ GC_push_one(state.r4);
+ GC_push_one(state.r5);
+ GC_push_one(state.r6);
+ GC_push_one(state.r7);
+ GC_push_one(state.r8);
+ GC_push_one(state.r9);
+ GC_push_one(state.r10);
+ GC_push_one(state.r11);
+ GC_push_one(state.r12);
+ GC_push_one(state.r13);
+ GC_push_one(state.r14);
+ GC_push_one(state.r15);
+ GC_push_one(state.r16);
+ GC_push_one(state.r17);
+ GC_push_one(state.r18);
+ GC_push_one(state.r19);
+ GC_push_one(state.r20);
+ GC_push_one(state.r21);
+ GC_push_one(state.r22);
+ GC_push_one(state.r23);
+ GC_push_one(state.r24);
+ GC_push_one(state.r25);
+ GC_push_one(state.r26);
+ GC_push_one(state.r27);
+ GC_push_one(state.r28);
+ GC_push_one(state.r29);
+ GC_push_one(state.r30);
+ GC_push_one(state.r31);
+ } /* p != me */
+ if(p->flags & MAIN_THREAD)
+ hi = GC_stackbottom;
+ else
+ hi = p->stack_end;
+#if DEBUG_THREADS
+ GC_printf3("Darwin: Stack for thread 0x%lx = [%lx,%lx)\n",
+ (unsigned long) p -> id,
+ (unsigned long) lo,
+ (unsigned long) hi
+ );
+#endif
+ GC_push_all_stack(lo,hi);
+ } /* for(p=GC_threads[i]...) */
+ } /* for(i=0;i<THREAD_TABLE_SZ...) */
+}
+
+#else /* !DARWIN_DONT_PARSE_STACK; Use FindTopOfStack() */
+
void GC_push_all_stacks() {
int i;
kern_return_t r;
lo = GC_approx_sp();
hi = (ptr_t)FindTopOfStack(0);
} else {
-# ifdef POWERPC
+# if defined(POWERPC)
+# if CPP_WORDSZ == 32
ppc_thread_state_t info;
+# else
+ ppc_thread_state64_t info;
+# endif
mach_msg_type_number_t outCount = THREAD_STATE_MAX;
r = thread_get_state(thread, MACHINE_THREAD_STATE,
(natural_t *)&info, &outCount);
} /* for(p=GC_threads[i]...) */
vm_deallocate(current_task(), (vm_address_t)act_list, sizeof(thread_t) * listcount);
}
+#endif /* !DARWIN_DONT_PARSE_STACK */
static mach_port_t GC_mach_handler_thread;
static int GC_use_mach_handler_thread = 0;
kern_return_t kern_result;
thread_act_array_t act_list;
mach_msg_type_number_t listcount;
+ struct thread_basic_info info;
+ mach_msg_type_number_t outCount = THREAD_INFO_MAX;
# if DEBUG_THREADS
GC_printf0("World starting\n");
# endif
continue;
}
- struct thread_basic_info info;
- mach_msg_type_number_t outCount = THREAD_INFO_MAX;
kern_result = thread_info(thread, THREAD_BASIC_INFO,
(thread_info_t)&info, &outCount);
if(kern_result != KERN_SUCCESS) continue;
collector. (If you are concerned about such things, I recommend you look
at the notice in config.guess or ltmain.sh.)
-This is version 6.3alpha6 of a conservative garbage collector for C and C++.
+This is version 6.6 of a conservative garbage collector for C and C++.
You might find a more recent version of this at
- Remove ltconfig, clean up configure messages for DGUX (thanks to
Adrian Bunk for the patches).
- Integrated NetBSD/OpenBSD patches from Marc Recht and Matthias Drochner.
+
+Since gc6.3alpha6:
+ - Compile test_cpp.cc with CXXCOMPILE instead of COMPILE.
+ - Very large allocations could cause a collector hang. Correct
+ calculation of GC_collect_at_heapsize.
+ - GC_print_hblkfreelist printed some bogus results if USE_MUNMAP
+ was defined.
+ - The generic GC_THREADS macro didn't work correctly on Solaris,
+ since the implementation failed to include gc_config_macros.h
+ before deciding whether or not to compile the rest of the file.
+ - Threadlibs.c failed to expand the generic GC_THREADS macro.
+ - Correct MacOSX thread stop code. (Thanks to Dick Porter.)
+ - SMALL_OBJ definition was off by one. This could cause crashes
+ at startup. (Thanks to Zoltan Varga for narrowing this down to
+ a trivial test case.)
+ - Integrate Paolo Molara's patch to deal with a race in the Darwin
+ thread stopping code.
+ - Changed X86_64 implementation to use SA_SIGINFO in the MPROTECT_VDB
+ implementation. The old approach appears to have been broken by
+ recent kernels.
+ - Add GC_ATTR_UNUSED to eliminate a warning in gc_allocator.h. (Thanks
+ to Andrew Begel.)
+ - Fix GC_task_self declaration in os_dep.c. (Thanks to Andrew Pinski.)
+ - Increase INITIAL_BUF_SZ in os_dep.c for Solaris /proc reads.
+
+Since 6.3:
+ - Merge gcconfig.h changes from gcc tree.
+ - Unconditionally include gc_priv.h in solaris_pthreads.c, win32_threads.h,
+ aix_irix_threads.c, and solaris_threads.c to get thread definitions.
+ - Start marker threads in GC_thr_init, so that they get started even
+ if no other threads are ever started. (Oddly enough, the parallel
+ collector worked correctly, though not well, with no helper threads.)
+ - Go ahead and split large blocks in GC_allochblk_nth if GC_dont_gc
+ is set. (Thanks to Alexander Petrossian.)
+ - GC_PRINT_BACK_HEIGHT would deadlock with thread support.
+ - Let in_progress_space in backgraph.s grow dynamically.
+ - Fix README.solaris2. The GC_thr_init() hack doesn't work anymore.
+ - Convert GC_finalizer_mem_freed to bytes in allchblk.c.
+ - Add missing declaration for GC_generic_malloc_words_small_inner.
+ Without it, s390x breaks. (Thanks to Ulrich Weigand.)
+ - Applied several MacOSX patches to support older tool chains.
+ (Thanks to Stefan Ring.)
+ - Bug fix for NetBSD/amd64. (Thanks to Marc Recht.) Add NetBSD/sh3
+ support. (Thanks to Uchiyama Yasushi.)
+ - Fixed an uninitialized variable in cordprnt.c. (Thanks to gcc for
+ providing the warning.)
+ - Eliminated some, but not all, gcc -Wall warnings.
+ - Changed some old style casts to reinterpret_cast in new_gc_alloc.h.
+ (Thanks to Dan Grayson.)
+ - GC_extend_size_map shouldn't adjust for GC_all_interior_pointers if
+ GC_DONT_ADD_BYTE_AT_END is set.
+ - Changed some (long) casts to (word) in preparation for win64.
+ (Thanks to Peter Colson.)
+ - Changed "int stack_size" declaration in pthread_support.c to use
+ size_t. (Only mattered with GC_ASSERTIONS enabled.)
+ - Added CRIS (etrax) support. (Thanks to Simon Posnjak and
+ Hans-Peter Nilsson.)
+ - Removed GC_IGNORE_FB frame buffer recognition, and replaced
+ it with a check that the mapping type is MEM_IMAGE.
+ In theory, this should work much better, but it is a high
+ risk change for win32. (Thanks to Ashley Bone for the crucial
+ experimental data behind this, and to Rutger Ovidus for
+ some further experiments.)
+ - Fixed print_block_list to print the correct kind number for
+ STUBBORN. (Thanks to Rutger Ovidus.)
+ - GC_allochblk_nth incremented GC_words_wasted by bytes rather than
+ words.
+ - Consider GC_words_wasted in GC_adj_words_allocd only if it is within
+ reason. (A hack to avoid some extremely unlikely scenarios in which
+ we manage to allocate only "wasted" space. 7.0 has a better fix.)
+ - Changed PowerPC GC_clear implementation to use lwsync instead of
+ eieio, since the documentation recommends against eieio, and
+ it seems to be incorrect if the preceding memory op is a load.
+ - Fixed print_block_list to print the correct kind number for
+ STUBBORN. (Thanks to Rutger Ovidus.)
+ - Have configure.in generate an error if it is asked to support
+ pthreads, but doesn't know how to.
+ - Added Kazuhiro Inaoka's patch for Renesas M32R support.
+ - Have the GNU build mechanism link with -ldl. Rename THREADLIBS
+ to THREADDLLIBS to reflect this. (Thanks to Sven Verdoolaege.)
+ - Added Hannes Mehnert's patch for FreeBSD/SPARC support.
+ - Merged some FreeBSD specific patches to threadlibs.c and dyn_load.c.
+ (Thanks tp John Merryweather Cooper.)
+ - Define MPROTECT_VDB on MACOSX only if threads are being used, since the
+ dirty page tracking mechanism uses threads. (This avoids an undefined
+ reference to _GC_darwin_register_mach_handler_thread.)
+ - By popular demand, use __libc symbols only if we are built with
+ USE_LIBC_PRIVATES, which is off by default, and not otherwise documented.
+ - Ignore GC_enable_incremental() requests when KEEP_BACK_PTRS is set.
+ The GC itself will dirty lots of pages in this cases, probably making
+ it counterproductive on all platforms. And the DARWIN port crashes.
+
+Since GC6.4:
+ - Integrated Paolo Molaro's patch to deal with EINTR in sem_wait.
+ - Make GC_approx_sp() write to dummy location to ensure that stack
+ is grown here, when sp looks reasonable, rather than later, when
+ it might look like a bad memory reference. (Problem was never
+ observed that I know of. But on rereading the code it seemed
+ dubious.)
+ - Separate out GC_with_callee_saves_pushed and sometimes call
+ it from GC_suspend_handler in pthread_stop_world.c. Callee-save
+ register values sometimes failed to get traced under HP/UX on
+ PA-RISC. Linux/IA64 had the same problem, though non-stacked
+ callee-save registers seem to be so rarely used there that nobody
+ ever noticed.
+ - Integrated an ancient Darwin powerpc_darwin_machine_dep.s patch
+ from Andreas Tobler, which I had lost.
+ - Fix compare_and_exchange implementation for gcc/IA64 to deal with
+ pickier compiler versions.
+ - Fixed Itanium 32-bit ABI support (HP/UX). In particular, the
+ compare_and_exchange implementation didn't consider that possibility.
+ - Undefine GC_pthread_detach in win32_threads.c. (Thanks to
+ Tagliapietra Tommaso.)
+ - Fixed inclusion of frame.h for NETBSD in os_dep.c.
+ - Applied Dan Bonachea's patch to use mmap on AIX.
+ - Several fixes to resurrect the Irix port on recent OS versions.
+ - Change ALPHA to use LINUX_STACKBOTTOM.
+ - Change SPARC64/LINUX to also use LINUX_STACKBOTTOM. Deal with potential
+ bad values of __libc_stack_end on that platform. (Thanks to David Miller.)
+ - Relax gctest to allow larger heap if ALIGN_DOUBLE isn't set.
+ (Unnecessary in 7.0)
+ - Force a define of __STDC__=0 for the IBM compiler on AIX, so that
+ we get prototypes. (Unnecessary in 7.0)
+ - GC_INIT definition for AIX and CYGWIN referred to DATASTART and DATAEND
+ which are only defined in private include files.
+ - Integrated some small gcconfig.h patches from Dan Bonachea. Also
+ relaxed assertion about FreeBSD stack size in pthread_support.c.
+ - Integrated Andrew Begel's darwin_stop_world.c patch for 64-bit
+ support. This may need additional work.
+ - Avoided potentially infinite recursion in GC_save_callers if
+ the system backtrace calls malloc. The workaround currently requires
+ __thread support if this code is used with threads.
+ - Avoided another similar infinite recursion by conditionally
+ invoking GC_save_callers in alloc.c. (Thanks to Matthias Andree
+ for helping to track down both of these.)
+ - Removed all traces of aix_irix_threads.c. AIX and Irix now use
+ pthread_support.c and pthread_stop_world.c. The old code appeared
+ to be unreliable for AIX, and was not regularly maintained.
+ - On Irix, ignore segments with MA_FETCHOP or MA_NOTCACHED attributed;
+ they're not always safe to read.
+ - Fixed a previously vacuous assertion (diagnosed by the SGI compiler)
+ in GC_remove_from_fl.
+ - Fix stack_size assertion in GC_pthread_create.
+ - Fix assertion in GC_steal_mark_stack.
+Since 6.5
+ - Fix CPU count detection for Irix and FreeBSD. (Thanks to Dan Bonachea.)
+ - Integrate Dan Bonachea's patch for the IBM XLC compiler on Darwin.
+ - Integrated Andreas Tobler's FreeBSD/PowerPC patch.
+ - Don't access the GC thread structure from the restart handler. It's
+ unsafe, since the handler may run too late. (Thanks to Ben Maurer for
+ tracking this down.)
+ - Applied Christian Thalinger's patch to change comment syntax in
+ alpha_mach_dep.S.
+ - Added test for GC_no_dls in GC_dyld_image_add for DARWIN. (Thanks to
+ Juan Jose Garcia Ripoli).
+ - Use LINUX_STACKBOTTOM for Linux/SH and LINUX/ARM. (Thanks to Sugioka
+ Toshinobu and Christian Thalinger.)
+ - Rewrote GC_parse_map_entry. This assumed a fixed column layout of
+ /proc/self/maps on Linux. This ceased to be true about 2 years ago.
+ The old code is probably quite problemetic with -DREDIRECT_MALLOC. It
+ is also used by default for IA64, though I haven't seen actual failures
+ there.
+ - More consistently define HBLKSIZE to 4096 on 64 bit architectures with
+ 4K pages. (Thanks to Andrew Haley.)
+ - With win32 threads, GC_stop_world needs to acquire GC_write_cs. (Thanks
+ to Ben Hutchings for the observation and patch.)
+ - Move up struct callinfo declaration to make gcc 4.0.2. happy.
+
To do:
- The USE_MUNMAP code should really use a separate data structure
indexed by physical page to keep track of time since last use of
+6.5 update:
+I disabled incremental GC on Darwin in this version, since I couldn't
+get gctest to pass when the GC was built as a dynamic library. Building
+with -DMPROTECT_VDB (and threads) on the command line should get you
+back to the old state. - HB
+
+./configure --enable-cplusplus results in a "make check" failure, probably
+because the ::delete override ends up in a separate dl, and Darwin dynamic
+loader semantics appear to be such that this is not really visible to the
+main program, unlike on ELF systems. Someone who understands dynamic
+loading needs to lookat this. For now, gc_cpp.o needs to be linked
+statically, if needed. - HB
+
Darwin/MacOSX Support - December 16, 2003
=========================================
are never honored, eliminating this risk for most,
but not all, applications. This feature is likely to disappear
if/when we find a less disgusting "solution".
+ IN VERSION 6.4 AND LATER, THIS SHOULD BE UNNECESSARY.
The following turn on runtime flags that are also program settable. Checked
only during initialization. We expect that they will usually be set through
To use threads, you need to abide by the following requirements:
-1) You need to use LinuxThreads (which are included in libc6).
+1) You need to use LinuxThreads or NPTL (which are included in libc6).
The collector relies on some implementation details of the LinuxThreads
- package. It is unlikely that this code will work on other
+ package. This code may not work on other
pthread implementations (in particular it will *not* work with
MIT pthreads).
race/deadlock issues we had before.
If solaris_threads are used on an X86 processor with malloc redirected to
-GC_malloc, it is necessary to call GC_thr_init explicitly before forking the
-first thread. (This avoids a deadlock arising from calling GC_thr_init
-with the allocation lock held.)
+GC_malloc a deadlock is likely to result.
It appears that there is a problem in using gc_cpp.h in conjunction with
Solaris threads and Sun's C++ runtime. Apparently the overloaded new operator
/* Newer versions of GNU/Linux define this macro. We
* define it similarly for any ELF systems that don't. */
# ifndef ElfW
-# ifdef FREEBSD
+# if defined(FREEBSD)
# if __ELF_WORD_SIZE == 32
# define ElfW(type) Elf32_##type
# else
# define ElfW(type) Elf32_##type
# else
# define ElfW(type) Elf64_##type
-# endif
+# endif
# endif
# endif
# endif
GC_FirstDLOpenedLinkMap()
{
ElfW(Dyn) *dp;
- struct r_debug *r;
static struct link_map *cachedResult = 0;
if( _DYNAMIC == 0) {
if( cachedResult == 0 ) {
int tag;
for( dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++ ) {
+ /* FIXME: The DT_DEBUG header is not mandated by the */
+ /* ELF spec. This code appears to be dependent on */
+ /* idiosynchracies of older GNU tool chains. If this code */
+ /* fails for you, the real problem is probably that it is */
+ /* being used at all. You should be getting the */
+ /* dl_iterate_phdr version. */
if( tag == DT_DEBUG ) {
struct link_map *lm
= ((struct r_debug *)(dp->d_un.d_ptr))->r_map;
}
for (i = 0; i < needed_sz; i++) {
flags = addr_map[i].pr_mflags;
- if ((flags & (MA_BREAK | MA_STACK | MA_PHYS)) != 0) goto irrelevant;
+ if ((flags & (MA_BREAK | MA_STACK | MA_PHYS
+ | MA_FETCHOP | MA_NOTCACHED)) != 0) goto irrelevant;
if ((flags & (MA_READ | MA_WRITE)) != (MA_READ | MA_WRITE))
goto irrelevant;
/* The latter test is empirically useless in very old Irix */
# define HAVE_REGISTER_MAIN_STATIC_DATA
+ /* The frame buffer testing code is dead in this version. */
+ /* We leave it here temporarily in case the switch to just */
+ /* testing for MEM_IMAGE sections causes un expected */
+ /* problems. */
GC_bool GC_warn_fb = TRUE; /* Warn about traced likely */
/* graphics memory. */
GC_bool GC_disallow_ignore_fb = FALSE;
/* Should [start, start+len) be treated as a frame buffer */
/* and ignored? */
- /* Unfortunately, we currently have no real way to tell */
- /* automatically, and rely largely on user input. */
- /* FIXME: If we had more data on this phenomenon (e.g. */
- /* is start aligned to a MB multiple?) we should be able to */
- /* do better. */
+ /* Unfortunately, we currently are not quite sure how to tell */
+ /* this automatically, and rely largely on user input. */
+ /* We expect that any mapping with type MEM_MAPPED (which */
+ /* apparently excludes library data sections) can be safely */
+ /* ignored. But we're too chicken to do that in this */
+ /* version. */
/* Based on a very limited sample, it appears that: */
- /* - Frame buffer mappings appear as mappings of length */
- /* 2**n MB - 192K. (We guess the 192K can vary a bit.) */
- /* - Have a stating address at best 64K aligned. */
- /* I'd love more information about the mapping, since I */
- /* can't reproduce the problem. */
- static GC_bool is_frame_buffer(ptr_t start, size_t len)
+ /* - Frame buffer mappings appear as mappings of large */
+ /* length, usually a bit less than a power of two. */
+ /* - The definition of "a bit less" in the above cannot */
+ /* be made more precise. */
+ /* - Have a starting address at best 64K aligned. */
+ /* - Have type == MEM_MAPPED. */
+ static GC_bool is_frame_buffer(ptr_t start, size_t len, DWORD tp)
{
static GC_bool initialized = FALSE;
# define MB (1024*1024)
# define DEFAULT_FB_MB 15
# define MIN_FB_MB 3
- if (GC_disallow_ignore_fb) return FALSE;
+ if (GC_disallow_ignore_fb || tp != MEM_MAPPED) return FALSE;
if (!initialized) {
char * ignore_fb_string = GETENV("GC_IGNORE_FB");
&& (protect == PAGE_EXECUTE_READWRITE
|| protect == PAGE_READWRITE)
&& !GC_is_heap_base(buf.AllocationBase)
- && !is_frame_buffer(p, buf.RegionSize)) {
+ /* This used to check for
+ * !is_frame_buffer(p, buf.RegionSize, buf.Type)
+ * instead of just checking for MEM_IMAGE.
+ * If something breaks, change it back. */
+ && buf.Type == MEM_IMAGE) {
# ifdef DEBUG_VIRTUALQUERY
GC_dump_meminfo(&buf);
# endif
static void GC_dyld_image_add(struct mach_header* hdr, unsigned long slide) {
unsigned long start,end,i;
const struct section *sec;
+ if (GC_no_dls) return;
for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
sec = getsectbynamefromheader(
hdr,GC_dyld_sections[i].seg,GC_dyld_sections[i].sect);
- if(sec == NULL || sec->size == 0) continue;
- start = slide + sec->addr;
- end = start + sec->size;
-# ifdef DARWIN_DEBUG
- GC_printf4("Adding section at %p-%p (%lu bytes) from image %s\n",
+ if(sec == NULL || sec->size == 0) continue;
+ start = slide + sec->addr;
+ end = start + sec->size;
+# ifdef DARWIN_DEBUG
+ GC_printf4("Adding section at %p-%p (%lu bytes) from image %s\n",
start,end,sec->size,GC_dyld_name_for_hdr(hdr));
-# endif
+# endif
GC_add_roots((char*)start,(char*)end);
- }
-# ifdef DARWIN_DEBUG
- GC_print_static_roots();
-# endif
+ }
+# ifdef DARWIN_DEBUG
+ GC_print_static_roots();
+# endif
}
/* This should never be called by a thread holding the lock */
if(sec == NULL || sec->size == 0) continue;
start = slide + sec->addr;
end = start + sec->size;
-# ifdef DARWIN_DEBUG
+# ifdef DARWIN_DEBUG
GC_printf4("Removing section at %p-%p (%lu bytes) from image %s\n",
start,end,sec->size,GC_dyld_name_for_hdr(hdr));
# endif
GC_remove_roots((char*)start,(char*)end);
}
-# ifdef DARWIN_DEBUG
- GC_print_static_roots();
-# endif
+# ifdef DARWIN_DEBUG
+ GC_print_static_roots();
+# endif
}
void GC_register_dynamic_libraries() {
static GC_word last_finalizer_notification = 0;
-#ifdef KEEP_BACK_PTRS
-void GC_generate_random_backtrace_no_gc(void);
-#endif
-
void GC_notify_or_invoke_finalizers GC_PROTO((void))
{
/* This is a convenient place to generate backtraces if appropriate, */
/* since that code is not callable with the allocation lock. */
-# ifdef KEEP_BACK_PTRS
- if (GC_backtraces > 0) {
- static word last_back_trace_gc_no = 3; /* Skip early ones. */
- long i;
+# if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH)
+ static word last_back_trace_gc_no = 1; /* Skip first one. */
- LOCK();
- if (GC_gc_no > last_back_trace_gc_no) {
+ if (GC_gc_no > last_back_trace_gc_no) {
+ word i;
+
+# ifdef KEEP_BACK_PTRS
+ LOCK();
/* Stops when GC_gc_no wraps; that's OK. */
- last_back_trace_gc_no = (word)(-1); /* disable others. */
- for (i = 0; i < GC_backtraces; ++i) {
+ last_back_trace_gc_no = (word)(-1); /* disable others. */
+ for (i = 0; i < GC_backtraces; ++i) {
/* FIXME: This tolerates concurrent heap mutation, */
/* which may cause occasional mysterious results. */
/* We need to release the GC lock, since GC_print_callers */
UNLOCK();
GC_generate_random_backtrace_no_gc();
LOCK();
- }
- last_back_trace_gc_no = GC_gc_no;
- }
- UNLOCK();
+ }
+ last_back_trace_gc_no = GC_gc_no;
+ UNLOCK();
+# endif
+# ifdef MAKE_BACK_GRAPH
+ if (GC_print_back_height)
+ GC_print_back_graph_stats();
+# endif
}
# endif
if (GC_finalize_now == 0) return;
{
hdr * result;
- if (!get_index((word) h)) return(FALSE);
+ if (!get_index((word) h)) return(0);
result = alloc_hdr();
SET_HDR(h, result);
# ifdef USE_MUNMAP
# include "gc_config_macros.h"
-# if defined(__STDC__) || defined(__cplusplus)
+# if defined(__STDC__) || defined(__cplusplus) || defined(_AIX)
# define GC_PROTO(args) args
typedef void * GC_PTR;
# define GC_CONST const
/* 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. */
+ /* Initially, GC_free_space_divisor = 3. */
/* Increasing its value will use less space */
/* but more collection time. Decreasing it */
/* will appreciably decrease collection time */
/* the base of the user object. */
/* Return 0 if displaced_pointer doesn't point to within a valid */
/* object. */
+/* Note that a deallocated object in the garbage collected heap */
+/* may be considered valid, even if it has been deallocated with */
+/* GC_free. */
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. */
/* Safer assignment of a pointer to a nonstack location. */
#ifdef GC_DEBUG
-# ifdef __STDC__
+# if defined(__STDC__) || defined(_AIX)
# define GC_PTR_STORE(p, q) \
(*(void **)GC_is_visible(p) = GC_is_valid_displacement(q))
# else
* no-op and the collector self-initializes. But a number of platforms
* make that too hard.
*/
-#if defined(sparc) || defined(__sparc)
+#if (defined(sparc) || defined(__sparc)) && defined(sun)
/*
* If you are planning on putting
* the collector in a SunOS 5 dynamic library, you need to call GC_INIT()
# define GC_INIT() { extern end, etext; \
GC_noop(&end, &etext); }
#else
-# if defined(__CYGWIN32__) && defined(GC_DLL) || defined (_AIX)
+# if defined(__CYGWIN32__) || defined (_AIX)
/*
* Similarly gnu-win32 DLLs need explicit initialization from
* the main program, as does AIX.
*/
-# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); }
+# ifdef __CYGWIN32__
+ extern int _data_start__[];
+ extern int _data_end__[];
+ extern int _bss_start__[];
+ extern int _bss_end__[];
+# define GC_MAX(x,y) ((x) > (y) ? (x) : (y))
+# define GC_MIN(x,y) ((x) < (y) ? (x) : (y))
+# define GC_DATASTART ((GC_PTR) GC_MIN(_data_start__, _bss_start__))
+# define GC_DATAEND ((GC_PTR) GC_MAX(_data_end__, _bss_end__))
+# ifdef GC_DLL
+# define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
+# else
+# define GC_INIT()
+# endif
+# endif
+# if defined(_AIX)
+ extern int _data[], _end[];
+# define GC_DATASTART ((GC_PTR)((ulong)_data))
+# define GC_DATAEND ((GC_PTR)((ulong)_end))
+# define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); }
+# endif
# else
# if defined(__APPLE__) && defined(__MACH__) || defined(GC_WIN32_THREADS)
# define GC_INIT() { GC_init(); }
#define GC_ALLOCATOR_H
-#include "gc.h" // For size_t
+#include "gc.h"
+
+#if defined(__GNUC__)
+# define GC_ATTR_UNUSED __attribute__((unused))
+#else
+# define GC_ATTR_UNUSED
+#endif
/* First some helpers to allow us to dispatch on whether or not a type
* is known to be pointerfree.
}
// __p is not permitted to be a null pointer.
- void deallocate(pointer __p, size_type GC_n)
+ void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
}
// __p is not permitted to be a null pointer.
- void deallocate(pointer __p, size_type GC_n)
+ void deallocate(pointer __p, size_type GC_ATTR_UNUSED GC_n)
{ GC_FREE(__p); }
size_type max_size() const throw()
# define GC_DGUX386_THREADS
# define GC_PTHREADS
# endif
+# if defined(_AIX)
+# define GC_AIX_THREADS
+# define GC_PTHREADS
+# endif
#endif /* GC_THREADS */
#if defined(GC_THREADS) && !defined(GC_PTHREADS) && \
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
+The collector cannot guarantee that it will find all inaccessible
objects. In practice, it finds almost all of them.
enum { GC_word_alignment = GC_byte_alignment/GC_bytes_per_word };
inline void * &GC_obj_link(void * p)
-{ return *(void **)p; }
+{ return *reinterpret_cast<void **>(p); }
// Compute a number of words >= n+1 bytes.
// The +1 allows for pointers one past the end.
} else {
flh = GC_objfreelist_ptr + nwords;
GC_obj_link(p) = *flh;
- memset((char *)p + GC_bytes_per_word, 0,
+ memset(reinterpret_cast<char *>(p) + GC_bytes_per_word, 0,
GC_bytes_per_word * (nwords - 1));
*flh = p;
GC_aux::GC_mem_recently_freed += nwords;
public: \
static T *allocate(size_t n) \
{ return 0 == n? 0 : \
- (T*) alloc::ptr_free_allocate(n * sizeof (T)); } \
+ reinterpret_cast<T*>(alloc::ptr_free_allocate(n * sizeof (T))); } \
static T *allocate(void) \
- { return (T*) alloc::ptr_free_allocate(sizeof (T)); } \
+ { return reinterpret_cast<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) \
/* 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 */
+/* Returns GC_invalid_header instead of 0. All of this saves a branch */
/* in the fast path. */
# define HC_GET_HDR(p, hhdr, source) \
{ \
# define GC_TEST_AND_SET_DEFINED
# endif
# if defined(POWERPC)
+# if CPP_WORDSZ == 64
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ unsigned long oldval;
+ unsigned long temp = 1; /* locked value */
+
+ __asm__ __volatile__(
+ "1:\tldarx %0,0,%3\n" /* load and reserve */
+ "\tcmpdi %0, 0\n" /* if load is */
+ "\tbne 2f\n" /* non-zero, return already set */
+ "\tstdcx. %2,0,%1\n" /* else store conditional */
+ "\tbne- 1b\n" /* retry if lost reservation */
+ "\tsync\n" /* import barrier */
+ "2:\t\n" /* oldval is zero if we set */
+ : "=&r"(oldval), "=p"(addr)
+ : "r"(temp), "1"(addr)
+ : "cr0","memory");
+ return (int)oldval;
+ }
+# else
inline static int GC_test_and_set(volatile unsigned int *addr) {
int oldval;
int temp = 1; /* locked value */
: "cr0","memory");
return oldval;
}
-# define GC_TEST_AND_SET_DEFINED
- inline static void GC_clear(volatile unsigned int *addr) {
- __asm__ __volatile__("eieio" : : : "memory");
- *(addr) = 0;
- }
-# define GC_CLEAR_DEFINED
+# endif
+# define GC_TEST_AND_SET_DEFINED
+ inline static void GC_clear(volatile unsigned int *addr) {
+ __asm__ __volatile__("lwsync" : : : "memory");
+ *(addr) = 0;
+ }
+# define GC_CLEAR_DEFINED
# endif
# if defined(ALPHA)
inline static int GC_test_and_set(volatile unsigned int * addr)
}
# define GC_TEST_AND_SET_DEFINED
# endif /* ARM32 */
+# ifdef CRIS
+ inline static int GC_test_and_set(volatile unsigned int *addr) {
+ /* Ripped from linuxthreads/sysdeps/cris/pt-machine.h. */
+ /* Included with Hans-Peter Nilsson's permission. */
+ register unsigned long int ret;
+
+ /* Note the use of a dummy output of *addr to expose the write.
+ * The memory barrier is to stop *other* writes being moved past
+ * this code.
+ */
+ __asm__ __volatile__("clearf\n"
+ "0:\n\t"
+ "movu.b [%2],%0\n\t"
+ "ax\n\t"
+ "move.b %3,[%2]\n\t"
+ "bwf 0b\n\t"
+ "clearf"
+ : "=&r" (ret), "=m" (*addr)
+ : "r" (addr), "r" ((int) 1), "m" (*addr)
+ : "memory");
+ return ret;
+ }
+# define GC_TEST_AND_SET_DEFINED
+# endif /* CRIS */
# ifdef S390
inline static int GC_test_and_set(volatile unsigned int *addr) {
int ret;
# define GC_test_and_set(addr) test_and_set((void *)addr,1)
# endif
# else
+# include <sgidefs.h>
+# include <mutex.h>
# define GC_test_and_set(addr) __test_and_set32((void *)addr,1)
# define GC_clear(addr) __lock_release(addr);
# define GC_CLEAR_DEFINED
# endif
# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
- && !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS)
+ && !defined(GC_WIN32_THREADS)
# define NO_THREAD (pthread_t)(-1)
# include <pthread.h>
# if defined(PARALLEL_MARK)
# if defined(POWERPC)
# if !defined(GENERIC_COMPARE_AND_SWAP)
+# if CPP_WORDSZ == 64
+ /* 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)
+ {
+ unsigned long result, dummy;
+ __asm__ __volatile__(
+ "1:\tldarx %0,0,%5\n"
+ "\tcmpd %0,%4\n"
+ "\tbne 2f\n"
+ "\tstdcx. %3,0,%2\n"
+ "\tbne- 1b\n"
+ "\tsync\n"
+ "\tli %1, 1\n"
+ "\tb 3f\n"
+ "2:\tli %1, 0\n"
+ "3:\t\n"
+ : "=&r" (dummy), "=r" (result), "=p" (addr)
+ : "r" (new_val), "r" (old), "2"(addr)
+ : "cr0","memory");
+ return (GC_bool) result;
+ }
+# else
/* 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)
: "cr0","memory");
return (GC_bool) result;
}
+# endif
# endif /* !GENERIC_COMPARE_AND_SWAP */
inline static void GC_memory_barrier()
{
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) : "memory");
+# if CPP_WORDSZ == 32
+ __asm__ __volatile__(
+ "addp4 %0=0,%1\n"
+ "mov ar.ccv=%3 ;; cmpxchg4.rel %0=[%0],%2,ar.ccv"
+ : "=&r"(oldval)
+ : "r"(addr), "r"(new_val), "r"(old) : "memory");
+# else
+ __asm__ __volatile__(
+ "mov ar.ccv=%3 ;; cmpxchg8.rel %0=[%1],%2,ar.ccv"
+ : "=r"(oldval)
+ : "r"(addr), "r"(new_val), "r"(old) : "memory");
+# endif
return (oldval == old);
}
# endif /* !GENERIC_COMPARE_AND_SWAP */
extern pthread_t GC_mark_lock_holder;
# endif
# endif /* GC_PTHREADS with linux_threads.c implementation */
-# if defined(GC_IRIX_THREADS)
-# include <pthread.h>
- /* This probably should never be included, but I can't test */
- /* on Irix anymore. */
-# include <mutex.h>
-
- extern volatile unsigned int 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()))
-# 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;
-# endif /* GC_IRIX_THREADS */
# if defined(GC_WIN32_THREADS)
# if defined(GC_PTHREADS)
# include <pthread.h>
/* */
/*********************************/
-#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. */
-struct callinfo;
-void GC_save_callers GC_PROTO((struct callinfo info[NFRAMES]));
-
-void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
-
-#endif
-
#ifdef NEED_CALLINFO
struct callinfo {
word ci_pc; /* Caller, not callee, pc */
};
#endif
+#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. */
+void GC_save_callers GC_PROTO((struct callinfo info[NFRAMES]));
+
+void GC_print_callers GC_PROTO((struct callinfo info[NFRAMES]));
+
+#endif
+
/*********************************/
/* */
#define CPP_MAXOBJBYTES (CPP_HBLKSIZE/2)
#define MAXOBJBYTES ((word)CPP_MAXOBJBYTES)
-#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_HBLKSIZE/2)
+#define CPP_MAXOBJSZ BYTES_TO_WORDS(CPP_MAXOBJBYTES)
#define MAXOBJSZ ((word)CPP_MAXOBJSZ)
# define divHBLKSZ(n) ((n) >> LOG_HBLKSIZE)
char _valid_offsets[VALID_OFFSET_SZ];
/* GC_valid_offsets[i] == TRUE ==> i */
/* is registered as a displacement. */
-# define OFFSET_VALID(displ) \
- (GC_all_interior_pointers || GC_valid_offsets[displ])
char _modws_valid_offsets[sizeof(word)];
/* GC_valid_offsets[i] ==> */
/* GC_modws_valid_offsets[i%sizeof(word)] */
+# define OFFSET_VALID(displ) \
+ (GC_all_interior_pointers || GC_valid_offsets[displ])
# ifdef STUBBORN_ALLOC
page_hash_table _changed_pages;
/* Stubborn object pages that were changes since last call to */
/* 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_inner GC_PROTO((word lw, int k));
+ /* Analogous to the above, but assumes */
+ /* a small object size, and bypasses */
+ /* MERGE_SIZES mechanism. */
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 */
#ifdef KEEP_BACK_PTRS
extern long GC_backtraces;
+ void GC_generate_random_backtrace_no_gc(void);
+#endif
+
+extern GC_bool GC_print_back_height;
+
+#ifdef MAKE_BACK_GRAPH
+ void GC_print_back_graph_stats(void);
#endif
/* Macros used for collector internal allocation. */
# endif
/* And one for FreeBSD: */
-# if defined(__FreeBSD__)
+# if defined(__FreeBSD__) && !defined(FREEBSD)
# define FREEBSD
# endif
# define ARM32
# define mach_type_known
# endif
+# if defined(NETBSD) && defined(__sh__)
+# define SH
+# define mach_type_known
+# endif
# if defined(vax)
# define VAX
# ifdef ultrix
# if defined(nec_ews) || defined(_nec_ews)
# define EWS4800
# endif
-# if !defined(LINUX) && !defined(EWS4800)
-# if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__)
+# if !defined(LINUX) && !defined(EWS4800) && !defined(NETBSD)
+# if defined(ultrix) || defined(__ultrix)
# define ULTRIX
# else
# if defined(_SYSTYPE_SVR4) || defined(SYSTYPE_SVR4) \
# define mach_type_known
# endif
# if defined(sparc) && defined(unix) && !defined(sun) && !defined(linux) \
- && !defined(__OpenBSD__) && !(__NetBSD__)
+ && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
# define SPARC
# define DRSNX
# define mach_type_known
# if defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) \
|| defined(hppa) || defined(__hppa__)
# define HP_PA
-# ifndef LINUX
+# if !defined(LINUX) && !defined(HPUX)
# define HPUX
# endif
# define mach_type_known
# endif
# if defined(__ia64) && defined(_HPUX_SOURCE)
# define IA64
-# define HPUX
+# ifndef HPUX
+# define HPUX
+# endif
# define mach_type_known
# endif
# if defined(__BEOS__) && defined(_X86_)
# define ARM32
# define mach_type_known
# endif
-# if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || defined(powerpc64) || defined(__powerpc64__))
+# if defined(LINUX) && defined(__cris__)
+# ifndef CRIS
+# define CRIS
+# endif
+# define mach_type_known
+# endif
+# if defined(LINUX) && (defined(powerpc) || defined(__powerpc__) || \
+ defined(powerpc64) || defined(__powerpc64__))
+# define POWERPC
+# define mach_type_known
+# endif
+# if defined(FREEBSD) && (defined(powerpc) || defined(__powerpc__))
# define POWERPC
# define mach_type_known
# endif
# define SH
# define mach_type_known
# endif
+# if defined(LINUX) && defined(__m32r__)
+# define M32R
+# define mach_type_known
+# endif
# if defined(__alpha) || defined(__alpha__)
# define ALPHA
# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) && !defined(FREEBSD)
# define MACOS
# define mach_type_known
# endif
-# if defined(macosx) || \
- defined(__APPLE__) && defined(__MACH__) && defined(__ppc__)
-# define DARWIN
+# if defined(macosx) || (defined(__APPLE__) && defined(__MACH__))
+# define DARWIN
+# if defined(__ppc__) || defined(__ppc64__)
# define POWERPC
# define mach_type_known
-# endif
-# if defined(__APPLE__) && defined(__MACH__) && defined(__i386__)
-# define DARWIN
+# elif defined(__i386__)
# define I386
--> Not really supported, but at least we recognize it.
+# endif
# endif
# if defined(NeXT) && defined(mc68000)
# define M68K
# define X86_64
# define mach_type_known
# endif
+# if defined(FREEBSD) && defined(__sparc__)
+# define SPARC
+# define mach_type_known
+#endif
# if defined(bsdi) && (defined(i386) || defined(__i386__))
# define I386
# define BSDI
/* POWERPC ==> IBM/Apple PowerPC */
/* (MACOS(<=9),DARWIN(incl.MACOSX),*/
/* LINUX, NETBSD, NOSYS variants) */
+ /* Handles 32 and 64-bit variants. */
+ /* AIX should be handled here, but */
+ /* that's called an RS6000. */
+ /* CRIS ==> Axis Etrax */
+ /* M32R ==> Renesas M32R */
/*
* For each architecture and OS, the following need to be defined:
*
- * CPP_WORD_SZ is a simple integer constant representing the word size.
+ * CPP_WORDSZ 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 also assume CPP_WORDSZ 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.)
+ * 32 bit pointers should use CPP_WORDSZ of 32, not 64. Default is 32.)
*
* MACH_TYPE is a string representation of the machine type.
* OS_TYPE is analogous for the OS.
* DATAEND, if not `end' where `end' is defined as ``extern int end[];''.
* RTH suggests gaining access to linker script synth'd values with
* this idiom instead of `&end' where `end' is defined as ``extern int end;'' .
+ * Otherwise, ``GCC will assume these are in .sdata/.sbss'' and it will, e.g.,
+ * cause failures on alpha*-*-* with ``-msmall-data or -fpic'' or mips-*-*
+ * without any special options.
*
* ALIGN_DOUBLE of GC_malloc should return blocks aligned to twice
* the pointer size.
*/
# if defined(__GNUC__) && ((__GNUC__ >= 3) || \
(__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \
- && !defined(__INTEL_COMPILER)
+ && !defined(__INTEL_COMPILER) \
+ && !defined(__PATHCC__)
# define HAVE_BUILTIN_UNWIND_INIT
# endif
# endif
# endif
-# ifdef POWERPC
+# if defined(POWERPC)
# define MACH_TYPE "POWERPC"
# ifdef MACOS
# define ALIGNMENT 2 /* Still necessary? Could it be 4? */
# define DATAEND /* not needed */
# endif
# ifdef LINUX
-# if (defined (powerpc64) || defined(__powerpc64__))
+# if defined(__powerpc64__)
# define ALIGNMENT 8
# define CPP_WORDSZ 64
+# ifndef HBLKSIZE
+# define HBLKSIZE 4096
+# endif
# else
-# define ALIGNMENT 4 /* Guess. Can someone verify? */
- /* This was 2, but that didn't sound right. */
+# define ALIGNMENT 4
# endif
# define OS_TYPE "LINUX"
/* HEURISTIC1 has been reliably reported to fail for a 32-bit */
# define DATAEND (_end)
# endif
# ifdef DARWIN
-# define ALIGNMENT 4
+# ifdef __ppc64__
+# define ALIGNMENT 8
+# define CPP_WORDSZ 64
+# else
+# define ALIGNMENT 4
+# endif
# define OS_TYPE "DARWIN"
# define DYNAMIC_LOADING
/* XXX: see get_end(3), get_etext() and get_end() should not be used.
# define USE_MMAP_ANON
# define USE_ASM_PUSH_REGS
/* This is potentially buggy. It needs more testing. See the comments in
- os_dep.c */
-# define MPROTECT_VDB
+ os_dep.c. It relies on threads to track writes. */
+# ifdef GC_DARWIN_THREADS
+/* # define MPROTECT_VDB -- diabled for now. May work for some apps. */
+# endif
# include <unistd.h>
# define GETPAGESIZE() getpagesize()
# if defined(USE_PPC_PREFETCH) && defined(__GNUC__)
should be looked into some more */
# define NO_PTHREAD_TRYLOCK
# endif
+# ifdef FREEBSD
+# define ALIGNMENT 4
+# define OS_TYPE "FREEBSD"
+# ifndef GC_FREEBSD_THREADS
+# define MPROTECT_VDB
+# endif
+# define SIG_SUSPEND SIGUSR1
+# define SIG_THR_RESTART SIGUSR2
+# define FREEBSD_STACKBOTTOM
+# ifdef __ELF__
+# define DYNAMIC_LOADING
+# endif
+ extern char etext[];
+ extern char * GC_FreeBSDGetDataStart();
+# define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
+# endif
# ifdef NETBSD
# define ALIGNMENT 4
# define OS_TYPE "NETBSD"
extern ptr_t GC_SysVGetDataStart();
# ifdef __arch64__
# define DATASTART GC_SysVGetDataStart(0x100000, _etext)
- /* libc_stack_end is not set reliably for sparc64 */
-# define STACKBOTTOM ((ptr_t) 0x80000000000ULL)
# else
# define DATASTART GC_SysVGetDataStart(0x10000, _etext)
-# define LINUX_STACKBOTTOM
# endif
+# define LINUX_STACKBOTTOM
# endif
# ifdef OPENBSD
# define OS_TYPE "OPENBSD"
# define DATASTART ((ptr_t)(etext))
# endif
# endif
+# ifdef FREEBSD
+# define OS_TYPE "FREEBSD"
+# define SIG_SUSPEND SIGUSR1
+# define SIG_THR_RESTART SIGUSR2
+# define FREEBSD_STACKBOTTOM
+# ifdef __ELF__
+# define DYNAMIC_LOADING
+# endif
+ extern char etext[];
+ extern char edata[];
+ extern char end[];
+# define NEED_FIND_LIMIT
+# define DATASTART ((ptr_t)(&etext))
+# define DATAEND (GC_find_limit (DATASTART, TRUE))
+# define DATASTART2 ((ptr_t)(&edata))
+# define DATAEND2 ((ptr_t)(&end))
+# endif
# endif
# ifdef I386
# 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. */
-# ifndef MAX
-# define MAX(x,y) ((x) > (y) ? (x) : (y))
-# endif
-# ifndef MIN
-# define MIN(x,y) ((x) < (y) ? (x) : (y))
-# endif
-# define DATASTART ((ptr_t) MIN(_data_start__, _bss_start__))
-# define DATAEND ((ptr_t) MAX(_data_end__, _bss_end__))
+# define DATASTART ((ptr_t)GC_DATASTART) /* From gc.h */
+# define DATAEND ((ptr_t)GC_DATAEND)
# undef STACK_GRAN
# define STACK_GRAN 0x10000
# define HEURISTIC1
# define DATAEND /* not needed */
# endif
# if defined(NETBSD)
- /* This also checked for __MIPSEL__ . Why? NETBSD recognition */
- /* should be handled at the top of the file. */
# define ALIGNMENT 4
# define OS_TYPE "NETBSD"
# define HEURISTIC2
# define CPP_WORDSZ 32
# define STACKBOTTOM ((ptr_t)((ulong)&errno))
# endif
+# define USE_MMAP
+# define USE_MMAP_ANON
/* From AIX linker man page:
_text Specifies the first location of the program.
_etext Specifies the first location after the program.
# endif
# ifdef LINUX
# define OS_TYPE "LINUX"
-# define STACKBOTTOM ((ptr_t) 0x120000000)
+# define LINUX_STACKBOTTOM
# ifdef __ELF__
# define SEARCH_FOR_DATA_START
# define DYNAMIC_LOADING
# define USE_GENERIC_PUSH_REGS
# ifdef UTS4
# define OS_TYPE "UTS4"
- extern int etext[];
+ extern int etext[];
extern int _etext[];
extern int _end[];
extern ptr_t GC_SysVGetDataStart();
# define MACH_TYPE "S390"
# define USE_GENERIC_PUSH_REGS
# ifndef __s390x__
-# define ALIGNMENT 4
-# define CPP_WORDSZ 32
+# define ALIGNMENT 4
+# define CPP_WORDSZ 32
# else
-# define ALIGNMENT 8
-# define CPP_WORDSZ 64
-# define HBLKSIZE 4096
+# define ALIGNMENT 8
+# define CPP_WORDSZ 64
+# endif
+# ifndef HBLKSIZE
+# define HBLKSIZE 4096
# endif
# ifdef LINUX
# define OS_TYPE "LINUX"
# define LINUX_STACKBOTTOM
# define DYNAMIC_LOADING
- extern int __data_start[];
+ extern int __data_start[];
# define DATASTART ((ptr_t)(__data_start))
extern int _end[];
# define DATAEND (_end)
# endif
#endif
+# ifdef CRIS
+# define MACH_TYPE "CRIS"
+# define CPP_WORDSZ 32
+# define ALIGNMENT 1
+# define OS_TYPE "LINUX"
+# define DYNAMIC_LOADING
+# define LINUX_STACKBOTTOM
+# define USE_GENERIC_PUSH_REGS
+# define SEARCH_FOR_DATA_START
+ extern int _end[];
+# define DATAEND (_end)
+# endif
+
# ifdef SH
# define MACH_TYPE "SH"
# define ALIGNMENT 4
# endif
# ifdef LINUX
# define OS_TYPE "LINUX"
-# define STACKBOTTOM ((ptr_t) 0x7c000000)
+# define LINUX_STACKBOTTOM
# define USE_GENERIC_PUSH_REGS
# define DYNAMIC_LOADING
# define SEARCH_FOR_DATA_START
extern int _end[];
# define DATAEND (_end)
# endif
+# ifdef NETBSD
+# define OS_TYPE "NETBSD"
+# define HEURISTIC2
+# define DATASTART GC_data_start
+# define USE_GENERIC_PUSH_REGS
+# define DYNAMIC_LOADING
+# endif
# endif
# ifdef SH4
# define DATAEND /* not needed */
# endif
+# ifdef M32R
+# define CPP_WORDSZ 32
+# define MACH_TYPE "M32R"
+# define ALIGNMENT 4
+# ifdef LINUX
+# define OS_TYPE "LINUX"
+# define LINUX_STACKBOTTOM
+# undef STACK_GRAN
+# define STACK_GRAN 0x10000000
+# define USE_GENERIC_PUSH_REGS
+# define DYNAMIC_LOADING
+# define SEARCH_FOR_DATA_START
+ extern int _end[];
+# define DATAEND (_end)
+# endif
+# endif
+
# ifdef X86_64
# define MACH_TYPE "X86_64"
# define ALIGNMENT 8
# define THREADS
# endif
-# if defined(HP_PA) || defined(M88K) || defined(POWERPC) && !defined(DARWIN) \
- || defined(LINT) || defined(MSWINCE) || defined(ARM32) \
+# if defined(HP_PA) || defined(M88K) \
+ || defined(POWERPC) && !defined(DARWIN) \
+ || defined(LINT) || defined(MSWINCE) || defined(ARM32) || defined(CRIS) \
|| (defined(I386) && defined(__LCC__))
/* Use setjmp based hack to mark from callee-save registers. */
/* The define should move to the individual platform */
# else
# if defined(AMIGA) && defined(GC_AMIGA_FASTALLOC)
extern void *GC_amiga_get_mem(size_t size);
- define GET_MEM(bytes) HBLKPTR((size_t) \
+# define GET_MEM(bytes) HBLKPTR((size_t) \
GC_amiga_get_mem((size_t)bytes + GC_page_size) \
+ GC_page_size-1)
# else
#endif /* GC_PRIVATE_H */
+#if defined(_AIX) && !defined(__GNUC__) && !defined(__STDC__)
+ /* IBMs xlc compiler doesn't appear to follow the convention of */
+ /* defining __STDC__ to be zero in extended mode. */
+# define __STDC__ 0
+#endif
+
# endif /* GCCONFIG_H */
# include "private/gc_priv.h"
# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
- && !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS)
+ && !defined(GC_WIN32_THREADS)
#if defined(GC_DARWIN_THREADS)
# include "private/darwin_stop_world.h"
# endif
# endif
+#if defined(RS6000) || defined(POWERPC)
+# include <ucontext.h>
+#endif
+
#if defined(__MWERKS__) && !defined(POWERPC)
asm static void PushMacRegisters()
}
#endif /* !USE_GENERIC_PUSH_REGS && !USE_ASM_PUSH_REGS */
+void GC_with_callee_saves_pushed(fn, arg)
+void (*fn)();
+ptr_t arg;
+{
+ word dummy;
+
+# if defined(USE_GENERIC_PUSH_REGS)
+# ifdef HAVE_BUILTIN_UNWIND_INIT
+ /* This was suggested by Richard Henderson as the way to */
+ /* force callee-save registers and register windows onto */
+ /* the stack. */
+ __builtin_unwind_init();
+# else /* !HAVE_BUILTIN_UNWIND_INIT */
+# if defined(RS6000) || defined(POWERPC)
+ /* FIXME: RS6000 means AIX. */
+ /* This should probably be used in all Posix/non-gcc */
+ /* settings. We defer that change to minimize risk. */
+ ucontext_t ctxt;
+ getcontext(&ctxt);
+# else
+ /* Generic code */
+ /* The idea is due to Parag Patel at HP. */
+ /* We're not sure whether he would like */
+ /* to be he acknowledged for it or not. */
+ jmp_buf regs;
+ register word * i = (word *) regs;
+ register ptr_t lim = (ptr_t)(regs) + (sizeof regs);
+
+ /* Setjmp doesn't always clear all of the buffer. */
+ /* That tends to preserve garbage. Clear it. */
+ for (; (char *)i < lim; i++) {
+ *i = 0;
+ }
+# if defined(MSWIN32) || defined(MSWINCE) \
+ || defined(UTS4) || defined(LINUX) || defined(EWS4800)
+ (void) setjmp(regs);
+# else
+ (void) _setjmp(regs);
+ /* We don't want to mess with signals. According to */
+ /* SUSV3, setjmp() may or may not save signal mask. */
+ /* _setjmp won't, but is less portable. */
+# endif
+# endif /* !AIX ... */
+# endif /* !HAVE_BUILTIN_UNWIND_INIT */
+# else
+# if defined(PTHREADS) && !defined(MSWIN32) /* !USE_GENERIC_PUSH_REGS */
+ /* We may still need this to save thread contexts. */
+ ucontext_t ctxt;
+ getcontext(&ctxt);
+# else /* Shouldn't be needed */
+ ABORT("Unexpected call to GC_with_callee_saves_pushed");
+# endif
+# endif
+# if (defined(SPARC) && !defined(HAVE_BUILTIN_UNWIND_INIT)) \
+ || defined(IA64)
+ /* On a register window machine, we need to save register */
+ /* contents on the stack for this to work. The setjmp */
+ /* is probably not needed on SPARC, since pointers are */
+ /* only stored in windowed or scratch registers. It is */
+ /* needed on IA64, since some non-windowed registers are */
+ /* preserved. */
+ {
+ GC_save_regs_ret_val = GC_save_regs_in_stack();
+ /* On IA64 gcc, could use __builtin_ia64_flushrs() and */
+ /* __builtin_ia64_flushrs(). The latter will be done */
+ /* implicitly by __builtin_unwind_init() for gcc3.0.1 */
+ /* and later. */
+ }
+# endif
+ fn(arg);
+ /* Strongly discourage the compiler from treating the above */
+ /* as a tail-call, since that would pop the register */
+ /* contents before we get a chance to look at them. */
+ GC_noop1((word)(&dummy));
+}
+
#if defined(USE_GENERIC_PUSH_REGS)
void GC_generic_push_regs(cold_gc_frame)
ptr_t cold_gc_frame;
{
- {
- word dummy;
-
-# ifdef HAVE_BUILTIN_UNWIND_INIT
- /* This was suggested by Richard Henderson as the way to */
- /* force callee-save registers and register windows onto */
- /* the stack. */
- __builtin_unwind_init();
-# else /* !HAVE_BUILTIN_UNWIND_INIT */
- /* Generic code */
- /* The idea is due to Parag Patel at HP. */
- /* We're not sure whether he would like */
- /* to be he acknowledged for it or not. */
- jmp_buf regs;
- register word * i = (word *) regs;
- register ptr_t lim = (ptr_t)(regs) + (sizeof regs);
-
- /* Setjmp doesn't always clear all of the buffer. */
- /* That tends to preserve garbage. Clear it. */
- for (; (char *)i < lim; i++) {
- *i = 0;
- }
-# if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \
- || defined(UTS4) || defined(LINUX) || defined(EWS4800)
- (void) setjmp(regs);
-# else
- (void) _setjmp(regs);
- /* We don't want to mess with signals. According to */
- /* SUSV3, setjmp() may or may not save signal mask. */
- /* _setjmp won't, but is less portable. */
-# endif
-# endif /* !HAVE_BUILTIN_UNWIND_INIT */
-# if (defined(SPARC) && !defined(HAVE_BUILTIN_UNWIND_INIT)) \
- || defined(IA64)
- /* On a register window machine, we need to save register */
- /* contents on the stack for this to work. The setjmp */
- /* is probably not needed on SPARC, since pointers are */
- /* only stored in windowed or scratch registers. It is */
- /* needed on IA64, since some non-windowed registers are */
- /* preserved. */
- {
- GC_save_regs_ret_val = GC_save_regs_in_stack();
- /* On IA64 gcc, could use __builtin_ia64_flushrs() and */
- /* __builtin_ia64_flushrs(). The latter will be done */
- /* implicitly by __builtin_unwind_init() for gcc3.0.1 */
- /* and later. */
- }
-# endif
- GC_push_current_stack(cold_gc_frame);
- /* Strongly discourage the compiler from treating the above */
- /* as a tail-call, since that would pop the register */
- /* contents before we get a chance to look at them. */
- GC_noop1((word)(&dummy));
- }
+ GC_with_callee_saves_pushed(GC_push_current_stack, cold_gc_frame);
}
#endif /* USE_GENERIC_PUSH_REGS */
/* the stack. Return sp. */
# ifdef SPARC
asm(" .seg \"text\"");
-# if defined(SVR4) || defined(NETBSD)
+# if defined(SVR4) || defined(NETBSD) || defined(FREEBSD)
asm(" .globl GC_save_regs_in_stack");
asm("GC_save_regs_in_stack:");
asm(" .type GC_save_regs_in_stack,#function");
# endif /* REDIRECT_REALLOC */
-/* The same thing, except caller does not hold allocation lock. */
+/* Allocate memory such that only pointers to near the */
+/* beginning of the object are considered. */
/* We avoid holding allocation lock while we clear memory. */
ptr_t GC_generic_malloc_ignore_off_page(lb, k)
register size_t lb;
++top;
top -> mse_descr = descr;
top -> mse_start = p -> mse_start;
- GC_ASSERT( top -> mse_descr & GC_DS_TAGS != GC_DS_LENGTH ||
- top -> mse_descr < GC_greatest_plausible_heap_addr
- - GC_least_plausible_heap_addr);
+ GC_ASSERT( (top -> mse_descr & GC_DS_TAGS) != GC_DS_LENGTH ||
+ top -> mse_descr < (ptr_t)GC_greatest_plausible_heap_addr
+ - (ptr_t)GC_least_plausible_heap_addr);
/* If this is a big object, count it as */
/* size/256 + 1 objects. */
++i;
ptr_t bottom;
ptr_t top;
{
- word * b = (word *)(((long) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
- word * t = (word *)(((long) top) & ~(ALIGNMENT-1));
+ word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
+ word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
register word *p;
register word q;
register word *lim;
{
register int sz = hhdr -> hb_sz;
- if (sz < MAXOBJSZ) {
+ if (sz <= MAXOBJSZ) {
return(GC_page_was_dirty(h));
} else {
register ptr_t p = (ptr_t)h;
ptr_t GC_approx_sp()
{
- word dummy;
+ VOLATILE word dummy;
+ dummy = 42; /* Force stack to grow if necessary. Otherwise the */
+ /* later accesses might cause the kernel to think we're */
+ /* doing something wrong. */
# ifdef _MSC_VER
# pragma warning(disable:4172)
# endif
byte_sz = WORDS_TO_BYTES(word_sz);
if (GC_all_interior_pointers) {
/* We need one extra byte; don't fill in GC_size_map[byte_sz] */
- byte_sz--;
+ byte_sz -= EXTRA_BYTES;
}
for (j = low_limit; j <= byte_sz; j++) GC_size_map[j] = word_sz;
void GC_enable_incremental GC_PROTO(())
{
-# if !defined(SMALL_CONFIG)
+# if !defined(SMALL_CONFIG) && !defined(KEEP_BACK_PTRS)
+ /* If we are keeping back pointers, the GC itself dirties all */
+ /* pages on which objects have been marked, making */
+ /* incremental GC pointless. */
if (!GC_find_leak) {
DCL_LOCK_STATE;
# include <signal.h>
# endif
+#if defined(LINUX) || defined(LINUX_STACKBOTTOM)
+# include <ctype.h>
+#endif
+
/* Blatantly OS dependent routines, except for those that are related */
/* to dynamic loading. */
# define NEED_FIND_LIMIT
# endif
-#if defined(FREEBSD) && defined(I386)
+#if defined(FREEBSD) && (defined(I386) || defined(powerpc) || defined(__powerpc__))
# include <machine/trap.h>
# if !defined(PCR)
# define NEED_FIND_LIMIT
// XXXXXXXX-XXXXXXXX r-xp 00000000 30:05 260537 name of mapping...\n
// ^^^^^^^^ ^^^^^^^^ ^^^^ ^^
// start end prot maj_dev
-// 0 9 18 32
-//
-// For 64 bit ABIs:
-// 0 17 34 56
//
-// The parser is called with a pointer to the entry and the return value
-// is either NULL or is advanced to the next entry(the byte after the
-// trailing '\n'.)
+// Note that since about auguat 2003 kernels, the columns no longer have
+// fixed offsets on 64-bit kernels. Hence we no longer rely on fixed offsets
+// anywhere, which is safer anyway.
//
-#if CPP_WORDSZ == 32
-# define OFFSET_MAP_START 0
-# define OFFSET_MAP_END 9
-# define OFFSET_MAP_PROT 18
-# define OFFSET_MAP_MAJDEV 32
-# define ADDR_WIDTH 8
-#endif
-
-#if CPP_WORDSZ == 64
-# define OFFSET_MAP_START 0
-# define OFFSET_MAP_END 17
-# define OFFSET_MAP_PROT 34
-# define OFFSET_MAP_MAJDEV 56
-# define ADDR_WIDTH 16
-#endif
/*
* Assign various fields of the first line in buf_ptr to *start, *end,
char *GC_parse_map_entry(char *buf_ptr, word *start, word *end,
char *prot_buf, unsigned int *maj_dev)
{
- int i;
- char *tok;
+ char *start_start, *end_start, *prot_start, *maj_dev_start;
+ char *p;
+ char *endp;
if (buf_ptr == NULL || *buf_ptr == '\0') {
return NULL;
}
- memcpy(prot_buf, buf_ptr+OFFSET_MAP_PROT, 4);
- /* do the protections first. */
+ p = buf_ptr;
+ while (isspace(*p)) ++p;
+ start_start = p;
+ GC_ASSERT(isxdigit(*start_start));
+ *start = strtoul(start_start, &endp, 16); p = endp;
+ GC_ASSERT(*p=='-');
+
+ ++p;
+ end_start = p;
+ GC_ASSERT(isxdigit(*end_start));
+ *end = strtoul(end_start, &endp, 16); p = endp;
+ GC_ASSERT(isspace(*p));
+
+ while (isspace(*p)) ++p;
+ prot_start = p;
+ GC_ASSERT(*prot_start == 'r' || *prot_start == '-');
+ memcpy(prot_buf, prot_start, 4);
prot_buf[4] = '\0';
-
- if (prot_buf[1] == 'w') {/* we can skip all of this if it's not writable. */
-
- tok = buf_ptr;
- buf_ptr[OFFSET_MAP_START+ADDR_WIDTH] = '\0';
- *start = strtoul(tok, NULL, 16);
-
- tok = buf_ptr+OFFSET_MAP_END;
- buf_ptr[OFFSET_MAP_END+ADDR_WIDTH] = '\0';
- *end = strtoul(tok, NULL, 16);
-
- buf_ptr += OFFSET_MAP_MAJDEV;
- tok = buf_ptr;
- while (*buf_ptr != ':') buf_ptr++;
- *buf_ptr++ = '\0';
- *maj_dev = strtoul(tok, NULL, 16);
+ if (prot_buf[1] == 'w') {/* we can skip the rest if it's not writable. */
+ /* Skip past protection field to offset field */
+ while (!isspace(*p)) ++p; while (isspace(*p)) ++p;
+ GC_ASSERT(isxdigit(*p));
+ /* Skip past offset field, which we ignore */
+ while (!isspace(*p)) ++p; while (isspace(*p)) ++p;
+ maj_dev_start = p;
+ GC_ASSERT(isxdigit(*maj_dev_start));
+ *maj_dev = strtoul(maj_dev_start, NULL, 16);
}
- while (*buf_ptr && *buf_ptr++ != '\n');
+ while (*p && *p++ != '\n');
- return buf_ptr;
+ return p;
}
#endif /* Need to parse /proc/self/maps. */
# if defined(SUNOS5SIGS) || defined(IRIX5) || defined(OSF1) \
|| defined(HURD) || defined(NETBSD) || defined(FREEBSD)
static struct sigaction old_segv_act;
-# if defined(_sigargs) /* !Irix6.x */ || defined(HPUX) \
- || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
+# if defined(IRIX5) || defined(HPUX) \
+ || defined(HURD) || defined(NETBSD)
static struct sigaction old_bus_act;
# endif
# else
/* and setting a handler at the same time. */
(void) sigaction(SIGSEGV, 0, &old_segv_act);
(void) sigaction(SIGSEGV, &act, 0);
+ (void) sigaction(SIGBUS, 0, &old_bus_act);
+ (void) sigaction(SIGBUS, &act, 0);
# else
(void) sigaction(SIGSEGV, &act, &old_segv_act);
-# if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \
- || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
+# if defined(IRIX5) \
+ || defined(HPUX) || defined(HURD) || defined(NETBSD)
/* Under Irix 5.x or HP/UX, we may get SIGBUS. */
/* Pthreads doesn't exist under Irix 5.x, so we */
/* don't have to worry in the threads case. */
# if defined(SUNOS5SIGS) || defined(IRIX5) \
|| defined(OSF1) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
(void) sigaction(SIGSEGV, &old_segv_act, 0);
-# if defined(IRIX5) && defined(_sigargs) /* Irix 5.x, not 6.x */ \
- || defined(HPUX) || defined(HURD) || defined(NETBSD) || defined(FREEBSD)
+# if defined(IRIX5) \
+ || defined(HPUX) || defined(HURD) || defined(NETBSD)
(void) sigaction(SIGBUS, &old_bus_act, 0);
# endif
# else
#include <sys/types.h>
#include <sys/stat.h>
-#include <ctype.h>
# define STAT_SKIP 27 /* Number of fields preceding startstack */
/* field in /proc/self/stat */
+#ifdef USE_LIBC_PRIVATES
# pragma weak __libc_stack_end
extern ptr_t __libc_stack_end;
+#endif
# ifdef IA64
/* Try to read the backing store base from /proc/self/maps. */
return GC_apply_to_maps(backing_store_base_from_maps);
}
-# pragma weak __libc_ia64_register_backing_store_base
- extern ptr_t __libc_ia64_register_backing_store_base;
+# ifdef USE_LIBC_PRIVATES
+# pragma weak __libc_ia64_register_backing_store_base
+ extern ptr_t __libc_ia64_register_backing_store_base;
+# endif
ptr_t GC_get_register_stack_base(void)
{
- if (0 != &__libc_ia64_register_backing_store_base
- && 0 != __libc_ia64_register_backing_store_base) {
- /* Glibc 2.2.4 has a bug such that for dynamically linked */
- /* executables __libc_ia64_register_backing_store_base is */
- /* defined but uninitialized during constructor calls. */
- /* Hence we check for both nonzero address and value. */
- return __libc_ia64_register_backing_store_base;
- } else {
- word result = backing_store_base_from_proc();
- if (0 == result) {
+# ifdef USE_LIBC_PRIVATES
+ if (0 != &__libc_ia64_register_backing_store_base
+ && 0 != __libc_ia64_register_backing_store_base) {
+ /* Glibc 2.2.4 has a bug such that for dynamically linked */
+ /* executables __libc_ia64_register_backing_store_base is */
+ /* defined but uninitialized during constructor calls. */
+ /* Hence we check for both nonzero address and value. */
+ return __libc_ia64_register_backing_store_base;
+ }
+# endif
+ word result = backing_store_base_from_proc();
+ if (0 == result) {
/* Use dumb heuristics. Works only for default configuration. */
result = (word)GC_stackbottom - BACKING_STORE_DISPLACEMENT;
result += BACKING_STORE_ALIGNMENT - 1;
result &= ~(BACKING_STORE_ALIGNMENT - 1);
/* Verify that it's at least readable. If not, we goofed. */
GC_noop1(*(word *)result);
- }
- return (ptr_t)result;
}
+ return (ptr_t)result;
}
# endif
+void *GC_set_stackbottom = NULL;
+
ptr_t GC_linux_stack_base(void)
{
/* We read the stack base value from /proc/self/stat. We do this */
/* since the correct value of __libc_stack_end never */
/* becomes visible to us. The second test works around */
/* this. */
-#if USE_LIBC_PRIVATE_SYMBOLS
+# ifdef USE_LIBC_PRIVATES
if (0 != &__libc_stack_end && 0 != __libc_stack_end ) {
# ifdef IA64
/* Some versions of glibc set the address 16 bytes too */
} /* Otherwise it's not safe to add 16 bytes and we fall */
/* back to using /proc. */
# else
+# ifdef SPARC
+ /* Older versions of glibc for 64-bit Sparc do not set
+ * this variable correctly, it gets set to either zero
+ * or one.
+ */
+ if (__libc_stack_end != (ptr_t) (unsigned long)0x1)
+ return __libc_stack_end;
+# else
return __libc_stack_end;
+# endif
# endif
}
-#endif
+# endif
f = open("/proc/self/stat", O_RDONLY);
if (f < 0 || STAT_READ(f, stat_buf, STAT_BUF_SIZE) < 2 * STAT_SKIP) {
ABORT("Couldn't read /proc/self/stat");
}
# endif
-# if defined(FREEBSD) && defined(I386) && !defined(PCR)
+# if defined(FREEBSD) && (defined(I386) || defined(powerpc) || defined(__powerpc__)) && !defined(PCR)
/* Its unclear whether this should be identical to the above, or */
/* whether it should apply to non-X86 architectures. */
/* For now we don't assume that there is always an empty page after */
# endif
-# ifdef RS6000
+# if 0 && defined(RS6000) /* We now use mmap */
/* The compiler seems to generate speculative reads one past the end of */
/* an allocated object. Hence we need to make sure that the page */
/* following the last heap page is also mapped. */
# if defined(ALPHA) || defined(M68K)
typedef void (* REAL_SIG_PF)(int, int, s_c *);
# else
-# if defined(IA64) || defined(HP_PA)
+# if defined(IA64) || defined(HP_PA) || defined(X86_64)
typedef void (* REAL_SIG_PF)(int, siginfo_t *, s_c *);
+ /* FIXME: */
+ /* According to SUSV3, the last argument should have type */
+ /* void * or ucontext_t * */
# else
typedef void (* REAL_SIG_PF)(int, s_c);
# endif
# endif
# ifdef FREEBSD
# define SIG_OK (sig == SIGBUS)
-# define CODE_OK (code == BUS_PAGE_FAULT)
+# define CODE_OK TRUE
# endif
# endif /* SUNOS4 || (FREEBSD && !SUNOS5SIGS) */
# if defined(ALPHA) || defined(M68K)
void GC_write_fault_handler(int sig, int code, s_c * sc)
# else
-# if defined(IA64) || defined(HP_PA)
+# if defined(IA64) || defined(HP_PA) || defined(X86_64)
void GC_write_fault_handler(int sig, siginfo_t * si, s_c * scp)
# else
# if defined(ARM32)
char * addr = (char *) (scp -> si_addr);
# endif
# ifdef LINUX
-# if defined(I386) || defined (X86_64)
+# if defined(I386)
char * addr = (char *) (sc.cr2);
# else
# if defined(M68K)
# ifdef ALPHA
char * addr = get_fault_addr(sc);
# else
-# if defined(IA64) || defined(HP_PA)
+# if defined(IA64) || defined(HP_PA) || defined(X86_64)
char * addr = si -> si_addr;
/* I believe this is claimed to work on all platforms for */
/* Linux 2.3.47 and later. Hopefully we don't have to */
# if defined(ARM32)
char * addr = (char *)sc.fault_address;
# else
- --> architecture not supported
+# if defined(CRIS)
+ char * addr = (char *)sc.regs.csraddr;
+# else
+ --> architecture not supported
+# endif
# endif
# endif
# endif
# if defined(ALPHA) || defined(M68K)
(*(REAL_SIG_PF)old_handler) (sig, code, sc);
# else
-# if defined(IA64) || defined(HP_PA)
+# if defined(IA64) || defined(HP_PA) || defined(X86_64)
(*(REAL_SIG_PF)old_handler) (sig, si, scp);
# else
(*(REAL_SIG_PF)old_handler) (sig, sc);
struct sigaction act, oldact;
/* We should probably specify SA_SIGINFO for Linux, and handle */
/* the different architectures more uniformly. */
-# if defined(IRIX5) || defined(LINUX) || defined(OSF1) || defined(HURD)
+# if defined(IRIX5) || defined(LINUX) && !defined(X86_64) \
+ || defined(OSF1) || defined(HURD)
act.sa_flags = SA_RESTART;
act.sa_handler = (SIG_PF)GC_write_fault_handler;
# else
#include <sys/procfs.h>
#include <sys/stat.h>
-#define INITIAL_BUF_SZ 4096
+#define INITIAL_BUF_SZ 16384
word GC_proc_buf_size = INITIAL_BUF_SZ;
char *GC_proc_buf;
#define MAX_EXCEPTION_PORTS 16
-static mach_port_t GC_task_self;
-
static struct {
mach_msg_type_number_t count;
exception_mask_t masks[MAX_EXCEPTION_PORTS];
exception_behavior_t behavior;
thread_state_flavor_t flavor;
- thread_state_data_t thread_state;
+ thread_state_t thread_state;
mach_msg_type_number_t thread_state_count = THREAD_STATE_MAX;
for(i=0;i<GC_old_exc_ports.count;i++)
char *addr;
struct hblk *h;
int i;
-#ifdef POWERPC
- thread_state_flavor_t flavor = PPC_EXCEPTION_STATE;
- mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE_COUNT;
- ppc_exception_state_t exc_state;
-#else
+# if defined(POWERPC)
+# if CPP_WORDSZ == 32
+ thread_state_flavor_t flavor = PPC_EXCEPTION_STATE;
+ mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE_COUNT;
+ ppc_exception_state_t exc_state;
+# else
+ thread_state_flavor_t flavor = PPC_EXCEPTION_STATE64;
+ mach_msg_type_number_t exc_state_count = PPC_EXCEPTION_STATE64_COUNT;
+ ppc_exception_state64_t exc_state;
+# endif
+# else
# error FIXME for non-ppc darwin
-#endif
+# endif
if(exception != EXC_BAD_ACCESS || code[0] != KERN_PROTECTION_FAILURE) {
# if defined (DRSNX)
# include <sys/sparc/frame.h>
# else
-# if defined(OPENBSD) || defined(NETBSD)
+# if defined(OPENBSD)
# include <frame.h>
# else
-# include <sys/frame.h>
+# if defined(FREEBSD) || defined(NETBSD)
+# include <machine/frame.h>
+# else
+# include <sys/frame.h>
+# endif
# endif
# endif
# endif
#if NARGS == 0 && NFRAMES % 2 == 0 /* No padding */ \
&& defined(GC_HAVE_BUILTIN_BACKTRACE)
+#ifdef REDIRECT_MALLOC
+ /* Deal with possible malloc calls in backtrace by omitting */
+ /* the infinitely recursing backtrace. */
+# ifdef THREADS
+ __thread /* If your compiler doesn't understand this */
+ /* you could use something like pthread_getspecific. */
+# endif
+ GC_in_save_callers = FALSE;
+#endif
+
void GC_save_callers (info)
struct callinfo info[NFRAMES];
{
/* We retrieve NFRAMES+1 pc values, but discard the first, since it */
/* points to our own frame. */
+# ifdef REDIRECT_MALLOC
+ if (GC_in_save_callers) {
+ info[0].ci_pc = (word)(&GC_save_callers);
+ for (i = 1; i < NFRAMES; ++i) info[i].ci_pc = 0;
+ return;
+ }
+ GC_in_save_callers = TRUE;
+# endif
GC_ASSERT(sizeof(struct callinfo) == sizeof(void *));
npcs = backtrace((void **)tmp_info, NFRAMES + IGNORE_FRAMES);
BCOPY(tmp_info+IGNORE_FRAMES, info, (npcs - IGNORE_FRAMES) * sizeof(void *));
for (i = npcs - IGNORE_FRAMES; i < NFRAMES; ++i) info[i].ci_pc = 0;
+# ifdef REDIRECT_MALLOC
+ GC_in_save_callers = FALSE;
+# endif
}
#else /* No builtin backtrace; do it ourselves */
-#if (defined(OPENBSD) || defined(NETBSD)) && defined(SPARC)
+#if (defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD)) && defined(SPARC)
# define FR_SAVFP fr_fp
# define FR_SAVPC fr_pc
#else
; GC_push_regs function. Under some optimization levels GCC will clobber
; some of the non-volatile registers before we get a chance to save them
-; therefore, this can't be inline asm.
+; therefore, this cannot be inline asm.
.text
.align 2
; PIC stuff, generated by GCC
.data
-.picsymbol_stub
+.section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
+ .align 2
L_GC_push_one$stub:
.indirect_symbol _GC_push_one
mflr r0
mflr r11
addis r11,r11,ha16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)
mtlr r0
- lwz r12,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)(r11)
+ lwzu r12,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)(r11)
mtctr r12
- addi r11,r11,lo16(L_GC_push_one$lazy_ptr-L0$_GC_push_one)
bctr
.data
.lazy_symbol_pointer
L_GC_push_one$lazy_ptr:
.indirect_symbol _GC_push_one
.long dyld_stub_binding_helper
+
* 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-2001 by Hewlett-Packard Company. All rights reserved.
+ * Copyright (c) 2000-2004 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.
# include "private/pthread_support.h"
# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \
- && !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS) \
- && !defined(GC_AIX_THREADS)
+ && !defined(GC_WIN32_THREADS)
# if defined(GC_HPUX_THREADS) && !defined(USE_PTHREAD_SPECIFIC) \
&& !defined(USE_COMPILER_TLS)
# endif
# if (defined(GC_DGUX386_THREADS) || defined(GC_OSF1_THREADS) || \
- defined(GC_DARWIN_THREADS)) && !defined(USE_PTHREAD_SPECIFIC)
+ defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) \
+ && !defined(USE_PTHREAD_SPECIFIC)
# define USE_PTHREAD_SPECIFIC
# endif
# include <semaphore.h>
#endif /* !GC_DARWIN_THREADS */
-#if defined(GC_DARWIN_THREADS)
+#if defined(GC_DARWIN_THREADS) || defined(GC_FREEBSD_THREADS)
# include <sys/sysctl.h>
#endif /* GC_DARWIN_THREADS */
/* We hold the allocation lock. */
void GC_thr_init()
{
-# ifndef GC_DARWIN_THREADS
- int dummy;
-# endif
+# ifndef GC_DARWIN_THREADS
+ int dummy;
+# endif
GC_thread t;
if (GC_thr_initialized) return;
# if defined(GC_HPUX_THREADS)
GC_nprocs = pthread_num_processors_np();
# endif
-# if defined(GC_OSF1_THREADS)
+# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS)
GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (GC_nprocs <= 0) GC_nprocs = 1;
# endif
-# if defined(GC_FREEBSD_THREADS)
- GC_nprocs = 1;
+# if defined(GC_IRIX_THREADS)
+ GC_nprocs = sysconf(_SC_NPROC_ONLN);
+ if (GC_nprocs <= 0) GC_nprocs = 1;
# endif
-# if defined(GC_DARWIN_THREADS)
+# if defined(GC_DARWIN_THREADS) || defined(GC_FREEBSD_THREADS)
int ncpus = 1;
size_t len = sizeof(ncpus);
sysctl((int[2]) {CTL_HW, HW_NCPU}, 2, &ncpus, &len, NULL, 0);
/* Disable true incremental collection, but generational is OK. */
GC_time_limit = GC_TIME_UNLIMITED;
}
+ /* If we are using a parallel marker, actually start helper threads. */
+ if (GC_parallel) start_mark_threads();
# endif
}
/* GC_init() calls us back, so set flag first. */
if (!GC_is_initialized) GC_init();
- /* If we are using a parallel marker, start the helper threads. */
-# ifdef PARALLEL_MARK
- if (GC_parallel) start_mark_threads();
-# endif
/* Initialize thread local free lists if used. */
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
LOCK();
if (!GC_thr_initialized) GC_thr_init();
# ifdef GC_ASSERTIONS
{
- int stack_size;
+ size_t stack_size;
if (NULL == attr) {
pthread_attr_t my_attr;
pthread_attr_init(&my_attr);
} else {
pthread_attr_getstacksize(attr, &stack_size);
}
- GC_ASSERT(stack_size >= (8*HBLKSIZE*sizeof(word)));
+# ifdef PARALLEL_MARK
+ GC_ASSERT(stack_size >= (8*HBLKSIZE*sizeof(word)));
+# else
+ /* FreeBSD-5.3/Alpha: default pthread stack is 64K, */
+ /* HBLKSIZE=8192, sizeof(word)=8 */
+ GC_ASSERT(stack_size >= 65536);
+# endif
/* Our threads may need to do some work for the GC. */
/* Ridiculously small threads won't work, and they */
/* probably wouldn't work anyway. */
{
struct Print_stats pstats;
- GC_printf0("(kind(0=ptrfree,1=normal,2=unc.,3=stubborn):size_in_bytes, #_marks_set)\n");
+ GC_printf1("(kind(0=ptrfree,1=normal,2=unc.,%lu=stubborn):size_in_bytes, #_marks_set)\n", STUBBORN);
pstats.number_of_blocks = 0;
pstats.total_bytes = 0;
GC_apply_to_all_blocks(GC_print_block_descr, (word)&pstats);
* Modified by Peter C. for Solaris Posix Threads.
*/
-# if defined(GC_SOLARIS_PTHREADS)
# include "private/gc_priv.h"
+
+# if defined(GC_SOLARIS_PTHREADS)
# include <pthread.h>
# include <thread.h>
# include <signal.h>
*/
/* Boehm, September 14, 1994 4:44 pm PDT */
-# if defined(GC_SOLARIS_THREADS) || defined(GC_SOLARIS_PTHREADS)
-
# include "private/gc_priv.h"
+
+# if defined(GC_SOLARIS_THREADS) || defined(GC_SOLARIS_PTHREADS)
# include "private/solaris_threads.h"
# include <thread.h>
# include <synch.h>
for (i = 0; i < max_lwps; i++)
last_ids[i] = 0;
for (;;) {
- if (syscall(SYS_ioctl, GC_main_proc_fd, PIOCSTATUS, &status) < 0)
- ABORT("Main PIOCSTATUS failed");
+ if (syscall(SYS_ioctl, GC_main_proc_fd, PIOCSTATUS, &status) < 0)
+ ABORT("Main PIOCSTATUS failed");
if (status.pr_nlwp < 1)
ABORT("Invalid number of lwps returned by PIOCSTATUS");
if (status.pr_nlwp >= max_lwps) {
for (i = 0; i < max_lwps; i++)
last_ids[i] = 0;
continue;
- }
+ }
if (syscall(SYS_ioctl, GC_main_proc_fd, PIOCLWPIDS, GC_current_ids) < 0)
ABORT("PIOCLWPIDS failed");
changed = FALSE;
{
GC_thread t;
thread_t tid;
+ int ret;
if (GC_thr_initialized)
return;
t = GC_new_thread(thr_self());
t -> stack_size = 0;
t -> flags = DETACHED | CLIENT_OWNS_STACK;
- if (thr_create(0 /* stack */, 0 /* stack_size */, GC_thr_daemon,
- 0 /* arg */, THR_DETACHED | THR_DAEMON,
- &tid /* thread_id */) != 0) {
+ ret = thr_create(0 /* stack */, 0 /* stack_size */, GC_thr_daemon,
+ 0 /* arg */, THR_DETACHED | THR_DAEMON,
+ &tid /* thread_id */);
+ if (ret != 0) {
+ GC_err_printf1("Thr_create returned %ld\n", ret);
ABORT("Cant fork daemon");
}
thr_setprio(tid, 126);
* modified is included with the above copyright notice.
*/
+#include "private/gc_priv.h" /* For GC_compare_and_exchange, GC_memory_barrier */
+
#if 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 = {INVALID_QTID, 0, 0, INVALID_THREADID};
+# include "gc_config_macros.h"
# include "private/gcconfig.h"
# include <stdio.h>
"-Wl,--wrap -Wl,pthread_sigmask -Wl,--wrap -Wl,sleep\n");
# endif
# if defined(GC_LINUX_THREADS) || defined(GC_IRIX_THREADS) \
- || defined(GC_FREEBSD_THREADS) || defined(GC_SOLARIS_PTHREADS) \
+ || defined(GC_SOLARIS_PTHREADS) \
|| defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
printf("-lpthread\n");
# endif
+# if defined(GC_FREEBSD_THREADS)
+# if (__FREEBSD_version >= 500000)
+ printf("-lpthread\n");
+# else
+ printf("-pthread\n");
+# endif
+# endif
# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS)
printf("-lpthread -lrt\n");
# endif
/* Eventually this one may become unnecessary. For now we need */
/* it to keep the old-style build process working. */
#define GC_TMP_VERSION_MAJOR 6
-#define GC_TMP_VERSION_MINOR 3
-#define GC_TMP_ALPHA_VERSION 6
+#define GC_TMP_VERSION_MINOR 6
+#define GC_TMP_ALPHA_VERSION GC_NOT_ALPHA
#ifndef GC_NOT_ALPHA
# define GC_NOT_ALPHA 0xff
+#include "private/gc_priv.h"
+
#if defined(GC_WIN32_THREADS)
-#include "private/gc_priv.h"
#include <windows.h>
#ifdef CYGWIN32
# undef pthread_create
# undef pthread_sigmask
# undef pthread_join
+# undef pthread_detach
# undef dlopen
# define DEBUG_CYGWIN_THREADS 0
/* Must still be in_use, since nobody else can store our thread_id. */
i++) {}
if (i > my_max) {
- WARN("Removing nonexisiting thread %ld\n", (GC_word)thread_id);
+ WARN("Removing nonexistent thread %ld\n", (GC_word)thread_id);
} else {
GC_delete_gc_thread(thread_table+i);
}
# endif
}
+/* Defined in misc.c */
+extern CRITICAL_SECTION GC_write_cs;
+
void GC_stop_world()
{
DWORD thread_id = GetCurrentThreadId();
if (!GC_thr_initialized) ABORT("GC_stop_world() called before GC_thr_init()");
GC_please_stop = TRUE;
+# ifndef CYGWIN32
+ EnterCriticalSection(&GC_write_cs);
+# endif /* !CYGWIN32 */
for (i = 0; i <= GC_get_max_thread_index(); i++)
if (thread_table[i].stack_base != 0
&& thread_table[i].id != thread_id) {
# endif
thread_table[i].suspended = TRUE;
}
+# ifndef CYGWIN32
+ LeaveCriticalSection(&GC_write_cs);
+# endif /* !CYGWIN32 */
}
void GC_start_world()