diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 20:24:04 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2011-07-26 20:24:04 +0400 |
commit | 483278295142421b2f8794e3c900ac2490439450 (patch) | |
tree | 869c3a5bf0c064e5ba53ea136b0eae48d4b536ef | |
parent | 64040040407b11d8740516fad2438109e7f22c02 (diff) | |
download | bdwgc-483278295142421b2f8794e3c900ac2490439450.tar.gz |
gc7.0alpha3 tarball importgc7_0alpha3
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | Makefile.am | 122 | ||||
-rw-r--r-- | Makefile.direct | 17 | ||||
-rw-r--r-- | configure.ac | 167 | ||||
-rw-r--r-- | cord/Makefile.am | 12 | ||||
-rw-r--r-- | cord/cord.am | 14 | ||||
-rw-r--r-- | doc/Makefile.am | 27 | ||||
-rw-r--r-- | doc/README.changes | 17 | ||||
-rw-r--r-- | doc/doc.am | 52 | ||||
-rw-r--r-- | include/Makefile.am | 35 | ||||
-rw-r--r-- | include/gc.h | 17 | ||||
-rw-r--r-- | include/gc_config_macros.h | 4 | ||||
-rw-r--r-- | include/include.am | 53 | ||||
-rw-r--r-- | include/private/gc_locks.h | 32 | ||||
-rw-r--r-- | include/private/gcconfig.h | 38 | ||||
-rw-r--r-- | os_dep.c | 13 | ||||
-rw-r--r-- | pthread_support.c | 86 | ||||
-rw-r--r-- | tests/Makefile.am | 37 | ||||
-rw-r--r-- | tests/tests.am | 60 | ||||
-rw-r--r-- | version.h | 2 |
20 files changed, 539 insertions, 283 deletions
@@ -40,6 +40,8 @@ CFLAGS= -O -I$(srcdir)/include -I$(AO_INSTALL_DIR)/include -DATOMIC_UNCOLLECTABL # To build the parallel collector on Linux, add to the above: # -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC +# To build the thread-capable preload library that intercepts +# malloc, add -DGC_USE_DLOPEN_WRAP -DREDIRECT_MALLOC=GC_malloc -fpic # To build the parallel collector in a static library on HP/UX, # add to the above: # -DGC_HPUX_THREADS -DTHREAD_LOCAL_ALLOC -D_POSIX_C_SOURCE=199506L -mt @@ -237,6 +239,10 @@ HOSTCFLAGS=$(CFLAGS) # causes the collector some system and pthread calls in a more transparent # fashion than the usual macro-based approach. Requires GNU ld, and # currently probably works only with Linux. +# -DGC_USE_DLOPEN_WRAP causes the collector to redefine malloc and intercepted +# pthread routines with their real names, and causes it to use dlopen +# and dlsym to refer to the original versions. This makes it possible to +# build an LD_PRELOADable malloc replacement library. # -DTHREAD_LOCAL_ALLOC defines GC_malloc(), GC_malloc_atomic() # and GC_gcj_malloc() to use a per-thread set of free-lists. # These then allocate in a way that usually does not involve @@ -340,10 +346,10 @@ TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \ GNU_BUILD_FILES= configure.ac Makefile.am configure acinclude.m4 \ libtool.m4 install-sh configure.host Makefile.in \ aclocal.m4 config.sub config.guess \ - include/Makefile.am include/Makefile.in \ - doc/Makefile.am doc/Makefile.in \ + include/include.am include/Makefile.in \ + doc/doc.am doc/Makefile.in \ ltmain.sh mkinstalldirs depcomp missing \ - cord/Makefile.am tests/Makefile.am + cord/cord.am tests/tests.am OTHER_MAKEFILES= OS2_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE gc.mak \ BCC_MAKEFILE EMX_MAKEFILE WCC_MAKEFILE Makefile.dj \ @@ -505,6 +511,11 @@ liblinuxgc.so: $(OBJS) dyn_load.o gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o ln liblinuxgc.so libgc.so +# Build gctest with dynamic library +dyn_test: + $(CC) $(CFLAGS) -o gctest tests/test.c libgc.so `./threadlibs` + ./gctest + # Alternative Linux rule. This is preferable, but is likely to break the # Makefile for some non-linux platforms. # LIBOBJS= $(patsubst %.o, %.lo, $(OBJS)) diff --git a/Makefile.am b/Makefile.am index c1871fb4..b56ef53e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,49 +12,71 @@ # Original author: Tom Tromey # Severely truncated by Hans-J. Boehm # Modified by: Grzegorz Jakacki <jakacki at acm dot org> +# Modified by: Petter Urkedal <petter.urkedal@nordita.dk> (2005-04) ## Process this file with automake to produce Makefile.in. ## FIXME: `make distcheck' in this directory will not currently work. ## This is most likely to the explicit flags passed to submakes. -## FIXME: I'll use AM_AUTOMAKE_INIT(options) macro call in configure.in -AUTOMAKE_OPTIONS = foreign - -SUBDIRS = include cord . tests doc +SUBDIRS = @maybe_libatomic_ops@ . +# Initialize variables so that we can declare files locally. EXTRA_DIST = - ## more items will be succesively added below - -if CPLUSPLUS -extra = libgccpp.la -else -extra = +lib_LTLIBRARIES = +include_HEADERS = +pkginclude_HEADERS = +dist_noinst_HEADERS = +check_PROGRAMS = +TESTS = + +pkgconfigdir = $(libdir)/pkgconfig +dist_pkgconfig_DATA = boehm-gc.pc + +include include/include.am +include cord/cord.am +include tests/tests.am +include doc/doc.am + + +# C Library +# --------- + +lib_LTLIBRARIES += libgc.la +libgc_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 \ + 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 \ + specific.c stubborn.c typd_mlc.c \ + backgraph.c + +# C Library: Architecture Dependent +# --------------------------------- + +if PTHREADS +libgc_la_SOURCES += pthread_support.c pthread_stop_world.c endif -lib_LTLIBRARIES = libgc.la $(extra) - -include_HEADERS = include/gc.h include/gc_local_alloc.h \ - include/gc_pthread_redirects.h include/gc_config_macros.h \ - include/leak_detector.h include/gc_typed.h include/gc_tiny_fl.h \ - @addincludes@ +if AIX_IRIX_THREADS +libgc_la_SOURCES += aix_irix_threads.c +endif -EXTRA_HEADERS = include/gc_cpp.h include/gc_allocator.h +# CHECK: No solaris_pthreads.c solaris_threads.c in gc7.0alpha2.tar.gz. +#if ARCH_SOLARIS +#libgc_la_SOURCES += solaris_pthreads.c solaris_threads.c +#endif if POWERPC_DARWIN -asm_libgc_sources = powerpc_darwin_mach_dep.s -else -asm_libgc_sources = +libgc_la_SOURCES += powerpc_darwin_mach_dep.s +endif +if DARWIN_THREADS +libgc_la_SOURCES += darwin_stop_world.c endif -libgc_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 \ -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 \ -backgraph.c win32_threads.c \ -pthread_support.c pthread_stop_world.c darwin_stop_world.c \ -$(asm_libgc_sources) +if WIN32_THREADS +libgc_la_SOURCES += win32_threads.c +endif # Include THREADDLLIBS here to ensure that the correct versions of # linuxthread semaphore functions get linked: @@ -67,25 +89,37 @@ EXTRA_libgc_la_SOURCES = alpha_mach_dep.S \ rs6000_mach_dep.s sparc_mach_dep.S sparc_netbsd_mach_dep.s \ sparc_sunos4_mach_dep.s ia64_save_regs_in_stack.s + +# C++ Interface +# ------------- + if CPLUSPLUS +lib_LTLIBRARIES += libgccpp.la +pkginclude_HEADERS += include/gc_cpp.h include/gc_allocator.h libgccpp_la_SOURCES = gc_cpp.cc libgccpp_la_LIBADD = $(THREADDLLIBS) $(UNWINDLIBS) libgccpp_la_LDFLAGS = -version-info 1:2:0 endif -## FIXME: automatically added to make dist if EXTRA_*_la_SOURCES -#EXTRA_DIST += alpha_mach_dep.S mips_sgi_mach_dep.s sparc_mach_dep.S + +# FIXME: If Visual C++ users use Makefile.am, this should go into +# pkginclude_HEADERS with proper AM_CONDITIONALization. Otherwise +# delete this comment. +EXTRA_DIST += gc_cpp.cpp + + +# Misc +# ---- AM_CXXFLAGS = @GC_CFLAGS@ AM_CFLAGS = @GC_CFLAGS@ - ## FIXME: relies on internal code generated by automake. ## FIXME: ./configure --enable-dependency-tracking should be used -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_pthread_redirects.h include/gc_config_macros.h \ -include/gc_mark.h @addincludes@ +#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_pthread_redirects.h include/gc_config_macros.h \ +#include/gc_mark.h @addincludes@ ## FIXME: we shouldn't have to do this, but automake forces us to. .s.lo: @@ -112,9 +146,9 @@ dist_noinst_SCRIPTS = callprocs configure.host ## configure.host --- used by Makefile.{am,dj,direct} # headers which are not installed -# (see include/Makefile.am for more) +# (see include/include.am for more) # -dist_noinst_HEADERS = version.h +dist_noinst_HEADERS += version.h # documentation which is not installed # @@ -130,21 +164,13 @@ EXTRA_DIST += BCC_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE \ # files used by makefiles other than Makefile.am # EXTRA_DIST += add_gc_prefix.c gcname.c if_mach.c if_not_there.c \ - hpux_test_and_clear.s pc_excludes gc.mak MacOS.c \ + hpux_test_and_clear.s gc.mak MacOS.c \ MacProjects.sit.hqx mach_dep.c setjmp_t.c \ threadlibs.c AmigaOS.c \ Mac_files/datastart.c Mac_files/dataend.c \ Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h +# :CHECK: If pc_excludes still around, re-add to EXTRA_DIST. -# part of C++ interface -# -EXTRA_DIST += gc_cpp.cc gc_cpp.cpp - -# cord package -# -EXTRA_DIST += cord/cordbscs.c cord/cordtest.c cord/de.c cord/de_win.c \ - cord/de_win.ICO cord/cordprnt.c cord/cordxtra.c cord/de_cmds.h \ - cord/de_win.h cord/de_win.RC # this is an auxiliary shell file used by Makefile and Makefile.direct # diff --git a/Makefile.direct b/Makefile.direct index faa9008f..bbc57b0d 100644 --- a/Makefile.direct +++ b/Makefile.direct @@ -40,6 +40,8 @@ CFLAGS= -O -I$(srcdir)/include -I$(AO_INSTALL_DIR)/include -DATOMIC_UNCOLLECTABL # To build the parallel collector on Linux, add to the above: # -DGC_LINUX_THREADS -DPARALLEL_MARK -DTHREAD_LOCAL_ALLOC +# To build the thread-capable preload library that intercepts +# malloc, add -DGC_USE_DLOPEN_WRAP -DREDIRECT_MALLOC=GC_malloc -fpic # To build the parallel collector in a static library on HP/UX, # add to the above: # -DGC_HPUX_THREADS -DTHREAD_LOCAL_ALLOC -D_POSIX_C_SOURCE=199506L -mt @@ -237,6 +239,10 @@ HOSTCFLAGS=$(CFLAGS) # causes the collector some system and pthread calls in a more transparent # fashion than the usual macro-based approach. Requires GNU ld, and # currently probably works only with Linux. +# -DGC_USE_DLOPEN_WRAP causes the collector to redefine malloc and intercepted +# pthread routines with their real names, and causes it to use dlopen +# and dlsym to refer to the original versions. This makes it possible to +# build an LD_PRELOADable malloc replacement library. # -DTHREAD_LOCAL_ALLOC defines GC_malloc(), GC_malloc_atomic() # and GC_gcj_malloc() to use a per-thread set of free-lists. # These then allocate in a way that usually does not involve @@ -340,10 +346,10 @@ TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \ GNU_BUILD_FILES= configure.ac Makefile.am configure acinclude.m4 \ libtool.m4 install-sh configure.host Makefile.in \ aclocal.m4 config.sub config.guess \ - include/Makefile.am include/Makefile.in \ - doc/Makefile.am doc/Makefile.in \ + include/include.am include/Makefile.in \ + doc/doc.am doc/Makefile.in \ ltmain.sh mkinstalldirs depcomp missing \ - cord/Makefile.am tests/Makefile.am + cord/cord.am tests/tests.am OTHER_MAKEFILES= OS2_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE gc.mak \ BCC_MAKEFILE EMX_MAKEFILE WCC_MAKEFILE Makefile.dj \ @@ -505,6 +511,11 @@ liblinuxgc.so: $(OBJS) dyn_load.o gcc -shared -o liblinuxgc.so $(OBJS) dyn_load.o ln liblinuxgc.so libgc.so +# Build gctest with dynamic library +dyn_test: + $(CC) $(CFLAGS) -o gctest tests/test.c libgc.so `./threadlibs` + ./gctest + # Alternative Linux rule. This is preferable, but is likely to break the # Makefile for some non-linux platforms. # LIBOBJS= $(patsubst %.o, %.lo, $(OBJS)) diff --git a/configure.ac b/configure.ac index 4ff582d0..4c63e7d2 100644 --- a/configure.ac +++ b/configure.ac @@ -17,20 +17,20 @@ dnl Process this file with autoconf to produce configure. # Initialization # ============== -AC_INIT(gc,7.0alpha2,Hans.Boehm@hp.com) +AC_INIT(gc,7.0alpha3,Hans.Boehm@hp.com) ## version must conform to [0-9]+[.][0-9]+(alpha[0-9]+)? AC_CONFIG_SRCDIR(gcj_mlc.c) AC_CANONICAL_TARGET AC_PREREQ(2.53) AC_REVISION($Revision: 1.2 $) GC_SET_VERSION -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects nostdinc]) AM_MAINTAINER_MODE AC_SUBST(PACKAGE) AC_SUBST(GC_VERSION) -AC_PROG_CC +AM_PROG_CC_C_O AC_PROG_CXX AM_PROG_AS @@ -45,27 +45,28 @@ AC_PROG_INSTALL GC_CFLAGS=${gc_cflags} AC_SUBST(GC_CFLAGS) -AC_ARG_ENABLE(threads, [ --enable-threads=TYPE choose threading package], +AC_ARG_ENABLE(threads, + [AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])], THREADS=$enableval, [ AC_MSG_CHECKING([for thread model used by GCC]) THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` if test -z "$THREADS"; then THREADS=no fi - AC_MSG_RESULT([$THREADS])]) + AC_MSG_RESULT([$THREADS]) ]) AC_ARG_ENABLE(parallel-mark, -[ --enable-parallel-mark parallelize marking and free list construction], + [AC_HELP_STRING([--enable-parallel-mark], + [parallelize marking and free list construction])], [case "$THREADS" in no | none | single) AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec]) ;; - esac] + esac ] ) AC_ARG_ENABLE(cplusplus, -[ --enable-cplusplus install C++ support], -) + [AC_HELP_STRING([--enable-cplusplus], [install C++ support])]) INCLUDES=-I${srcdir}/include THREADDLLIBS= @@ -93,6 +94,7 @@ case "$THREADS" in *-*-aix*) AC_DEFINE(GC_AIX_THREADS) AC_DEFINE(_REENTRANT) + aix_irix_threads=true ;; *-*-hpux*) AC_MSG_WARN("Only HP/UX 11 threads are supported.") @@ -113,12 +115,15 @@ case "$THREADS" in *-*-solaris*) AC_DEFINE(GC_SOLARIS_THREADS) AC_DEFINE(GC_SOLARIS_PTHREADS) + solaris_threads=true ;; *-*-irix*) AC_DEFINE(GC_IRIX_THREADS) + aix_irix_threads=true ;; *-*-cygwin*) AC_DEFINE(GC_WIN32_THREADS) + win32_threads=true ;; *-*-darwin*) AC_DEFINE(GC_DARWIN_THREADS) @@ -126,6 +131,7 @@ case "$THREADS" in if test "${enable_parallel_mark}" = yes; then AC_DEFINE(PARALLEL_MARK) fi + darwin_threads=true ;; *-*-osf*) AC_DEFINE(GC_OSF1_THREADS) @@ -176,6 +182,12 @@ case "$THREADS" in ;; esac AC_SUBST(THREADDLLIBS) +AM_CONDITIONAL(THREADS, test x$THREADS != xnone) +AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix) +AM_CONDITIONAL(AIX_IRIX_THREADS, test x$aix_irix_threads = xtrue) +AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue) +AM_CONDITIONAL(ARCH_SOLARIS, test x$solaris_threads = xtrue) +AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue) case "$host" in powerpc-*-darwin*) @@ -210,8 +222,6 @@ TARGET_ECOS="$with_ecos" addobjs= addlibs= -addincludes= -addtests= CXXINCLUDES= case "$TARGET_ECOS" in no) @@ -223,11 +233,6 @@ case "$TARGET_ECOS" in ;; esac -if test "${enable_cplusplus}" = yes; then - addincludes="$addincludes include/gc_cpp.h include/gc_allocator.h" - addtests="$addtests test_cpp" -fi - AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes) AC_SUBST(CXX) @@ -303,9 +308,7 @@ AC_MSG_RESULT($machdep) fi addobjs="$addobjs $machdep" AC_SUBST(addobjs) -AC_SUBST(addincludes) AC_SUBST(addlibs) -AC_SUBST(addtests) AC_PROG_LIBTOOL @@ -382,10 +385,52 @@ dnl ALL_INTERIOR_POINTERS can be overridden in startup code. AC_DEFINE(NO_EXECUTE_PERMISSION) AC_DEFINE(ALL_INTERIOR_POINTERS) + +dnl Interface Selection +dnl ------------------- +dnl dnl By default, make the library as general as possible. -AC_DEFINE(JAVA_FINALIZATION) -AC_DEFINE(GC_GCJ_SUPPORT) -AC_DEFINE(ATOMIC_UNCOLLECTABLE) + +dnl :FIXME: gcj does not work as of gc-7.0_alpha2, so default set to no. +enable_gcj_support=no +AC_ARG_ENABLE(gcj-support, + [AC_HELP_STRING([--enable-gcj-support], + [Enable support for gcj.])]) +AM_CONDITIONAL(ENABLE_GCJ_SUPPORT, + [test x"$enable_gcj_support" != xno]) +if test x"$enable_gcj_support" != xno; then + AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj]) +fi + +AC_ARG_ENABLE(java-finalization, + [AC_HELP_STRING([--disable-java-finalization], + [Disable support for java finalization.])]) +if test x"$enable_java_finalization" != xno; then + AC_DEFINE(JAVA_FINALIZATION) +fi + +AC_ARG_ENABLE(atomic-uncollectable, + [AC_HELP_STRING([--disable-atomic-uncollectible], + [Disable support for atomic uncollectible allocation.])]) +if test x"$enable_atomic_uncollectible" != x"no"; then + AC_DEFINE(ATOMIC_UNCOLLECTABLE, 1, + [Define to enable atomic uncollectible allocation.]) +fi + +AC_ARG_ENABLE(redirect-malloc, + [AC_HELP_STRING([--enable-redirect-malloc], + [Redirect malloc and friends to GC routines])]) + +if test "${enable_redirect_malloc}" = yes; then + if test "${enable_full_debug}" = yes; then + AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement) + AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement) + AC_DEFINE(REDIRECT_FREE, GC_debug_free) + else + AC_DEFINE(REDIRECT_MALLOC, GC_malloc) + fi +fi + dnl This is something of a hack. When cross-compiling we turn off dnl some functionality. We also enable the "small" configuration. @@ -397,9 +442,14 @@ if test -n "${with_cross_host}"; then AC_DEFINE(NO_DEBUGGING) fi + +dnl Debugging +dnl --------- + UNWINDLIBS= AC_ARG_ENABLE(gc-debug, -[ --enable-gc-debug include full support for pointer backtracing etc.], +[AC_HELP_STRING([--enable-gc-debug], + [include full support for pointer backtracing etc.])], [ if test "$enable_gc_debug" = "yes"; then AC_MSG_WARN("Should define GC_DEBUG and use debug alloc. in clients.") AC_DEFINE(KEEP_BACK_PTRS) @@ -427,32 +477,61 @@ AC_ARG_ENABLE(gc-debug, AC_SUBST(UNWINDLIBS) -AC_ARG_ENABLE(redirect-malloc, -[ --enable-redirect-malloc redirect malloc and friends to GC routines]) - -if test "${enable_redirect_malloc}" = yes; then - if test "${enable_full_debug}" = yes; then - AC_DEFINE(REDIRECT_MALLOC, GC_debug_malloc_replacement) - AC_DEFINE(REDIRECT_REALLOC, GC_debug_realloc_replacement) - AC_DEFINE(REDIRECT_FREE, GC_debug_free) - else - AC_DEFINE(REDIRECT_MALLOC, GC_malloc) - fi -fi - AC_ARG_ENABLE(gc-assertions, -[ --enable-gc-assertions collector-internal assertion checking]) + [AC_HELP_STRING([--enable-gc-assertions], + [collector-internal assertion checking])]) if test "${enable_gc_assertions}" = yes; then AC_DEFINE(GC_ASSERTIONS) fi AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host") -AC_OUTPUT( -[Makefile doc/Makefile include/Makefile tests/Makefile cord/Makefile],, -srcdir=${srcdir} -host=${host} -CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} -CC="${CC}" -DEFS="$DEFS" -) + +dnl Atomic Ops +dnl ---------- + +AC_CHECK_HEADER(libatomic_ops.h, + [ AC_MSG_NOTICE([Using pre-installed libatomic_ops]) ], + [ ao_dir= + for candidate in ${srcdir}/libatomic_ops*; do + case $candidate in + *.tar.gz) + ;; + *) + if test -e "$candidate"; then + ao_dir="$candidate" + fi + ;; + esac + done + if test -z "$ao_dir"; then + AC_MSG_ERROR([Missig libatomic_ops.]) + fi + ao_version="${ao_dir#*libatomic_ops-}" + ao_dir=libatomic_ops-${ao_version} + AC_MSG_NOTICE([Using internal version of libatomic_ops]) + + dnl Automake does not accept shell variables in AC_CONFIG_SUBDIRS + test -e ${srcdir}/libatomic_ops \ + || ln -sf ${ao_dir} ${srcdir}/libatomic_ops + AC_CONFIG_SUBDIRS(libatomic_ops) + + GC_CFLAGS="${MY_CFLAGS} -I \$(top_srcdir)/libatomic_ops/src" + ATOMIC_OPS_LIBS="-L \$(top_builddir)/libatomic_ops/src -latomic_ops" + maybe_libatomic_ops=libatomic_ops + ]) +AC_SUBST(maybe_libatomic_ops) + +dnl Produce the Files +dnl ----------------- + +AC_CONFIG_FILES([Makefile boehm-gc.pc]) + +AC_CONFIG_COMMANDS([default],, + [ srcdir=${srcdir} + host=${host} + CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + CC="${CC}" + DEFS="$DEFS" ]) + +AC_OUTPUT diff --git a/cord/Makefile.am b/cord/Makefile.am deleted file mode 100644 index 253632f6..00000000 --- a/cord/Makefile.am +++ /dev/null @@ -1,12 +0,0 @@ -AM_CPPFLAGS=-I $(top_srcdir)/include -I$(top_srcdir)/include/private - -lib_LTLIBRARIES = libcord.la - -libcord_la_SOURCES = \ - cordbscs.c \ - cordprnt.c \ - cordtest.c \ - cordxtra.c - - -EXTRA_DIST = de.c de_cmds.h de_win.ICO de_win.RC de_win.c de_win.h diff --git a/cord/cord.am b/cord/cord.am new file mode 100644 index 00000000..2ce61808 --- /dev/null +++ b/cord/cord.am @@ -0,0 +1,14 @@ + +lib_LTLIBRARIES += libcord.la + +libcord_la_SOURCES = \ + cord/cordbscs.c \ + cord/cordprnt.c \ + cord/cordtest.c \ + cord/cordxtra.c + + +EXTRA_DIST += \ + cord/cordbscs.c cord/cordtest.c cord/de.c \ + cord/cordprnt.c cord/cordxtra.c cord/de_cmds.h \ + cord/de_win.h cord/de_win.c cord/de_win.RC cord/de_win.ICO diff --git a/doc/Makefile.am b/doc/Makefile.am deleted file mode 100644 index 9446bcb1..00000000 --- a/doc/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# -# -# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED -# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. -# -# Permission is hereby granted to use or copy this program -# for any purpose, provided the above notices are retained on all copies. -# Permission to modify the code and to distribute modified code is granted, -# provided the above notices are retained, and a notice that the code was -# modified is included with the above copyright notice. -# -# Modified by: Grzegorz Jakacki <jakacki at acm dot org> - -## Process this file with automake to produce Makefile.in. - -# installed documentation -# -dist_pkgdata_DATA = barrett_diagram debugging.html gc.man \ - gcdescr.html README README.amiga README.arm.cross \ - README.autoconf README.changes README.contributors \ - README.cords README.DGUX386 README.dj README.environment \ - README.ews4800 README.hp README.linux README.Mac \ - README.MacOSX README.macros README.OS2 README.rs6000 \ - README.sgi README.solaris2 README.uts README.win32 \ - tree.html leak.html gcinterface.html scale.html \ - README.darwin simple_example.html - diff --git a/doc/README.changes b/doc/README.changes index 70148a22..52e41569 100644 --- a/doc/README.changes +++ b/doc/README.changes @@ -2186,6 +2186,18 @@ Since gc6.4: 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. Since gc6.5: - Remove GC_PROTO, VOLATILE, GC_PTR, and GC_CONST. Assume ANSI C compiler @@ -2309,6 +2321,11 @@ Since gc7.0alpha1: redefines GC_malloc. - Removed now unused AIX memory allocation code. - Various minor fixes for bugs introduced in 7.0alpha1. + +Since gc7.0alpha2 + - Added support for dlopen-based interception of pthread functions. + This is only half done. The gc.h redefinitions currently interfere. + - Integrated major automake overhaul from Petter Urkedal. To do: - Fix USE_MARK_BITS. diff --git a/doc/doc.am b/doc/doc.am new file mode 100644 index 00000000..b21d5001 --- /dev/null +++ b/doc/doc.am @@ -0,0 +1,52 @@ +# +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program +# for any purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is granted, +# provided the above notices are retained, and a notice that the code was +# modified is included with the above copyright notice. +# +# Modified by: Grzegorz Jakacki <jakacki at acm dot org> +# Modified by: Petter Urkedal <petter.urkedal@nordita.dk> + +## Process this file with automake to produce Makefile.in. + +# installed documentation +# +dist_pkgdata_DATA = \ + doc/barrett_diagram \ + doc/debugging.html \ + doc/gc.man \ + doc/gcdescr.html \ + doc/README \ + doc/README.amiga \ + doc/README.arm.cross \ + doc/README.autoconf \ + doc/README.changes \ + doc/README.contributors \ + doc/README.cords \ + doc/README.DGUX386 \ + doc/README.dj \ + doc/README.environment \ + doc/README.ews4800 \ + doc/README.hp \ + doc/README.linux \ + doc/README.Mac \ + doc/README.MacOSX \ + doc/README.macros \ + doc/README.OS2 \ + doc/README.rs6000 \ + doc/README.sgi \ + doc/README.solaris2 \ + doc/README.uts \ + doc/README.win32 \ + doc/tree.html \ + doc/leak.html \ + doc/gcinterface.html \ + doc/scale.html \ + doc/README.darwin \ + doc/simple_example.html + diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 5bc68ddc..00000000 --- a/include/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -# -# -# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED -# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. -# -# Permission is hereby granted to use or copy this program -# for any purpose, provided the above notices are retained on all copies. -# Permission to modify the code and to distribute modified code is granted, -# provided the above notices are retained, and a notice that the code was -# modified is included with the above copyright notice. -# -# Modified by: Grzegorz Jakacki <jakacki at acm dot org> - -## Process this file with automake to produce Makefile.in. - -# installed headers -# -pkginclude_HEADERS = gc.h gc_typed.h gc_inl.h \ - gc_inline.h gc_mark.h gc_cpp.h \ - weakpointer.h new_gc_alloc.h \ - gc_allocator.h gc_backptr.h \ - gc_gcj.h gc_local_alloc.h leak_detector.h \ - gc_amiga_redirects.h gc_pthread_redirects.h \ - gc_config_macros.h - -# headers which are not installed -# -dist_noinst_HEADERS = private/gc_hdrs.h \ - private/gc_priv.h private/gcconfig.h \ - private/gc_pmark.h private/gc_locks.h \ - private/dbg_mlc.h \ - private/specific.h private/cord_pos.h \ - private/pthread_support.h private/pthread_stop_world.h \ - private/darwin_semaphore.h private/darwin_stop_world.h \ - cord.h ec.h javaxfc.h diff --git a/include/gc.h b/include/gc.h index 8637735c..a47dc4a1 100644 --- a/include/gc.h +++ b/include/gc.h @@ -977,7 +977,22 @@ extern void GC_thr_init(void); /* Needed for Solaris/X86 */ * Similarly gnu-win32 DLLs need explicit initialization from * the main program, as does AIX. */ -# define GC_INIT() { GC_add_roots(DATASTART, DATAEND); GC_init(); } +# 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__)) +# endif +# if defined(_AIX) + extern int _data[], _end[]; +# define GC_DATASTART ((GC_PTR)((ulong)_data)) +# define GC_DATAEND ((GC_PTR)((ulong)_end)) +# endif +# define GC_INIT() { GC_add_roots(GC_DATASTART, GC_DATAEND); GC_init(); } #else # define GC_INIT() { GC_init(); } #endif diff --git a/include/gc_config_macros.h b/include/gc_config_macros.h index bdae6a90..2cfa6c22 100644 --- a/include/gc_config_macros.h +++ b/include/gc_config_macros.h @@ -95,6 +95,10 @@ # 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) && !defined(GC_WIN32_THREADS) \ diff --git a/include/include.am b/include/include.am new file mode 100644 index 00000000..0c865155 --- /dev/null +++ b/include/include.am @@ -0,0 +1,53 @@ +# +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program +# for any purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is granted, +# provided the above notices are retained, and a notice that the code was +# modified is included with the above copyright notice. +# +# Modified by: Grzegorz Jakacki <jakacki at acm dot org> +# Modified by: Petter Urkedal <petter.urkedal@nordita.dk> + +## Process this file with automake to produce Makefile.in. + +# installed headers +# +pkginclude_HEADERS += \ + include/gc.h \ + include/gc_typed.h \ + include/gc_inline.h \ + include/gc_mark.h \ + include/gc_cpp.h \ + include/weakpointer.h \ + include/new_gc_alloc.h \ + include/gc_allocator.h \ + include/gc_backptr.h \ + include/gc_gcj.h \ + include/leak_detector.h \ + include/gc_amiga_redirects.h \ + include/gc_pthread_redirects.h \ + include/gc_config_macros.h \ + include/gc_tiny_fl.h + +# headers which are not installed +# +dist_noinst_HEADERS += \ + include/private/gc_hdrs.h \ + include/private/gc_priv.h \ + include/private/gcconfig.h \ + include/private/gc_pmark.h \ + include/private/gc_locks.h \ + include/private/dbg_mlc.h \ + include/private/specific.h \ + include/private/cord_pos.h \ + include/private/pthread_support.h \ + include/private/pthread_stop_world.h \ + include/private/darwin_semaphore.h \ + include/private/darwin_stop_world.h \ + include/cord.h \ + include/ec.h \ + include/javaxfc.h diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h index 9184e3a6..4dcba2b2 100644 --- a/include/private/gc_locks.h +++ b/include/private/gc_locks.h @@ -78,8 +78,7 @@ # endif -# if defined(GC_PTHREADS) \ - && !defined(GC_IRIX_THREADS) && !defined(GC_WIN32_THREADS) +# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) # define NO_THREAD (pthread_t)(-1) # include <pthread.h> @@ -145,35 +144,6 @@ # 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 AO_TS_t 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 UNCOND_LOCK() { if (AO_test_and_set_acquire(&GC_allocate_lock)) \ - GC_lock(); } -# define UNCOND_UNLOCK() AO_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> diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index e71041b2..cd296e58 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -56,7 +56,7 @@ # endif /* And one for FreeBSD: */ -# if defined(__FreeBSD__) +# if defined(__FreeBSD__) && !defined(FREEBSD) # define FREEBSD # endif @@ -190,14 +190,16 @@ # 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_) @@ -600,7 +602,7 @@ */ # if defined(__GNUC__) && ((__GNUC__ >= 3) || \ (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)) \ - && !defined(__INTEL_COMPILER) + && !defined(__INTEL_COMPILER) && !defined(__PATHCC__) # define HAVE_BUILTIN_UNWIND_INIT # endif @@ -849,12 +851,10 @@ extern ptr_t GC_SysVGetDataStart(size_t, ptr_t); # ifdef __arch64__ # define DATASTART GC_SysVGetDataStart(0x100000, (ptr_t)_etext) - /* libc_stack_end is not set reliably for sparc64 */ -# define STACKBOTTOM ((ptr_t) 0x80000000000ULL) # else # define DATASTART GC_SysVGetDataStart(0x10000, (ptr_t)_etext) -# define LINUX_STACKBOTTOM # endif +# define LINUX_STACKBOTTOM # endif # ifdef OPENBSD # define OS_TYPE "OPENBSD" @@ -1062,26 +1062,8 @@ # 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 @@ -1461,7 +1443,7 @@ # 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 @@ -941,14 +941,21 @@ ptr_t GC_get_main_stack_base(void) /* this. */ # ifdef USE_LIBC_PRIVATES if (0 != &__libc_stack_end && 0 != __libc_stack_end ) { -# ifdef IA64 +# if defined(IA64) /* Some versions of glibc set the address 16 bytes too */ /* low while the initialization code is running. */ if (((word)__libc_stack_end & 0xfff) + 0x10 < 0x1000) { return __libc_stack_end + 0x10; } /* Otherwise it's not safe to add 16 bytes and we fall */ /* back to using /proc. */ -# else +# elif defined(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 } @@ -1072,7 +1079,7 @@ int GC_get_stack_base(struct GC_stack_base *b) # ifdef NEED_FIND_LIMIT # ifdef STACK_GROWS_DOWN - b -> mem_base = GC_find_limit(&dummy, TRUE); + b -> mem_base = GC_find_limit((ptr_t)(&dummy), TRUE); # ifdef IA64 b -> reg_base = GC_find_limit(GC_save_regs_in_stack(), FALSE); # endif diff --git a/pthread_support.c b/pthread_support.c index 0c70732e..17590824 100644 --- a/pthread_support.c +++ b/pthread_support.c @@ -45,9 +45,7 @@ # 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) +# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS) # if defined(GC_HPUX_THREADS) && !defined(USE_PTHREAD_SPECIFIC) \ && !defined(USE_COMPILER_TLS) @@ -135,12 +133,28 @@ # define WRAP_FUNC(f) __wrap_##f # define REAL_FUNC(f) __real_##f #else -# define WRAP_FUNC(f) GC_##f -# if !defined(GC_DGUX386_THREADS) -# define REAL_FUNC(f) f -# else /* GC_DGUX386_THREADS */ -# define REAL_FUNC(f) __d10_##f -# endif /* GC_DGUX386_THREADS */ +# ifdef GC_USE_DLOPEN_WRAP +# include <dlfcn.h> +# define WRAP_FUNC(f) f +# define REAL_FUNC(f) GC_real_##f + /* FIXME: Needs work for DARWIN and True64 (OSF1) */ + typedef int (* GC_pthread_create_t)(pthread_t *, const pthread_attr_t *, + void * (*)(void *), void *); + static GC_pthread_create_t GC_real_pthread_create; + typedef int (* GC_pthread_sigmask_t)(int, const sigset_t *, sigset_t *); + static GC_pthread_sigmask_t GC_real_pthread_sigmask; + typedef int (* GC_pthread_join_t)(pthread_t, void **); + static GC_pthread_join_t GC_real_pthread_join; + typedef int (* GC_pthread_detach_t)(pthread_t); + static GC_pthread_detach_t GC_real_pthread_detach; +# else +# define WRAP_FUNC(f) GC_##f +# if !defined(GC_DGUX386_THREADS) +# define REAL_FUNC(f) f +# else /* GC_DGUX386_THREADS */ +# define REAL_FUNC(f) __d10_##f +# endif /* GC_DGUX386_THREADS */ +# endif # undef pthread_create # if !defined(GC_DARWIN_THREADS) # undef pthread_sigmask @@ -156,6 +170,48 @@ # endif #endif +#ifdef GC_USE_DLOPEN_WRAP + static GC_bool GC_syms_initialized = FALSE; + + void GC_init_real_syms(void) + { + void *dl_handle; +# define LIBPTHREAD_NAME "libpthread.so.0" +# define LIBPTHREAD_NAME_LEN 16 /* incl. trailing 0 */ + size_t len = LIBPTHREAD_NAME_LEN - 1; + char namebuf[LIBPTHREAD_NAME_LEN]; + static char *libpthread_name = LIBPTHREAD_NAME; + + if (GC_syms_initialized) return; +# ifdef RTLD_NEXT + dl_handle = RTLD_NEXT; +# else + dl_handle = dlopen(libpthread_name, RTLD_LAZY); + if (NULL == dl_handle) { + while (isdigit(libpthread_name[len-1])) --len; + if (libpthread_name[len-1] == '.') --len; + memcpy(namebuf, libpthread_name, len); + namebuf[len] = '\0'; + dl_handle = dlopen(namebuf, RTLD_LAZY); + } + if (NULL == dl_handle) ABORT("Couldn't open libpthread\n"); +# endif + GC_real_pthread_create = (GC_pthread_create_t) + dlsym(dl_handle, "pthread_create"); + GC_real_pthread_sigmask = (GC_pthread_sigmask_t) + dlsym(dl_handle, "pthread_sigmask"); + GC_real_pthread_join = (GC_pthread_join_t) + dlsym(dl_handle, "pthread_join"); + GC_real_pthread_detach = (GC_pthread_detach_t) + dlsym(dl_handle, "pthread_detach"); + GC_syms_initialized = TRUE; + } + +# define INIT_REAL_SYMS() if (!GC_syms_initialized) GC_init_real_syms(); +#else +# define INIT_REAL_SYMS() +#endif + void GC_thr_init(void); static GC_bool parallel_initialized = FALSE; @@ -928,6 +984,7 @@ int WRAP_FUNC(pthread_sigmask)(int how, const sigset_t *set, sigset_t *oset) { sigset_t fudged_set; + INIT_REAL_SYMS(); if (set != NULL && (how == SIG_BLOCK || how == SIG_SETMASK)) { fudged_set = *set; sigdelset(&fudged_set, SIG_SUSPEND); @@ -1022,6 +1079,7 @@ int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) int result; GC_thread thread_gc_id; + INIT_REAL_SYMS(); LOCK(); thread_gc_id = GC_lookup_thread(thread); /* This is guaranteed to be the intended one, since the thread id */ @@ -1054,6 +1112,7 @@ WRAP_FUNC(pthread_detach)(pthread_t thread) int result; GC_thread thread_gc_id; + INIT_REAL_SYMS(); LOCK(); thread_gc_id = GC_lookup_thread(thread); UNLOCK(); @@ -1095,9 +1154,10 @@ GC_thread GC_register_my_thread_inner(struct GC_stack_base *sb, int GC_register_my_thread(struct GC_stack_base *sb) { pthread_t my_pthread = pthread_self(); + GC_thread me; LOCK(); - GC_thread me = GC_lookup_thread(my_pthread); + me = GC_lookup_thread(my_pthread); if (0 == me) { me = GC_register_my_thread_inner(sb, my_pthread); me -> flags |= DETACHED; @@ -1177,6 +1237,7 @@ WRAP_FUNC(pthread_create)(pthread_t *new_thread, /* even if the default is unreasonably small. That's the client's */ /* responsibility. */ + INIT_REAL_SYMS(); LOCK(); si = (struct start_info *)GC_INTERNAL_MALLOC(sizeof(struct start_info), NORMAL); @@ -1198,7 +1259,12 @@ WRAP_FUNC(pthread_create)(pthread_t *new_thread, } else { pthread_attr_getstacksize(attr, &stack_size); } +# if GC_FREEBSD_THREADS + /* FreeBSD-5.3/Alpha: default pthread stack is 64K, HBLKSIZE=8192, sizeof(word)=8 */ + GC_ASSERT(stack_size >= 65536); +# else GC_ASSERT(stack_size >= (8*HBLKSIZE*sizeof(word))); +# 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. */ diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index 0064f3ba..00000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -AM_CPPFLAGS=-I$(top_builddir)/include -I$(top_builddir)/include/private - -if CPLUSPLUS -extra_checks = test_cpp -else -extra_checks = -endif - -## FIXME: trace_test don't works on macosx 10.3 -## gcc -g -O2 -o .libs/tracetest trace_test.o ../.libs/libgc.dylib -lpthread -## ld: Undefined symbols: -## _GC_generate_random_backtrace - -check_PROGRAMS = gctest leaktest middletest threadleaktest $(extra_checks) - -gctest_SOURCES = test.c -gctest_LDADD = $(top_builddir)/libgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) -gctest_DEPENDENCIES = $(top_builddir)/libgc.la - -leaktest_SOURCES = leak_test.c -leaktest_LDADD = $(top_builddir)/libgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) - -middletest_SOURCES = middle.c -middletest_LDADD = $(top_builddir)/libgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) - -## tracetest_SOURCES = trace_test.c -## tracetest_LDADD = $(top_builddir)/libgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) - -threadleaktest_SOURCES = thread_leak_test.c -threadleaktest_LDADD = $(top_builddir)/libgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) - -if CPLUSPLUS -test_cpp_SOURCES = test_cpp.cc -test_cpp_LDADD = $(top_builddir)/libgc.la $(top_builddir)/libgccpp.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) -endif - -TESTS = gctest leaktest middletest threadleaktest $(extra_checks) diff --git a/tests/tests.am b/tests/tests.am new file mode 100644 index 00000000..defd592c --- /dev/null +++ b/tests/tests.am @@ -0,0 +1,60 @@ +# +# +# THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED +# OR IMPLIED. ANY USE IS AT YOUR OWN RISK. +# +# Permission is hereby granted to use or copy this program +# for any purpose, provided the above notices are retained on all copies. +# Permission to modify the code and to distribute modified code is granted, +# provided the above notices are retained, and a notice that the code was +# modified is included with the above copyright notice. + + +## FIXME: trace_test don't works on macosx 10.3 +## gcc -g -O2 -o .libs/tracetest trace_test.o ../.libs/libgc.dylib -lpthread +## ld: Undefined symbols: +## _GC_generate_random_backtrace + + +# Common libs to _LDADD for all tests. +test_ldadd = \ + $(top_builddir)/libgc.la \ + $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS) + + + +TESTS += gctest +check_PROGRAMS += gctest +gctest_SOURCES = tests/test.c +gctest_LDADD = $(test_ldadd) +gctest_DEPENDENCIES = $(top_builddir)/libgc.la + +TESTS += leaktest +check_PROGRAMS += leaktest +leaktest_SOURCES = tests/leak_test.c +leaktest_LDADD = $(test_ldadd) + +TESTS += middletest +check_PROGRAMS += middletest +middletest_SOURCES = tests/middle.c +middletest_LDADD = $(test_ldadd) + +#TESTS += tracetest +#check_PROGRAMS += tracetest +#tracetest_SOURCES = tests/trace_test.c +#tracetest_LDADD = $(test_ldadd) + +if THREADS +TESTS += threadleaktest +check_PROGRAMS += threadleaktest +threadleaktest_SOURCES = tests/thread_leak_test.c +threadleaktest_LDADD = $(test_ldadd) +endif + +if CPLUSPLUS +TESTS += test_cpp +check_PROGRAMS += test_cpp +test_cpp_SOURCES = tests/test_cpp.cc +test_cpp_LDADD = libgccpp.la $(test_ldadd) +endif + @@ -3,7 +3,7 @@ /* it to keep the old-style build process working. */ #define GC_TMP_VERSION_MAJOR 7 #define GC_TMP_VERSION_MINOR 0 -#define GC_TMP_ALPHA_VERSION 2 +#define GC_TMP_ALPHA_VERSION 3 #ifndef GC_NOT_ALPHA # define GC_NOT_ALPHA 0xff |