## files that should be in the distribution are not mentioned in this
## Makefile.am.
-AUTOMAKE_OPTIONS = cygnus subdir-objects
+AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I .. -I ../config
-SUBDIRS = include
+SUBDIRS = include testsuite
noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
# Include THREADLIBS here to ensure that the correct versions of
# linuxthread semaphore functions get linked:
-libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
+libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = $(addobjs)
libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
libgcjgc_convenience_la_LIBADD = $(addobjs)
libgcjgc_convenience_la_DEPENDENCIES = $(addobjs)
-AM_CXXFLAGS = $(GC_CFLAGS)
-AM_CFLAGS = $(GC_CFLAGS)
+AM_CXXFLAGS = $(GC_CFLAGS) $(THREADCFLAGS)
+AM_CFLAGS = $(GC_CFLAGS) $(THREADCFLAGS)
AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
-test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
-
-check_PROGRAMS = gctest
-gctest_SOURCES = tests/test.c
-gctest_LDADD = $(test_ldadd)
-gctest_LDFLAGS = -shared-libgcc
-gctest_LINK = $(LINK) $(gctest_LDFLAGS)
-TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
-TESTS = gctest
-
-TESTS += leaktest$(EXEEXT)
-check_PROGRAMS += leaktest
-leaktest_SOURCES = tests/leak_test.c
-leaktest_LDADD = $(test_ldadd)
-leaktest_LDFLAGS = -shared-libgcc
-leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
-
-TESTS += middletest$(EXEEXT)
-check_PROGRAMS += middletest
-middletest_SOURCES = tests/middle.c
-middletest_LDADD = $(test_ldadd)
-middletest_LDFLAGS = -shared-libgcc
-middletest_LINK = $(LINK) $(middletest_LDFLAGS)
-
-TESTS += staticrootstest$(EXEEXT)
-check_PROGRAMS += staticrootstest
-staticrootstest_SOURCES = tests/staticrootstest.c
-staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
-staticrootstest_LDFLAGS = -shared-libgcc
-staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
-check_LTLIBRARIES = libstaticrootslib.la
-libstaticrootslib_la_SOURCES = tests/staticrootslib.c
-libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
-libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
- -rpath /nowhere -shared-libgcc
-libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
-
## FIXME: we shouldn't have to do this, but automake forces us to.
.s.lo:
## We use -Wp,-P to strip #line directives. Irix `as' chokes on
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-check_PROGRAMS = gctest$(EXEEXT) leaktest$(EXEEXT) middletest$(EXEEXT) \
- staticrootstest$(EXEEXT)
-TESTS = gctest$(EXEEXT) leaktest$(EXEEXT) middletest$(EXEEXT) \
- staticrootstest$(EXEEXT)
subdir = .
-DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(top_srcdir)/configure $(am__configure_deps) \
- $(srcdir)/../mkinstalldirs $(srcdir)/threads.mk.in
+DIST_COMMON = $(am__configure_deps) $(srcdir)/../compile \
+ $(srcdir)/../config.guess $(srcdir)/../config.sub \
+ $(srcdir)/../depcomp $(srcdir)/../install-sh \
+ $(srcdir)/../ltmain.sh $(srcdir)/../missing \
+ $(srcdir)/../mkinstalldirs $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in $(srcdir)/threads.mk.in \
+ $(top_srcdir)/configure ChangeLog depcomp
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../config/depstand.m4 \
CONFIG_CLEAN_VPATH_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
am__DEPENDENCIES_1 =
+am__libgcjgc_la_SOURCES_DIST = 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 win32_threads.c pthread_support.c \
+ pthread_stop_world.c darwin_stop_world.c \
+ powerpc_darwin_mach_dep.s
@POWERPC_DARWIN_TRUE@am__objects_1 = powerpc_darwin_mach_dep.lo
am_libgcjgc_la_OBJECTS = allchblk.lo alloc.lo blacklst.lo checksums.lo \
dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo \
backgraph.lo win32_threads.lo pthread_support.lo \
pthread_stop_world.lo darwin_stop_world.lo $(am__objects_1)
libgcjgc_la_OBJECTS = $(am_libgcjgc_la_OBJECTS)
+am__libgcjgc_convenience_la_SOURCES_DIST = 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 win32_threads.c \
+ pthread_support.c pthread_stop_world.c darwin_stop_world.c \
+ powerpc_darwin_mach_dep.s
am__objects_2 = allchblk.lo alloc.lo blacklst.lo checksums.lo \
dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo \
headers.lo malloc.lo mallocx.lo mark.lo mark_rts.lo misc.lo \
am_libgcjgc_convenience_la_OBJECTS = $(am__objects_2)
libgcjgc_convenience_la_OBJECTS = \
$(am_libgcjgc_convenience_la_OBJECTS)
-am__dirstamp = $(am__leading_dot)dirstamp
-am_libstaticrootslib_la_OBJECTS = tests/staticrootslib.lo
-libstaticrootslib_la_OBJECTS = $(am_libstaticrootslib_la_OBJECTS)
-libstaticrootslib_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(libstaticrootslib_la_LDFLAGS) $(LDFLAGS) -o $@
-am_gctest_OBJECTS = tests/test.$(OBJEXT)
-gctest_OBJECTS = $(am_gctest_OBJECTS)
-am__DEPENDENCIES_2 = libgcjgc.la $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
-gctest_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am_leaktest_OBJECTS = tests/leak_test.$(OBJEXT)
-leaktest_OBJECTS = $(am_leaktest_OBJECTS)
-leaktest_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am_middletest_OBJECTS = tests/middle.$(OBJEXT)
-middletest_OBJECTS = $(am_middletest_OBJECTS)
-middletest_DEPENDENCIES = $(am__DEPENDENCIES_2)
-am_staticrootstest_OBJECTS = tests/staticrootstest.$(OBJEXT)
-staticrootstest_OBJECTS = $(am_staticrootstest_OBJECTS)
-staticrootstest_DEPENDENCIES = $(am__DEPENDENCIES_2) \
- libstaticrootslib.la
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include
-depcomp =
-am__depfiles_maybe =
+depcomp = $(SHELL) $(top_srcdir)/../depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
LTCCASCOMPILE = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)
-SOURCES = $(libgcjgc_la_SOURCES) $(libgcjgc_convenience_la_SOURCES) \
- $(libstaticrootslib_la_SOURCES) $(gctest_SOURCES) \
- $(leaktest_SOURCES) $(middletest_SOURCES) \
- $(staticrootstest_SOURCES)
+SOURCES = $(libgcjgc_la_SOURCES) $(libgcjgc_convenience_la_SOURCES)
+DIST_SOURCES = $(am__libgcjgc_la_SOURCES_DIST) \
+ $(am__libgcjgc_convenience_la_SOURCES_DIST)
MULTISRCTOP =
MULTIBUILDTOP =
MULTIDIRS =
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
- $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir dist dist-all distcheck
ETAGS = etags
CTAGS = ctags
-am__tty_colors = \
-red=; grn=; lgn=; blu=; std=
DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+ { test ! -d "$(distdir)" \
+ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -fr "$(distdir)"; }; }
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_CPPFLAGS = @AM_CPPFLAGS@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADCFLAGS = @THREADCFLAGS@
THREADLIBS = @THREADLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
-AUTOMAKE_OPTIONS = cygnus subdir-objects
+AUTOMAKE_OPTIONS = foreign subdir-objects
ACLOCAL_AMFLAGS = -I .. -I ../config
-SUBDIRS = include
+SUBDIRS = include testsuite
noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
@POWERPC_DARWIN_FALSE@asm_libgcjgc_sources =
@POWERPC_DARWIN_TRUE@asm_libgcjgc_sources = powerpc_darwin_mach_dep.s
# Include THREADLIBS here to ensure that the correct versions of
# linuxthread semaphore functions get linked:
-libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
+libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
libgcjgc_la_DEPENDENCIES = $(addobjs)
libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
libgcjgc_convenience_la_LIBADD = $(addobjs)
libgcjgc_convenience_la_DEPENDENCIES = $(addobjs)
-AM_CXXFLAGS = $(GC_CFLAGS)
-AM_CFLAGS = $(GC_CFLAGS)
+AM_CXXFLAGS = $(GC_CFLAGS) $(THREADCFLAGS)
+AM_CFLAGS = $(GC_CFLAGS) $(THREADCFLAGS)
AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
-test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
-gctest_SOURCES = tests/test.c
-gctest_LDADD = $(test_ldadd)
-gctest_LDFLAGS = -shared-libgcc
-gctest_LINK = $(LINK) $(gctest_LDFLAGS)
-TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
-leaktest_SOURCES = tests/leak_test.c
-leaktest_LDADD = $(test_ldadd)
-leaktest_LDFLAGS = -shared-libgcc
-leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
-middletest_SOURCES = tests/middle.c
-middletest_LDADD = $(test_ldadd)
-middletest_LDFLAGS = -shared-libgcc
-middletest_LINK = $(LINK) $(middletest_LDFLAGS)
-staticrootstest_SOURCES = tests/staticrootstest.c
-staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
-staticrootstest_LDFLAGS = -shared-libgcc
-staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
-check_LTLIBRARIES = libstaticrootslib.la
-libstaticrootslib_la_SOURCES = tests/staticrootslib.c
-libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
-libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
- -rpath /nowhere -shared-libgcc
-
-libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
# Work around what appears to be a GNU make bug handling MAKEFLAGS
# values defined in terms of make variables, as is the case for CC and
threads.mk: $(top_builddir)/config.status $(srcdir)/threads.mk.in
cd $(top_builddir) && $(SHELL) ./config.status $@
-clean-checkLTLIBRARIES:
- -test -z "$(check_LTLIBRARIES)" || rm -f $(check_LTLIBRARIES)
- @list='$(check_LTLIBRARIES)'; for p in $$list; do \
- dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
- test "$$dir" != "$$p" || dir=.; \
- echo "rm -f \"$${dir}/so_locations\""; \
- rm -f "$${dir}/so_locations"; \
- done
-
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
$(libgcjgc_la_LINK) $(libgcjgc_la_OBJECTS) $(libgcjgc_la_LIBADD) $(LIBS)
libgcjgc_convenience.la: $(libgcjgc_convenience_la_OBJECTS) $(libgcjgc_convenience_la_DEPENDENCIES)
$(LINK) $(libgcjgc_convenience_la_OBJECTS) $(libgcjgc_convenience_la_LIBADD) $(LIBS)
-tests/$(am__dirstamp):
- @$(MKDIR_P) tests
- @: > tests/$(am__dirstamp)
-tests/staticrootslib.lo: tests/$(am__dirstamp)
-libstaticrootslib.la: $(libstaticrootslib_la_OBJECTS) $(libstaticrootslib_la_DEPENDENCIES)
- $(libstaticrootslib_la_LINK) $(libstaticrootslib_la_OBJECTS) $(libstaticrootslib_la_LIBADD) $(LIBS)
-
-clean-checkPROGRAMS:
- @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
- echo " rm -f" $$list; \
- rm -f $$list || exit $$?; \
- test -n "$(EXEEXT)" || exit 0; \
- list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f" $$list; \
- rm -f $$list
-tests/test.$(OBJEXT): tests/$(am__dirstamp)
-gctest$(EXEEXT): $(gctest_OBJECTS) $(gctest_DEPENDENCIES)
- @rm -f gctest$(EXEEXT)
- $(gctest_LINK) $(gctest_OBJECTS) $(gctest_LDADD) $(LIBS)
-tests/leak_test.$(OBJEXT): tests/$(am__dirstamp)
-leaktest$(EXEEXT): $(leaktest_OBJECTS) $(leaktest_DEPENDENCIES)
- @rm -f leaktest$(EXEEXT)
- $(leaktest_LINK) $(leaktest_OBJECTS) $(leaktest_LDADD) $(LIBS)
-tests/middle.$(OBJEXT): tests/$(am__dirstamp)
-middletest$(EXEEXT): $(middletest_OBJECTS) $(middletest_DEPENDENCIES)
- @rm -f middletest$(EXEEXT)
- $(middletest_LINK) $(middletest_OBJECTS) $(middletest_LDADD) $(LIBS)
-tests/staticrootstest.$(OBJEXT): tests/$(am__dirstamp)
-staticrootstest$(EXEEXT): $(staticrootstest_OBJECTS) $(staticrootstest_DEPENDENCIES)
- @rm -f staticrootstest$(EXEEXT)
- $(staticrootstest_LINK) $(staticrootstest_OBJECTS) $(staticrootstest_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
- -rm -f tests/leak_test.$(OBJEXT)
- -rm -f tests/middle.$(OBJEXT)
- -rm -f tests/staticrootslib.$(OBJEXT)
- -rm -f tests/staticrootslib.lo
- -rm -f tests/staticrootstest.$(OBJEXT)
- -rm -f tests/test.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/allchblk.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/backgraph.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blacklst.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checksums.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/darwin_stop_world.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbg_mlc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dyn_load.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/finalize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gc_dlopen.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcj_mlc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/headers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/malloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mallocx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mark.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mark_rts.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/new_hblk.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obj_map.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/os_dep.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pcr_interface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_stop_world.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pthread_support.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ptr_chck.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/real_malloc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/reclaim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/specific.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stubborn.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/typd_mlc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/win32_threads.Plo@am__quote@
+
.c.o:
- $(COMPILE) -c -o $@ $<
+@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ $<
.c.obj:
- $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
- $(LTCOMPILE) -c -o $@ $<
+@am__fastdepCC_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
.s.o:
$(CCASCOMPILE) -c -o $@ $<
clean-libtool:
-rm -rf .libs _libs
- -rm -rf tests/.libs tests/_libs
distclean-libtool:
-rm -f libtool config.lt
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-check-TESTS: $(TESTS)
- @failed=0; all=0; xfail=0; xpass=0; skip=0; \
- srcdir=$(srcdir); export srcdir; \
- list=' $(TESTS) '; \
- $(am__tty_colors); \
- if test -n "$$list"; then \
- for tst in $$list; do \
- if test -f ./$$tst; then dir=./; \
- elif test -f $$tst; then dir=; \
- else dir="$(srcdir)/"; fi; \
- if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
- all=`expr $$all + 1`; \
- case " $(XFAIL_TESTS) " in \
- *[\ \ ]$$tst[\ \ ]*) \
- xpass=`expr $$xpass + 1`; \
- failed=`expr $$failed + 1`; \
- col=$$red; res=XPASS; \
- ;; \
- *) \
- col=$$grn; res=PASS; \
- ;; \
- esac; \
- elif test $$? -ne 77; then \
- all=`expr $$all + 1`; \
- case " $(XFAIL_TESTS) " in \
- *[\ \ ]$$tst[\ \ ]*) \
- xfail=`expr $$xfail + 1`; \
- col=$$lgn; res=XFAIL; \
- ;; \
- *) \
- failed=`expr $$failed + 1`; \
- col=$$red; res=FAIL; \
- ;; \
- esac; \
- else \
- skip=`expr $$skip + 1`; \
- col=$$blu; res=SKIP; \
+distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ test -d "$(distdir)" || mkdir "$(distdir)"
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
- echo "$${col}$$res$${std}: $$tst"; \
- done; \
- if test "$$all" -eq 1; then \
- tests="test"; \
- All=""; \
- else \
- tests="tests"; \
- All="All "; \
- fi; \
- if test "$$failed" -eq 0; then \
- if test "$$xfail" -eq 0; then \
- banner="$$All$$all $$tests passed"; \
- else \
- if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
- banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
- if test "$$xpass" -eq 0; then \
- banner="$$failed of $$all $$tests failed"; \
- else \
- if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
- banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
- fi; \
- fi; \
- dashes="$$banner"; \
- skipped=""; \
- if test "$$skip" -ne 0; then \
- if test "$$skip" -eq 1; then \
- skipped="($$skip test was not run)"; \
- else \
- skipped="($$skip tests were not run)"; \
- fi; \
- test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
- dashes="$$skipped"; \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
fi; \
- report=""; \
- if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
- report="Please report to $(PACKAGE_BUGREPORT)"; \
- test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
- dashes="$$report"; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
fi; \
- dashes=`echo "$$dashes" | sed s/./=/g`; \
- if test "$$failed" -eq 0; then \
- echo "$$grn$$dashes"; \
- else \
- echo "$$red$$dashes"; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
fi; \
- echo "$$banner"; \
- test -z "$$skipped" || echo "$$skipped"; \
- test -z "$$report" || echo "$$report"; \
- echo "$$dashes$$std"; \
- test "$$failed" -eq 0; \
- else :; fi
-check-am: $(check_LTLIBRARIES) $(check_PROGRAMS)
- $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+ done
+ -test -n "$(am__skip_mode_fix)" \
+ || find "$(distdir)" -type d ! -perm -755 \
+ -exec chmod u+rwx,go+rx {} \; -o \
+ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+ || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+ tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+ $(am__remove_distdir)
+
+dist-lzma: distdir
+ tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+ $(am__remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+ $(am__remove_distdir)
+
+dist-tarZ: distdir
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__remove_distdir)
+
+dist-shar: distdir
+ shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ $(am__remove_distdir)
+
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__remove_distdir)
+
+dist dist-all: distdir
+ tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ case '$(DIST_ARCHIVES)' in \
+ *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+ *.tar.lzma*) \
+ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
+ *.tar.xz*) \
+ xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+ *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+ *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir); chmod a+w $(distdir)
+ mkdir $(distdir)/_build
+ mkdir $(distdir)/_inst
+ chmod a-w $(distdir)
+ test -d $(distdir)/_build || exit 0; \
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && am__cwd=`pwd` \
+ && $(am__cd) $(distdir)/_build \
+ && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && rm -rf $(DIST_ARCHIVES) \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+ && cd "$$am__cwd" \
+ || exit 1
+ $(am__remove_distdir)
+ @(echo "$(distdir) archives ready for distribution: "; \
+ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+ @$(am__cd) '$(distuninstallcheck_dir)' \
+ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
check: check-recursive
all-am: Makefile $(LTLIBRARIES) all-multi
installdirs: installdirs-recursive
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
- -rm -f tests/$(am__dirstamp)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-multi clean-recursive
-clean-am: clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
- clean-libtool clean-noinstLTLIBRARIES mostlyclean-am
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
distclean: distclean-multi distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
maintainer-clean: maintainer-clean-multi maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
+ -rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all-multi \
- check-am clean-multi ctags-recursive distclean-multi \
- install-am install-multi install-strip maintainer-clean-multi \
+ clean-multi ctags-recursive distclean-multi install-am \
+ install-multi install-strip maintainer-clean-multi \
mostlyclean-multi tags-recursive
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
- all all-am all-multi am--refresh check check-TESTS check-am \
- clean clean-checkLTLIBRARIES clean-checkPROGRAMS clean-generic \
- clean-libtool clean-multi clean-noinstLTLIBRARIES ctags \
- ctags-recursive distclean distclean-compile distclean-generic \
- distclean-libtool distclean-multi distclean-tags dvi dvi-am \
- html html-am info info-am install install-am install-data \
- install-data-am install-dvi install-dvi-am install-exec \
- install-exec-am install-html install-html-am install-info \
- install-info-am install-man install-multi install-pdf \
- install-pdf-am install-ps install-ps-am install-strip \
- installcheck installcheck-am installdirs installdirs-am \
- maintainer-clean maintainer-clean-generic \
+ all all-am all-multi am--refresh check check-am clean \
+ clean-generic clean-libtool clean-multi \
+ clean-noinstLTLIBRARIES ctags ctags-recursive dist dist-all \
+ dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ dist-xz \
+ dist-zip distcheck distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-multi \
+ distclean-tags distcleancheck distdir distuninstallcheck dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-multi \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-multi mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool mostlyclean-multi pdf \
pdf-am ps ps-am tags tags-recursive uninstall uninstall-am
POWERPC_DARWIN_FALSE
POWERPC_DARWIN_TRUE
THREADLIBS
+THREADCFLAGS
CXXCPP
CPP
OTOOL64
eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
} # ac_fn_c_check_member
-
-# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
-# -------------------------------------------------------
-# Tests whether HEADER exists, giving a warning if it cannot be compiled using
-# the include files in INCLUDES and setting the cache variable VAR
-# accordingly.
-ac_fn_c_check_header_mongrel ()
-{
- as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
- if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
- $as_echo_n "(cached) " >&6
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-else
- # Is the header compilable?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
-$as_echo_n "checking $2 usability... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-$4
-#include <$2>
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_header_compiler=yes
-else
- ac_header_compiler=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
-$as_echo "$ac_header_compiler" >&6; }
-
-# Is the header present?
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
-$as_echo_n "checking $2 presence... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <$2>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
- ac_header_preproc=yes
-else
- ac_header_preproc=no
-fi
-rm -f conftest.err conftest.$ac_ext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
-$as_echo "$ac_header_preproc" >&6; }
-
-# So? What about this header?
-case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
- yes:no: )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
-$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
- no:yes:* )
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
-$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
-$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
-$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
-$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
-$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
- ;;
-esac
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
-$as_echo_n "checking for $2... " >&6; }
-if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
- $as_echo_n "(cached) " >&6
-else
- eval "$3=\$ac_header_compiler"
-fi
-eval ac_res=\$$3
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-fi
- eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
-
-} # ac_fn_c_check_header_mongrel
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11393 "configure"
+#line 11307 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11499 "configure"
+#line 11413 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
AM_CPPFLAGS="-I`cd $srcdir && ${PWDCMD-pwd}`/include"
+THREADCFLAGS=
THREADLIBS=
case "$THREADS" in
no | none | single)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&5
$as_echo "$as_me: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&2;}
;;
- *-*-kfreebsd*-gnu)
+ *-*-kfreebsd*-gnu)
$as_echo "#define GC_FREEBSD_THREADS 1" >>confdefs.h
- INCLUDES="$INCLUDES -pthread"
- THREADDLLIBS=-pthread
+ THREADCFLAGS=-pthread
+ THREADLIBS=-pthread
$as_echo "#define _REENTRANT 1" >>confdefs.h
if test "${enable_parallel_mark}" = yes; then
$as_echo "#define USE_COMPILER_TLS 1" >>confdefs.h
- ;;
+ ;;
*-*-freebsd*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"FreeBSD does not yet fully support threads with Boehm GC.\"" >&5
$as_echo "$as_me: WARNING: \"FreeBSD does not yet fully support threads with Boehm GC.\"" >&2;}
$as_echo "#define GC_FREEBSD_THREADS 1" >>confdefs.h
- AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
+ THREADCFLAGS=-pthread
THREADLIBS=-pthread
;;
*-*-solaris2.8*)
# May want to enable it in other cases, too.
# Measurements havent yet been done.
fi
- AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
+ THREADCFLAGS=-pthread
THREADLIBS="-lpthread -lrt"
;;
esac
$as_echo "#define GC_WIN32_THREADS 1" >>confdefs.h
;;
- dgux386)
- THREADS=dgux386
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $THREADLIBS" >&5
-$as_echo "$THREADLIBS" >&6; }
- # Use pthread GCC switch
- THREADLIBS=-pthread
- if test "${enable_parallel_mark}" = yes; then
- $as_echo "#define PARALLEL_MARK 1" >>confdefs.h
-
- fi
- $as_echo "#define THREAD_LOCAL_ALLOC 1" >>confdefs.h
-
-
-$as_echo "#define GC_DGUX386_THREADS 1" >>confdefs.h
-
-
-$as_echo "#define DGUX_THREADS 1" >>confdefs.h
-
- # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
- AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
- ;;
aix)
THREADS=posix
THREADLIBS=-lpthread
esac
+
case "$host" in
powerpc-*-darwin*)
powerpc_darwin=true
-#
-# Check for AViiON Machines running DGUX
-#
-ac_is_dgux=no
-ac_fn_c_check_header_mongrel "$LINENO" "sys/dg_sys_info.h" "ac_cv_header_sys_dg_sys_info_h" "$ac_includes_default"
-if test "x$ac_cv_header_sys_dg_sys_info_h" = x""yes; then :
- ac_is_dgux=yes
-fi
-
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if host is AViiON running DGUX" >&5
-$as_echo_n "checking if host is AViiON running DGUX... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_is_dgux" >&5
-$as_echo "$ac_is_dgux" >&6; }
- ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
-if test $ac_is_dgux = yes; then
- if test "$enable_full_debug" = "yes"; then
- GC_CFLAGS="$GC_CFLAGS -mstandard"
- fi
- GC_CFLAGS="$GC_CFLAGS -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend"
-fi
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GCC optimization should be disabled" >&5
$as_echo_n "checking whether GCC optimization should be disabled... " >&6; }
O0_CFLAGS=
$as_echo "#define SAVE_CALL_COUNT 8" >>confdefs.h
;;
- i345686-*-dgux*)
- $as_echo "#define MAKE_BACK_GRAPH 1" >>confdefs.h
-
- ;;
esac
fi
fi
ac_config_headers="$ac_config_headers include/gc_config.h include/gc_ext_config.h"
-ac_config_files="$ac_config_files Makefile include/Makefile threads.mk"
+ac_config_files="$ac_config_files Makefile include/Makefile testsuite/Makefile threads.mk"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
"include/gc_ext_config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/gc_ext_config.h" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+ "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;;
"threads.mk") CONFIG_FILES="$CONFIG_FILES threads.mk" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
)
AM_CPPFLAGS="-I`cd $srcdir && ${PWDCMD-pwd}`/include"
+THREADCFLAGS=
THREADLIBS=
case "$THREADS" in
no | none | single)
*-*-hpux10*)
AC_MSG_WARN("Only HP-UX 11 POSIX threads are supported.")
;;
- *-*-kfreebsd*-gnu)
+ *-*-kfreebsd*-gnu)
AC_DEFINE(GC_FREEBSD_THREADS)
- INCLUDES="$INCLUDES -pthread"
- THREADDLLIBS=-pthread
+ THREADCFLAGS=-pthread
+ THREADLIBS=-pthread
AC_DEFINE(_REENTRANT)
if test "${enable_parallel_mark}" = yes; then
AC_DEFINE(PARALLEL_MARK)
fi
AC_DEFINE(THREAD_LOCAL_ALLOC)
AC_DEFINE(USE_COMPILER_TLS, 1,[use tls for boehm])
- ;;
+ ;;
*-*-freebsd*)
AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.")
AC_DEFINE(GC_FREEBSD_THREADS,1,[support FreeBSD threads])
- AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
+ THREADCFLAGS=-pthread
THREADLIBS=-pthread
;;
*-*-solaris2.8*)
# May want to enable it in other cases, too.
# Measurements havent yet been done.
fi
- AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
+ THREADCFLAGS=-pthread
THREADLIBS="-lpthread -lrt"
;;
esac
dnl Old wine getenv may not return NULL for missing entry.
dnl Define EMPTY_GETENV_RESULTS here to work around the bug.
;;
- dgux386)
- THREADS=dgux386
-AC_MSG_RESULT($THREADLIBS)
- # Use pthread GCC switch
- THREADLIBS=-pthread
- if test "${enable_parallel_mark}" = yes; then
- AC_DEFINE(PARALLEL_MARK,1)
- fi
- AC_DEFINE(THREAD_LOCAL_ALLOC,1)
- AC_DEFINE(GC_DGUX386_THREADS,1,[support for DB/UX on I386 threads])
- AC_DEFINE(DGUX_THREADS,1,[No description])
- # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
- AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
- ;;
aix)
THREADS=posix
THREADLIBS=-lpthread
AC_MSG_ERROR($THREADS is an unknown thread package)
;;
esac
+AC_SUBST(THREADCFLAGS)
AC_SUBST(THREADLIBS)
case "$host" in
AC_SUBST(addlibs)
AC_SUBST(addtests)
-#
-# Check for AViiON Machines running DGUX
-#
-ac_is_dgux=no
-AC_CHECK_HEADER(sys/dg_sys_info.h, [ac_is_dgux=yes])
-
-AC_MSG_CHECKING(if host is AViiON running DGUX)
-AC_MSG_RESULT($ac_is_dgux)
- ## :GOTCHA: we do not check anything but sys/dg_sys_info.h
-if test $ac_is_dgux = yes; then
- if test "$enable_full_debug" = "yes"; then
- GC_CFLAGS="$GC_CFLAGS -mstandard"
- fi
- GC_CFLAGS="$GC_CFLAGS -DDGUX -D_DGUX_SOURCE -Di386 -mno-legend"
-fi
-
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 Not needed anymore on Solaris.
AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
AC_DEFINE(SAVE_CALL_COUNT, 8, [number of call frames saved with objects allocated through the debugging interface])
;;
- i[3456]86-*-dgux*)
- AC_DEFINE(MAKE_BACK_GRAPH,1)
- ;;
esac
fi])
AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
-AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
+AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile threads.mk)
AC_OUTPUT
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
+THREADCFLAGS = @THREADCFLAGS@
THREADLIBS = @THREADLIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
+++ /dev/null
-#include "leak_detector.h"
-
-int main() {
- int *p[10];
- int i;
- GC_find_leak = 1; /* for new collect versions not compiled */
- /* with -DFIND_LEAK. */
- for (i = 0; i < 10; ++i) {
- p[i] = malloc(sizeof(int)+i);
- }
- CHECK_LEAKS();
- for (i = 1; i < 10; ++i) {
- free(p[i]);
- }
- for (i = 0; i < 9; ++i) {
- p[i] = malloc(sizeof(int)+i);
- }
- CHECK_LEAKS();
- CHECK_LEAKS();
- CHECK_LEAKS();
- return 0;
-}
+++ /dev/null
-/*
- * Test at the boundary between small and large objects.
- * Inspired by a test case from Zoltan Varga.
- */
-#include <gc.h>
-#include <stdio.h>
-
-int main ()
-{
- int i;
-
- GC_all_interior_pointers = 0;
-
- for (i = 0; i < 20000; ++i) {
- GC_malloc_atomic (4096);
- GC_malloc (4096);
- }
- for (i = 0; i < 20000; ++i) {
- GC_malloc_atomic (2048);
- GC_malloc (2048);
- }
- printf("Final heap size is %ld\n", GC_get_heap_size());
- return 0;
-}
-
+++ /dev/null
-#include <stdio.h>
-
-#ifndef GC_DEBUG
-# define GC_DEBUG
-#endif
-
-#include "gc.h"
-
-struct treenode {
- struct treenode *x;
- struct treenode *y;
-} * root[10];
-
-struct treenode * libsrl_mktree(int i)
-{
- struct treenode * r = GC_MALLOC(sizeof(struct treenode));
- if (0 == i) return 0;
- if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
- r -> x = libsrl_mktree(i-1);
- r -> y = libsrl_mktree(i-1);
- return r;
-}
-
-void * libsrl_init(void)
-{
- GC_INIT();
- return GC_MALLOC(sizeof(struct treenode));
-}
-
-void * libsrl_collect (void)
-{
- GC_gcollect();
-}
+++ /dev/null
-#include <stdio.h>
-
-#ifndef GC_DEBUG
-# define GC_DEBUG
-#endif
-
-#include "gc.h"
-#include "gc_backptr.h"
-
-struct treenode {
- struct treenode *x;
- struct treenode *y;
-} * root[10];
-
-static char *staticroot = 0;
-
-extern struct treenode * libsrl_mktree(int i);
-extern void * libsrl_init(void);
-extern void * libsrl_collect (void);
-
-int main(void)
-{
- int i;
- staticroot = libsrl_init();
- for (i = 0; i < sizeof(struct treenode); ++i) {
- staticroot[i] = 0x42;
- }
- libsrl_collect();
- for (i = 0; i < 10; ++i) {
- root[i] = libsrl_mktree(12);
- libsrl_collect();
- }
- for (i = 0; i < sizeof(struct treenode); ++i) {
- if (staticroot[i] != 0x42)
- return -1;
- }
- for (i = 0; i < 10; ++i) {
- root[i] = libsrl_mktree(12);
- libsrl_collect();
- }
- for (i = 0; i < sizeof(struct treenode); ++i) {
- if (staticroot[i] != 0x42)
- return -1;
- }
- return 0;
-}
+++ /dev/null
-/*
- * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
- * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
- * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
- *
- * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
- * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
- *
- * Permission is hereby granted to use or copy this program
- * for any purpose, provided the above notices are retained on all copies.
- * Permission to modify the code and to distribute modified code is granted,
- * provided the above notices are retained, and a notice that the code was
- * modified is included with the above copyright notice.
- */
-/* An incomplete test for the garbage collector. */
-/* Some more obscure entry points are not tested at all. */
-/* This must be compiled with the same flags used to build the */
-/* GC. It uses GC internals to allow more precise results */
-/* checking for some of the tests. */
-
-# undef GC_BUILD
-
-#if defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)
-# define GC_DEBUG
-#endif
-
-# if defined(mips) && defined(SYSTYPE_BSD43)
- /* MIPS RISCOS 4 */
-# else
-# include <stdlib.h>
-# endif
-# include <stdio.h>
-# ifdef _WIN32_WCE
-# include <winbase.h>
-# define assert ASSERT
-# else
-# include <assert.h> /* Not normally used, but handy for debugging. */
-# endif
-# include <assert.h> /* Not normally used, but handy for debugging. */
-# include "gc.h"
-# include "gc_typed.h"
-# ifdef THREAD_LOCAL_ALLOC
-# include "gc_local_alloc.h"
-# endif
-# include "private/gc_priv.h" /* For output, locking, MIN_WORDS, */
- /* and some statistics. */
-# include "private/gcconfig.h"
-
-# if defined(MSWIN32) || defined(MSWINCE)
-# include <windows.h>
-# endif
-
-# ifdef PCR
-# include "th/PCR_ThCrSec.h"
-# include "th/PCR_Th.h"
-# undef GC_printf0
-# define GC_printf0 printf
-# undef GC_printf1
-# define GC_printf1 printf
-# endif
-
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
-# include <thread.h>
-# include <synch.h>
-# endif
-
-# if defined(GC_PTHREADS)
-# include <pthread.h>
-# endif
-
-# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
- static CRITICAL_SECTION incr_cs;
-# endif
-
-#ifdef __STDC__
-# include <stdarg.h>
-#endif
-
-
-/* Allocation Statistics */
-int stubborn_count = 0;
-int uncollectable_count = 0;
-int collectable_count = 0;
-int atomic_count = 0;
-int realloc_count = 0;
-
-#if defined(GC_AMIGA_FASTALLOC) && defined(AMIGA)
-
- extern void GC_amiga_free_all_mem(void);
- void Amiga_Fail(void){GC_amiga_free_all_mem();abort();}
-# define FAIL (void)Amiga_Fail()
- void *GC_amiga_gctest_malloc_explicitly_typed(size_t lb, GC_descr d){
- void *ret=GC_malloc_explicitly_typed(lb,d);
- if(ret==NULL){
- if(!GC_dont_gc){
- GC_gcollect();
- ret=GC_malloc_explicitly_typed(lb,d);
- }
- if(ret==NULL){
- GC_printf0("Out of memory, (typed allocations are not directly "
- "supported with the GC_AMIGA_FASTALLOC option.)\n");
- FAIL;
- }
- }
- return ret;
- }
- void *GC_amiga_gctest_calloc_explicitly_typed(size_t a,size_t lb, GC_descr d){
- void *ret=GC_calloc_explicitly_typed(a,lb,d);
- if(ret==NULL){
- if(!GC_dont_gc){
- GC_gcollect();
- ret=GC_calloc_explicitly_typed(a,lb,d);
- }
- if(ret==NULL){
- GC_printf0("Out of memory, (typed allocations are not directly "
- "supported with the GC_AMIGA_FASTALLOC option.)\n");
- FAIL;
- }
- }
- return ret;
- }
-# define GC_malloc_explicitly_typed(a,b) GC_amiga_gctest_malloc_explicitly_typed(a,b)
-# define GC_calloc_explicitly_typed(a,b,c) GC_amiga_gctest_calloc_explicitly_typed(a,b,c)
-
-#else /* !AMIGA_FASTALLOC */
-
-# ifdef PCR
-# define FAIL (void)abort()
-# else
-# ifdef MSWINCE
-# define FAIL DebugBreak()
-# else
-# define FAIL GC_abort("Test failed");
-# endif
-# endif
-
-#endif /* !AMIGA_FASTALLOC */
-
-/* AT_END may be defined to exercise the interior pointer test */
-/* if the collector is configured with ALL_INTERIOR_POINTERS. */
-/* As it stands, this test should succeed with either */
-/* configuration. In the FIND_LEAK configuration, it should */
-/* find lots of leaks, since we free almost nothing. */
-
-struct SEXPR {
- struct SEXPR * sexpr_car;
- struct SEXPR * sexpr_cdr;
-};
-
-
-typedef struct SEXPR * sexpr;
-
-# define INT_TO_SEXPR(x) ((sexpr)(unsigned long)(x))
-
-# undef nil
-# define nil (INT_TO_SEXPR(0))
-# define car(x) ((x) -> sexpr_car)
-# define cdr(x) ((x) -> sexpr_cdr)
-# define is_nil(x) ((x) == nil)
-
-
-int extra_count = 0; /* Amount of space wasted in cons node */
-
-/* Silly implementation of Lisp cons. Intentionally wastes lots of space */
-/* to test collector. */
-# ifdef VERY_SMALL_CONFIG
-# define cons small_cons
-# else
-sexpr cons (x, y)
-sexpr x;
-sexpr y;
-{
- register sexpr r;
- register int *p;
- register int my_extra = extra_count;
-
- stubborn_count++;
- r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra);
- if (r == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- for (p = (int *)r;
- ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
- if (*p) {
- (void)GC_printf1("Found nonzero at 0x%lx - allocator is broken\n",
- (unsigned long)p);
- FAIL;
- }
- *p = 13;
- }
-# ifdef AT_END
- r = (sexpr)((char *)r + (my_extra & ~7));
-# endif
- r -> sexpr_car = x;
- r -> sexpr_cdr = y;
- my_extra++;
- if ( my_extra >= 5000 ) {
- extra_count = 0;
- } else {
- extra_count = my_extra;
- }
- GC_END_STUBBORN_CHANGE((char *)r);
- return(r);
-}
-# endif
-
-#ifdef GC_GCJ_SUPPORT
-
-#include "gc_mark.h"
-#include "gc_gcj.h"
-
-/* The following struct emulates the vtable in gcj. */
-/* This assumes the default value of MARK_DESCR_OFFSET. */
-struct fake_vtable {
- void * dummy; /* class pointer in real gcj. */
- size_t descr;
-};
-
-struct fake_vtable gcj_class_struct1 = { 0, sizeof(struct SEXPR)
- + sizeof(struct fake_vtable *) };
- /* length based descriptor. */
-struct fake_vtable gcj_class_struct2 =
- { 0, (3l << (CPP_WORDSZ - 3)) | GC_DS_BITMAP};
- /* Bitmap based descriptor. */
-
-struct GC_ms_entry * fake_gcj_mark_proc(word * addr,
- struct GC_ms_entry *mark_stack_ptr,
- struct GC_ms_entry *mark_stack_limit,
- word env )
-{
- sexpr x;
- if (1 == env) {
- /* Object allocated with debug allocator. */
- addr = (word *)GC_USR_PTR_FROM_BASE(addr);
- }
- x = (sexpr)(addr + 1); /* Skip the vtable pointer. */
- mark_stack_ptr = GC_MARK_AND_PUSH(
- (GC_PTR)(x -> sexpr_cdr), mark_stack_ptr,
- mark_stack_limit, (GC_PTR *)&(x -> sexpr_cdr));
- mark_stack_ptr = GC_MARK_AND_PUSH(
- (GC_PTR)(x -> sexpr_car), mark_stack_ptr,
- mark_stack_limit, (GC_PTR *)&(x -> sexpr_car));
- return(mark_stack_ptr);
-}
-
-#endif /* GC_GCJ_SUPPORT */
-
-#ifdef THREAD_LOCAL_ALLOC
-
-#undef GC_REDIRECT_TO_LOCAL
-#include "gc_local_alloc.h"
-
-sexpr local_cons (x, y)
-sexpr x;
-sexpr y;
-{
- register sexpr r;
- register int *p;
- register int my_extra = extra_count;
- static int my_random = 0;
-
- collectable_count++;
- r = (sexpr) GC_LOCAL_MALLOC(sizeof(struct SEXPR) + my_extra);
-# ifdef GC_GCJ_SUPPORT
- if (collectable_count % 2 == 0) {
- r = (sexpr) GC_LOCAL_GCJ_MALLOC(sizeof(struct SEXPR) + sizeof(GC_word) + my_extra,
- &gcj_class_struct1);
- r = (sexpr) ((GC_word *)r + 1);
- }
-# endif
- if (r == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- for (p = (int *)r;
- ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
- if (*p) {
- (void)GC_printf1("Found nonzero at 0x%lx (local) - allocator is broken\n",
- (unsigned long)p);
- FAIL;
- }
- *p = 13;
- }
- r -> sexpr_car = x;
- r -> sexpr_cdr = y;
- my_extra++;
- if ( my_extra >= 5000 || my_extra == 200 && ++my_random % 37 != 0) {
- extra_count = 0;
- } else {
- extra_count = my_extra;
- }
- return(r);
-}
-#endif /* THREAD_LOCAL_ALLOC */
-
-sexpr small_cons (x, y)
-sexpr x;
-sexpr y;
-{
- register sexpr r;
-
- collectable_count++;
- r = (sexpr) GC_MALLOC(sizeof(struct SEXPR));
- if (r == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- r -> sexpr_car = x;
- r -> sexpr_cdr = y;
- return(r);
-}
-
-sexpr small_cons_uncollectable (x, y)
-sexpr x;
-sexpr y;
-{
- register sexpr r;
-
- uncollectable_count++;
- r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR));
- if (r == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- r -> sexpr_car = x;
- r -> sexpr_cdr = (sexpr)(~(unsigned long)y);
- return(r);
-}
-
-#ifdef GC_GCJ_SUPPORT
-
-
-sexpr gcj_cons(x, y)
-sexpr x;
-sexpr y;
-{
- GC_word * r;
- sexpr result;
- static int count = 0;
-
- if (++count & 1) {
-# ifdef USE_MARK_BYTES
- r = (GC_word *) GC_GCJ_FAST_MALLOC(4, &gcj_class_struct1);
-# else
- r = (GC_word *) GC_GCJ_FAST_MALLOC(3, &gcj_class_struct1);
-# endif
- } else {
- r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR)
- + sizeof(struct fake_vtable*),
- &gcj_class_struct2);
- }
- if (r == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- result = (sexpr)(r + 1);
- result -> sexpr_car = x;
- result -> sexpr_cdr = y;
- return(result);
-}
-#endif
-
-/* Return reverse(x) concatenated with y */
-sexpr reverse1(x, y)
-sexpr x, y;
-{
- if (is_nil(x)) {
- return(y);
- } else {
- return( reverse1(cdr(x), cons(car(x), y)) );
- }
-}
-
-sexpr reverse(x)
-sexpr x;
-{
-# ifdef TEST_WITH_SYSTEM_MALLOC
- malloc(100000);
-# endif
- return( reverse1(x, nil) );
-}
-
-sexpr ints(low, up)
-int low, up;
-{
- if (low > up) {
- return(nil);
- } else {
- return(small_cons(small_cons(INT_TO_SEXPR(low), nil), ints(low+1, up)));
- }
-}
-
-#ifdef GC_GCJ_SUPPORT
-/* Return reverse(x) concatenated with y */
-sexpr gcj_reverse1(x, y)
-sexpr x, y;
-{
- if (is_nil(x)) {
- return(y);
- } else {
- return( gcj_reverse1(cdr(x), gcj_cons(car(x), y)) );
- }
-}
-
-sexpr gcj_reverse(x)
-sexpr x;
-{
- return( gcj_reverse1(x, nil) );
-}
-
-sexpr gcj_ints(low, up)
-int low, up;
-{
- if (low > up) {
- return(nil);
- } else {
- return(gcj_cons(gcj_cons(INT_TO_SEXPR(low), nil), gcj_ints(low+1, up)));
- }
-}
-#endif /* GC_GCJ_SUPPORT */
-
-#ifdef THREAD_LOCAL_ALLOC
-/* Return reverse(x) concatenated with y */
-sexpr local_reverse1(x, y)
-sexpr x, y;
-{
- if (is_nil(x)) {
- return(y);
- } else {
- return( local_reverse1(cdr(x), local_cons(car(x), y)) );
- }
-}
-
-sexpr local_reverse(x)
-sexpr x;
-{
- return( local_reverse1(x, nil) );
-}
-
-sexpr local_ints(low, up)
-int low, up;
-{
- if (low > up) {
- return(nil);
- } else {
- return(local_cons(local_cons(INT_TO_SEXPR(low), nil), local_ints(low+1, up)));
- }
-}
-#endif /* THREAD_LOCAL_ALLOC */
-
-/* To check uncollectable allocation we build lists with disguised cdr */
-/* pointers, and make sure they don't go away. */
-sexpr uncollectable_ints(low, up)
-int low, up;
-{
- if (low > up) {
- return(nil);
- } else {
- return(small_cons_uncollectable(small_cons(INT_TO_SEXPR(low), nil),
- uncollectable_ints(low+1, up)));
- }
-}
-
-void check_ints(list, low, up)
-sexpr list;
-int low, up;
-{
- if ((int)(GC_word)(car(car(list))) != low) {
- (void)GC_printf0(
- "List reversal produced incorrect list - collector is broken\n");
- FAIL;
- }
- if (low == up) {
- if (cdr(list) != nil) {
- (void)GC_printf0("List too long - collector is broken\n");
- FAIL;
- }
- } else {
- check_ints(cdr(list), low+1, up);
- }
-}
-
-# define UNCOLLECTABLE_CDR(x) (sexpr)(~(unsigned long)(cdr(x)))
-
-void check_uncollectable_ints(list, low, up)
-sexpr list;
-int low, up;
-{
- if ((int)(GC_word)(car(car(list))) != low) {
- (void)GC_printf0(
- "Uncollectable list corrupted - collector is broken\n");
- FAIL;
- }
- if (low == up) {
- if (UNCOLLECTABLE_CDR(list) != nil) {
- (void)GC_printf0("Uncollectable list too long - collector is broken\n");
- FAIL;
- }
- } else {
- check_uncollectable_ints(UNCOLLECTABLE_CDR(list), low+1, up);
- }
-}
-
-/* Not used, but useful for debugging: */
-void print_int_list(x)
-sexpr x;
-{
- if (is_nil(x)) {
- (void)GC_printf0("NIL\n");
- } else {
- (void)GC_printf1("(%ld)", (long)(car(car(x))));
- if (!is_nil(cdr(x))) {
- (void)GC_printf0(", ");
- (void)print_int_list(cdr(x));
- } else {
- (void)GC_printf0("\n");
- }
- }
-}
-
-/*
- * A tiny list reversal test to check thread creation.
- */
-#ifdef THREADS
-
-# if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
- DWORD __stdcall tiny_reverse_test(void * arg)
-# else
- void * tiny_reverse_test(void * arg)
-# endif
-{
- int i;
- for (i = 0; i < 5; ++i) {
- check_ints(reverse(reverse(ints(1,10))), 1, 10);
-# ifdef THREAD_LOCAL_ALLOC
- check_ints(local_reverse(local_reverse(local_ints(1,10))), 1, 10);
-# endif
- }
- return 0;
-}
-
-# if defined(GC_PTHREADS)
- void fork_a_thread()
- {
- pthread_t t;
- int code;
- if ((code = pthread_create(&t, 0, tiny_reverse_test, 0)) != 0) {
- (void)GC_printf1("Small thread creation failed %lu\n",
- (unsigned long)code);
- FAIL;
- }
- if ((code = pthread_join(t, 0)) != 0) {
- (void)GC_printf1("Small thread join failed %lu\n",
- (unsigned long)code);
- FAIL;
- }
- }
-
-# elif defined(GC_WIN32_THREADS)
- void fork_a_thread()
- {
- DWORD thread_id;
- HANDLE h;
- h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
- if (h == (HANDLE)NULL) {
- (void)GC_printf1("Small thread creation failed %lu\n",
- (unsigned long)GetLastError());
- FAIL;
- }
- if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) {
- (void)GC_printf1("Small thread wait failed %lu\n",
- (unsigned long)GetLastError());
- FAIL;
- }
- }
-
-/* # elif defined(GC_SOLARIS_THREADS) */
-
-# else
-
-# define fork_a_thread()
-
-# endif
-
-#else
-
-# define fork_a_thread()
-
-#endif
-
-/* Try to force a to be strangely aligned */
-struct {
- char dummy;
- sexpr aa;
-} A;
-#define a A.aa
-
-/*
- * Repeatedly reverse lists built out of very different sized cons cells.
- * Check that we didn't lose anything.
- */
-void reverse_test()
-{
- int i;
- sexpr b;
- sexpr c;
- sexpr d;
- sexpr e;
- sexpr *f, *g, *h;
-# if defined(MSWIN32) || defined(MACOS)
- /* Win32S only allows 128K stacks */
-# define BIG 1000
-# else
-# if defined PCR
- /* PCR default stack is 100K. Stack frames are up to 120 bytes. */
-# define BIG 700
-# else
-# if defined MSWINCE
- /* WinCE only allows 64K stacks */
-# define BIG 500
-# else
-# if defined(OSF1)
- /* OSF has limited stack space by default, and large frames. */
-# define BIG 200
-# else
-# if defined(__MACH__) && defined(__ppc64__)
- /* Small stack and largish frames. */
-# define BIG 2500
-# else
-# define BIG 4500
-# endif
-# endif
-# endif
-# endif
-# endif
-
- A.dummy = 17;
- a = ints(1, 49);
- b = ints(1, 50);
- c = ints(1, BIG);
- d = uncollectable_ints(1, 100);
- e = uncollectable_ints(1, 1);
- /* Check that realloc updates object descriptors correctly */
- collectable_count++;
- f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr));
- realloc_count++;
- f = (sexpr *)GC_REALLOC((GC_PTR)f, 6 * sizeof(sexpr));
- f[5] = ints(1,17);
- collectable_count++;
- g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr));
- realloc_count++;
- g = (sexpr *)GC_REALLOC((GC_PTR)g, 800 * sizeof(sexpr));
- g[799] = ints(1,18);
- collectable_count++;
- h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr));
- realloc_count++;
- h = (sexpr *)GC_REALLOC((GC_PTR)h, 2000 * sizeof(sexpr));
-# ifdef GC_GCJ_SUPPORT
- h[1999] = gcj_ints(1,200);
- for (i = 0; i < 51; ++i)
- h[1999] = gcj_reverse(h[1999]);
- /* Leave it as the reveresed list for now. */
-# else
- h[1999] = ints(1,200);
-# endif
- /* Try to force some collections and reuse of small list elements */
- for (i = 0; i < 10; i++) {
- (void)ints(1, BIG);
- }
- /* Superficially test interior pointer recognition on stack */
- c = (sexpr)((char *)c + sizeof(char *));
- d = (sexpr)((char *)d + sizeof(char *));
-
-# ifdef __STDC__
- GC_FREE((void *)e);
-# else
- GC_FREE((char *)e);
-# endif
- check_ints(b,1,50);
- check_ints(a,1,49);
- for (i = 0; i < 50; i++) {
- check_ints(b,1,50);
- b = reverse(reverse(b));
- }
- check_ints(b,1,50);
- check_ints(a,1,49);
- for (i = 0; i < 60; i++) {
- if (i % 10 == 0) fork_a_thread();
- /* This maintains the invariant that a always points to a list of */
- /* 49 integers. Thus this is thread safe without locks, */
- /* assuming atomic pointer assignments. */
- a = reverse(reverse(a));
-# ifdef THREAD_LOCAL_ALLOC
- a = local_reverse(local_reverse(a));
-# endif
-# if !defined(AT_END) && !defined(THREADS)
- /* This is not thread safe, since realloc explicitly deallocates */
- if (i & 1) {
- a = (sexpr)GC_REALLOC((GC_PTR)a, 500);
- } else {
- a = (sexpr)GC_REALLOC((GC_PTR)a, 8200);
- }
-# endif
- }
- check_ints(a,1,49);
- check_ints(b,1,50);
- c = (sexpr)((char *)c - sizeof(char *));
- d = (sexpr)((char *)d - sizeof(char *));
- check_ints(c,1,BIG);
- check_uncollectable_ints(d, 1, 100);
- check_ints(f[5], 1,17);
- check_ints(g[799], 1,18);
-# ifdef GC_GCJ_SUPPORT
- h[1999] = gcj_reverse(h[1999]);
-# endif
- check_ints(h[1999], 1,200);
-# ifndef THREADS
- a = 0;
-# endif
- b = c = 0;
-}
-
-#undef a
-
-/*
- * The rest of this builds balanced binary trees, checks that they don't
- * disappear, and tests finalization.
- */
-typedef struct treenode {
- int level;
- struct treenode * lchild;
- struct treenode * rchild;
-} tn;
-
-int finalizable_count = 0;
-int finalized_count = 0;
-VOLATILE int dropped_something = 0;
-
-# ifdef __STDC__
- void finalizer(void * obj, void * client_data)
-# else
- void finalizer(obj, client_data)
- char * obj;
- char * client_data;
-# endif
-{
- tn * t = (tn *)obj;
-
-# ifdef PCR
- PCR_ThCrSec_EnterSys();
-# endif
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
- static mutex_t incr_lock;
- mutex_lock(&incr_lock);
-# endif
-# if defined(GC_PTHREADS)
- static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
- pthread_mutex_lock(&incr_lock);
-# else
-# ifdef GC_WIN32_THREADS
- EnterCriticalSection(&incr_cs);
-# endif
-# endif
- if ((int)(GC_word)client_data != t -> level) {
- (void)GC_printf0("Wrong finalization data - collector is broken\n");
- FAIL;
- }
- finalized_count++;
- t -> level = -1; /* detect duplicate finalization immediately */
-# ifdef PCR
- PCR_ThCrSec_ExitSys();
-# endif
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
- mutex_unlock(&incr_lock);
-# endif
-# if defined(GC_PTHREADS)
- pthread_mutex_unlock(&incr_lock);
-# else
-# ifdef GC_WIN32_THREADS
- LeaveCriticalSection(&incr_cs);
-# endif
-# endif
-}
-
-size_t counter = 0;
-
-# define MAX_FINALIZED 8000
-
-# if !defined(MACOS)
- GC_FAR GC_word live_indicators[MAX_FINALIZED] = {0};
-#else
- /* Too big for THINK_C. have to allocate it dynamically. */
- GC_word *live_indicators = 0;
-#endif
-
-int live_indicators_count = 0;
-
-tn * mktree(n)
-int n;
-{
-# ifdef THREAD_LOCAL_ALLOC
- tn * result = (tn *)GC_LOCAL_MALLOC(sizeof(tn));
-# else
- tn * result = (tn *)GC_MALLOC(sizeof(tn));
-# endif
-
- collectable_count++;
-# ifdef THREAD_LOCAL_ALLOC
- /* Minimally exercise thread local allocation */
- {
- char * result = (char *)GC_LOCAL_MALLOC_ATOMIC(17);
- memset(result, 'a', 17);
- }
-# endif /* THREAD_LOCAL_ALLOC */
-# if defined(MACOS)
- /* get around static data limitations. */
- if (!live_indicators)
- live_indicators =
- (GC_word*)NewPtrClear(MAX_FINALIZED * sizeof(GC_word));
- if (!live_indicators) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
-# endif
- if (n == 0) return(0);
- if (result == 0) {
- (void)GC_printf0("Out of memory\n");
- exit(1);
- }
- result -> level = n;
- result -> lchild = mktree(n-1);
- result -> rchild = mktree(n-1);
- if (counter++ % 17 == 0 && n >= 2) {
- tn * tmp = result -> lchild -> rchild;
-
- result -> lchild -> rchild = result -> rchild -> lchild;
- result -> rchild -> lchild = tmp;
- }
- if (counter++ % 119 == 0) {
- int my_index;
-
- {
-# ifdef PCR
- PCR_ThCrSec_EnterSys();
-# endif
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
- static mutex_t incr_lock;
- mutex_lock(&incr_lock);
-# endif
-# if defined(GC_PTHREADS)
- static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
- pthread_mutex_lock(&incr_lock);
-# else
-# ifdef GC_WIN32_THREADS
- EnterCriticalSection(&incr_cs);
-# endif
-# endif
- /* Losing a count here causes erroneous report of failure. */
- finalizable_count++;
- my_index = live_indicators_count++;
-# ifdef PCR
- PCR_ThCrSec_ExitSys();
-# endif
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
- mutex_unlock(&incr_lock);
-# endif
-# if defined(GC_PTHREADS)
- pthread_mutex_unlock(&incr_lock);
-# else
-# ifdef GC_WIN32_THREADS
- LeaveCriticalSection(&incr_cs);
-# endif
-# endif
- }
-
- GC_REGISTER_FINALIZER((GC_PTR)result, finalizer, (GC_PTR)(GC_word)n,
- (GC_finalization_proc *)0, (GC_PTR *)0);
- if (my_index >= MAX_FINALIZED) {
- GC_printf0("live_indicators overflowed\n");
- FAIL;
- }
- live_indicators[my_index] = 13;
- if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
- (GC_PTR *)(&(live_indicators[my_index])),
- (GC_PTR)result) != 0) {
- GC_printf0("GC_general_register_disappearing_link failed\n");
- FAIL;
- }
- if (GC_unregister_disappearing_link(
- (GC_PTR *)
- (&(live_indicators[my_index]))) == 0) {
- GC_printf0("GC_unregister_disappearing_link failed\n");
- FAIL;
- }
- if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
- (GC_PTR *)(&(live_indicators[my_index])),
- (GC_PTR)result) != 0) {
- GC_printf0("GC_general_register_disappearing_link failed 2\n");
- FAIL;
- }
- }
- return(result);
-}
-
-void chktree(t,n)
-tn *t;
-int n;
-{
- if (n == 0 && t != 0) {
- (void)GC_printf0("Clobbered a leaf - collector is broken\n");
- FAIL;
- }
- if (n == 0) return;
- if (t -> level != n) {
- (void)GC_printf1("Lost a node at level %lu - collector is broken\n",
- (unsigned long)n);
- FAIL;
- }
- if (counter++ % 373 == 0) {
- collectable_count++;
- (void) GC_MALLOC(counter%5001);
- }
- chktree(t -> lchild, n-1);
- if (counter++ % 73 == 0) {
- collectable_count++;
- (void) GC_MALLOC(counter%373);
- }
- chktree(t -> rchild, n-1);
-}
-
-# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
-thread_key_t fl_key;
-
-void * alloc8bytes()
-{
-# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
- collectable_count++;
- return(GC_MALLOC(8));
-# else
- void ** my_free_list_ptr;
- void * my_free_list;
-
- if (thr_getspecific(fl_key, (void **)(&my_free_list_ptr)) != 0) {
- (void)GC_printf0("thr_getspecific failed\n");
- FAIL;
- }
- if (my_free_list_ptr == 0) {
- uncollectable_count++;
- my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
- if (thr_setspecific(fl_key, my_free_list_ptr) != 0) {
- (void)GC_printf0("thr_setspecific failed\n");
- FAIL;
- }
- }
- my_free_list = *my_free_list_ptr;
- if (my_free_list == 0) {
- collectable_count++;
- my_free_list = GC_malloc_many(8);
- if (my_free_list == 0) {
- (void)GC_printf0("alloc8bytes out of memory\n");
- FAIL;
- }
- }
- *my_free_list_ptr = GC_NEXT(my_free_list);
- GC_NEXT(my_free_list) = 0;
- return(my_free_list);
-# endif
-}
-
-#else
-
-# if defined(GC_PTHREADS)
-pthread_key_t fl_key;
-
-void * alloc8bytes()
-{
-# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
- collectable_count++;
- return(GC_MALLOC(8));
-# else
- void ** my_free_list_ptr;
- void * my_free_list;
-
- my_free_list_ptr = (void **)pthread_getspecific(fl_key);
- if (my_free_list_ptr == 0) {
- uncollectable_count++;
- my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
- if (pthread_setspecific(fl_key, my_free_list_ptr) != 0) {
- (void)GC_printf0("pthread_setspecific failed\n");
- FAIL;
- }
- }
- my_free_list = *my_free_list_ptr;
- if (my_free_list == 0) {
- my_free_list = GC_malloc_many(8);
- if (my_free_list == 0) {
- (void)GC_printf0("alloc8bytes out of memory\n");
- FAIL;
- }
- }
- *my_free_list_ptr = GC_NEXT(my_free_list);
- GC_NEXT(my_free_list) = 0;
- collectable_count++;
- return(my_free_list);
-# endif
-}
-
-# else
-# define alloc8bytes() GC_MALLOC_ATOMIC(8)
-# endif
-#endif
-
-void alloc_small(n)
-int n;
-{
- register int i;
-
- for (i = 0; i < n; i += 8) {
- atomic_count++;
- if (alloc8bytes() == 0) {
- (void)GC_printf0("Out of memory\n");
- FAIL;
- }
- }
-}
-
-# if defined(THREADS) && defined(GC_DEBUG)
-# ifdef VERY_SMALL_CONFIG
-# define TREE_HEIGHT 12
-# else
-# define TREE_HEIGHT 15
-# endif
-# else
-# ifdef VERY_SMALL_CONFIG
-# define TREE_HEIGHT 13
-# else
-# define TREE_HEIGHT 16
-# endif
-# endif
-void tree_test()
-{
- tn * root;
- register int i;
-
- root = mktree(TREE_HEIGHT);
-# ifndef VERY_SMALL_CONFIG
- alloc_small(5000000);
-# endif
- chktree(root, TREE_HEIGHT);
- if (finalized_count && ! dropped_something) {
- (void)GC_printf0("Premature finalization - collector is broken\n");
- FAIL;
- }
- dropped_something = 1;
- GC_noop(root); /* Root needs to remain live until */
- /* dropped_something is set. */
- root = mktree(TREE_HEIGHT);
- chktree(root, TREE_HEIGHT);
- for (i = TREE_HEIGHT; i >= 0; i--) {
- root = mktree(i);
- chktree(root, i);
- }
-# ifndef VERY_SMALL_CONFIG
- alloc_small(5000000);
-# endif
-}
-
-unsigned n_tests = 0;
-
-GC_word bm_huge[10] = {
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0xffffffff,
- 0x00ffffff,
-};
-
-/* A very simple test of explicitly typed allocation */
-void typed_test()
-{
- GC_word * old, * new;
- GC_word bm3 = 0x3;
- GC_word bm2 = 0x2;
- GC_word bm_large = 0xf7ff7fff;
- GC_descr d1 = GC_make_descriptor(&bm3, 2);
- GC_descr d2 = GC_make_descriptor(&bm2, 2);
-# ifndef LINT
- GC_descr dummy = GC_make_descriptor(&bm_large, 32);
-# endif
- GC_descr d3 = GC_make_descriptor(&bm_large, 32);
- GC_descr d4 = GC_make_descriptor(bm_huge, 320);
- GC_word * x = (GC_word *)GC_malloc_explicitly_typed(2000, d4);
- register int i;
-
- collectable_count++;
- old = 0;
- for (i = 0; i < 4000; i++) {
- collectable_count++;
- new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d1);
- if (0 != new[0] || 0 != new[1]) {
- GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
- FAIL;
- }
- new[0] = 17;
- new[1] = (GC_word)old;
- old = new;
- collectable_count++;
- new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d2);
- new[0] = 17;
- new[1] = (GC_word)old;
- old = new;
- collectable_count++;
- new = (GC_word *) GC_malloc_explicitly_typed(33 * sizeof(GC_word), d3);
- new[0] = 17;
- new[1] = (GC_word)old;
- old = new;
- collectable_count++;
- new = (GC_word *) GC_calloc_explicitly_typed(4, 2 * sizeof(GC_word),
- d1);
- new[0] = 17;
- new[1] = (GC_word)old;
- old = new;
- collectable_count++;
- if (i & 0xff) {
- new = (GC_word *) GC_calloc_explicitly_typed(7, 3 * sizeof(GC_word),
- d2);
- } else {
- new = (GC_word *) GC_calloc_explicitly_typed(1001,
- 3 * sizeof(GC_word),
- d2);
- if (0 != new[0] || 0 != new[1]) {
- GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
- FAIL;
- }
- }
- new[0] = 17;
- new[1] = (GC_word)old;
- old = new;
- }
- for (i = 0; i < 20000; i++) {
- if (new[0] != 17) {
- (void)GC_printf1("typed alloc failed at %lu\n",
- (unsigned long)i);
- FAIL;
- }
- new[0] = 0;
- old = new;
- new = (GC_word *)(old[1]);
- }
- GC_gcollect();
- GC_noop(x);
-}
-
-int fail_count = 0;
-
-#ifndef __STDC__
-/*ARGSUSED*/
-void fail_proc1(x)
-GC_PTR x;
-{
- fail_count++;
-}
-
-#else
-
-/*ARGSUSED*/
-void fail_proc1(GC_PTR x)
-{
- fail_count++;
-}
-
-static void uniq(void *p, ...) {
- va_list a;
- void *q[100];
- int n = 0, i, j;
- q[n++] = p;
- va_start(a,p);
- for (;(q[n] = va_arg(a,void *));n++) ;
- va_end(a);
- for (i=0; i<n; i++)
- for (j=0; j<i; j++)
- if (q[i] == q[j]) {
- GC_printf0(
- "Apparently failed to mark form some function arguments.\n"
- "Perhaps GC_push_regs was configured incorrectly?\n"
- );
- FAIL;
- }
-}
-
-#endif /* __STDC__ */
-
-#ifdef THREADS
-# define TEST_FAIL_COUNT(n) 1
-#else
-# define TEST_FAIL_COUNT(n) (fail_count >= (n))
-#endif
-
-void run_one_test()
-{
- char *x;
-# ifdef LINT
- char *y = 0;
-# else
- char *y = (char *)(size_t)fail_proc1;
-# endif
- DCL_LOCK_STATE;
-
-# ifdef FIND_LEAK
- (void)GC_printf0(
- "This test program is not designed for leak detection mode\n");
- (void)GC_printf0("Expect lots of problems.\n");
-# endif
- GC_FREE(0);
-# ifndef DBG_HDRS_ALL
- collectable_count += 3;
- if (GC_size(GC_malloc(7)) != 8 &&
- GC_size(GC_malloc(7)) != MIN_WORDS * sizeof(GC_word)
- || GC_size(GC_malloc(15)) != 16) {
- (void)GC_printf0("GC_size produced unexpected results\n");
- FAIL;
- }
- collectable_count += 1;
- if (GC_size(GC_malloc(0)) != MIN_WORDS * sizeof(GC_word)) {
- (void)GC_printf1("GC_malloc(0) failed: GC_size returns %ld\n",
- GC_size(GC_malloc(0)));
- FAIL;
- }
- collectable_count += 1;
- if (GC_size(GC_malloc_uncollectable(0)) != MIN_WORDS * sizeof(GC_word)) {
- (void)GC_printf0("GC_malloc_uncollectable(0) failed\n");
- FAIL;
- }
- GC_is_valid_displacement_print_proc = fail_proc1;
- GC_is_visible_print_proc = fail_proc1;
- collectable_count += 1;
- x = GC_malloc(16);
- if (GC_base(x + 13) != x) {
- (void)GC_printf0("GC_base(heap ptr) produced incorrect result\n");
- FAIL;
- }
-# ifndef PCR
- if (GC_base(y) != 0) {
- (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n");
- FAIL;
- }
-# endif
- if (GC_same_obj(x+5, x) != x + 5) {
- (void)GC_printf0("GC_same_obj produced incorrect result\n");
- FAIL;
- }
- if (GC_is_visible(y) != y || GC_is_visible(x) != x) {
- (void)GC_printf0("GC_is_visible produced incorrect result\n");
- FAIL;
- }
- if (!TEST_FAIL_COUNT(1)) {
-# if!(defined(RS6000) || defined(POWERPC) || defined(IA64)) || defined(M68K)
- /* ON RS6000s function pointers point to a descriptor in the */
- /* data segment, so there should have been no failures. */
- /* The same applies to IA64. Something similar seems to */
- /* be going on with NetBSD/M68K. */
- (void)GC_printf0("GC_is_visible produced wrong failure indication\n");
- FAIL;
-# endif
- }
- if (GC_is_valid_displacement(y) != y
- || GC_is_valid_displacement(x) != x
- || GC_is_valid_displacement(x + 3) != x + 3) {
- (void)GC_printf0(
- "GC_is_valid_displacement produced incorrect result\n");
- FAIL;
- }
-# if defined(__STDC__) && !defined(MSWIN32) && !defined(MSWINCE)
- /* Harder to test under Windows without a gc.h declaration. */
- {
- size_t i;
- extern void *GC_memalign();
-
- GC_malloc(17);
- for (i = sizeof(GC_word); i < 512; i *= 2) {
- GC_word result = (GC_word) GC_memalign(i, 17);
- if (result % i != 0 || result == 0 || *(int *)result != 0) FAIL;
- }
- }
-# endif
-# ifndef ALL_INTERIOR_POINTERS
-# if defined(RS6000) || defined(POWERPC)
- if (!TEST_FAIL_COUNT(1)) {
-# else
- if (GC_all_interior_pointers && !TEST_FAIL_COUNT(1)
- || !GC_all_interior_pointers && !TEST_FAIL_COUNT(2)) {
-# endif
- (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n");
- FAIL;
- }
-# endif
-# endif /* DBG_HDRS_ALL */
- /* Test floating point alignment */
- collectable_count += 2;
- *(double *)GC_MALLOC(sizeof(double)) = 1.0;
- *(double *)GC_MALLOC(sizeof(double)) = 1.0;
-# ifdef GC_GCJ_SUPPORT
- GC_REGISTER_DISPLACEMENT(sizeof(struct fake_vtable *));
- GC_init_gcj_malloc(0, (void *)fake_gcj_mark_proc);
-# endif
- /* Make sure that fn arguments are visible to the collector. */
-# ifdef __STDC__
- uniq(
- GC_malloc(12), GC_malloc(12), GC_malloc(12),
- (GC_gcollect(),GC_malloc(12)),
- GC_malloc(12), GC_malloc(12), GC_malloc(12),
- (GC_gcollect(),GC_malloc(12)),
- GC_malloc(12), GC_malloc(12), GC_malloc(12),
- (GC_gcollect(),GC_malloc(12)),
- GC_malloc(12), GC_malloc(12), GC_malloc(12),
- (GC_gcollect(),GC_malloc(12)),
- GC_malloc(12), GC_malloc(12), GC_malloc(12),
- (GC_gcollect(),GC_malloc(12)),
- (void *)0);
-# endif
- /* Repeated list reversal test. */
- reverse_test();
-# ifdef PRINTSTATS
- GC_printf0("-------------Finished reverse_test\n");
-# endif
-# ifndef DBG_HDRS_ALL
- typed_test();
-# ifdef PRINTSTATS
- GC_printf0("-------------Finished typed_test\n");
-# endif
-# endif /* DBG_HDRS_ALL */
- tree_test();
- LOCK();
- n_tests++;
- UNLOCK();
-# if defined(THREADS) && defined(HANDLE_FORK)
- if (fork() == 0) {
- GC_gcollect();
- tiny_reverse_test(0);
- GC_gcollect();
- GC_printf0("Finished a child process\n");
- exit(0);
- }
-# endif
- /* GC_printf1("Finished %x\n", pthread_self()); */
-}
-
-void check_heap_stats()
-{
- unsigned long max_heap_sz;
- register int i;
- int still_live;
- int late_finalize_count = 0;
-
-# ifdef VERY_SMALL_CONFIG
- /* these are something of a guess */
- if (sizeof(char *) > 4) {
- max_heap_sz = 4500000;
- } else {
- max_heap_sz = 2800000;
- }
-# else
- if (sizeof(char *) > 4) {
- max_heap_sz = 19000000;
- } else {
- max_heap_sz = 11000000;
- }
-# endif
-# ifndef ALIGN_DOUBLE
- /* We end up needing more small object pages. */
- max_heap_sz += 2000000;
-# endif
-# ifdef GC_DEBUG
- max_heap_sz *= 2;
-# ifdef SAVE_CALL_CHAIN
- max_heap_sz *= 3;
-# ifdef SAVE_CALL_COUNT
- max_heap_sz += max_heap_sz * SAVE_CALL_COUNT/4;
-# endif
-# endif
-# endif
- /* Garbage collect repeatedly so that all inaccessible objects */
- /* can be finalized. */
- while (GC_collect_a_little()) { }
- for (i = 0; i < 16; i++) {
- GC_gcollect();
- late_finalize_count += GC_invoke_finalizers();
- }
- (void)GC_printf1("Completed %lu tests\n", (unsigned long)n_tests);
- (void)GC_printf1("Allocated %lu collectable objects\n", (unsigned long)collectable_count);
- (void)GC_printf1("Allocated %lu uncollectable objects\n", (unsigned long)uncollectable_count);
- (void)GC_printf1("Allocated %lu atomic objects\n", (unsigned long)atomic_count);
- (void)GC_printf1("Allocated %lu stubborn objects\n", (unsigned long)stubborn_count);
- (void)GC_printf2("Finalized %lu/%lu objects - ",
- (unsigned long)finalized_count,
- (unsigned long)finalizable_count);
-# ifdef FINALIZE_ON_DEMAND
- if (finalized_count != late_finalize_count) {
- (void)GC_printf0("Demand finalization error\n");
- FAIL;
- }
-# endif
- if (finalized_count > finalizable_count
- || finalized_count < finalizable_count/2) {
- (void)GC_printf0("finalization is probably broken\n");
- FAIL;
- } else {
- (void)GC_printf0("finalization is probably ok\n");
- }
- still_live = 0;
- for (i = 0; i < MAX_FINALIZED; i++) {
- if (live_indicators[i] != 0) {
- still_live++;
- }
- }
- i = finalizable_count - finalized_count - still_live;
- if (0 != i) {
- (void)GC_printf2
- ("%lu disappearing links remain and %ld more objects were not finalized\n",
- (unsigned long) still_live, (long)i);
- if (i > 10) {
- GC_printf0("\tVery suspicious!\n");
- } else {
- GC_printf0("\tSlightly suspicious, but probably OK.\n");
- }
- }
- (void)GC_printf1("Total number of bytes allocated is %lu\n",
- (unsigned long)
- WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc));
- (void)GC_printf1("Final heap size is %lu bytes\n",
- (unsigned long)GC_get_heap_size());
- if (WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc)
-# ifdef VERY_SMALL_CONFIG
- < 2700000*n_tests) {
-# else
- < 33500000*n_tests) {
-# endif
- (void)GC_printf0("Incorrect execution - missed some allocations\n");
- FAIL;
- }
- if (GC_get_heap_size() > max_heap_sz*n_tests) {
- (void)GC_printf0("Unexpected heap growth - collector may be broken\n");
- FAIL;
- }
- (void)GC_printf0("Collector appears to work\n");
-}
-
-#if defined(MACOS)
-void SetMinimumStack(long minSize)
-{
- long newApplLimit;
-
- if (minSize > LMGetDefltStack())
- {
- newApplLimit = (long) GetApplLimit()
- - (minSize - LMGetDefltStack());
- SetApplLimit((Ptr) newApplLimit);
- MaxApplZone();
- }
-}
-
-#define cMinStackSpace (512L * 1024L)
-
-#endif
-
-#ifdef __STDC__
- void warn_proc(char *msg, GC_word p)
-#else
- void warn_proc(msg, p)
- char *msg;
- GC_word p;
-#endif
-{
- GC_printf1(msg, (unsigned long)p);
- /*FAIL;*/
-}
-
-
-#if !defined(PCR) && !defined(GC_SOLARIS_THREADS) \
- && !defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) \
- || defined(LINT)
-#if defined(MSWIN32) && !defined(__MINGW32__)
- int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n)
-#else
- int main()
-#endif
-{
-# if defined(DJGPP)
- int dummy;
-# endif
- n_tests = 0;
-
-# if defined(DJGPP)
- /* No good way to determine stack base from library; do it */
- /* manually on this platform. */
- GC_stackbottom = (GC_PTR)(&dummy);
-# endif
-# if defined(MACOS)
- /* Make sure we have lots and lots of stack space. */
- SetMinimumStack(cMinStackSpace);
- /* Cheat and let stdio initialize toolbox for us. */
- printf("Testing GC Macintosh port.\n");
-# endif
- GC_INIT(); /* Only needed on a few platforms. */
- (void) GC_set_warn_proc(warn_proc);
-# if (defined(MPROTECT_VDB) || defined(PROC_VDB)) \
- && !defined(MAKE_BACK_GRAPH)
- GC_enable_incremental();
- (void) GC_printf0("Switched to incremental mode\n");
-# if defined(MPROTECT_VDB)
- (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
-# else
-# ifdef PROC_VDB
- (void)GC_printf0("Reading dirty bits from /proc\n");
-# else
- (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
-# endif
-# endif
-# endif
- run_one_test();
- check_heap_stats();
-# ifndef MSWINCE
- (void)fflush(stdout);
-# endif
-# ifdef LINT
- /* Entry points we should be testing, but aren't. */
- /* Some can be tested by defining GC_DEBUG at the top of this file */
- /* This is a bit SunOS4 specific. */
- GC_noop(GC_expand_hp, GC_add_roots, GC_clear_roots,
- GC_register_disappearing_link,
- GC_register_finalizer_ignore_self,
- GC_debug_register_displacement,
- GC_print_obj, GC_debug_change_stubborn,
- GC_debug_end_stubborn_change, GC_debug_malloc_uncollectable,
- GC_debug_free, GC_debug_realloc, GC_generic_malloc_words_small,
- GC_init, GC_make_closure, GC_debug_invoke_finalizer,
- GC_page_was_ever_dirty, GC_is_fresh,
- GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page,
- GC_set_max_heap_size, GC_get_bytes_since_gc,
- GC_get_total_bytes, GC_pre_incr, GC_post_incr);
-# endif
-# ifdef MSWIN32
- GC_win32_free_heap();
-# endif
- return(0);
-}
-# endif
-
-#if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
-
-DWORD __stdcall thr_run_one_test(void *arg)
-{
- run_one_test();
- return 0;
-}
-
-#ifdef MSWINCE
-HANDLE win_created_h;
-HWND win_handle;
-
-LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
- LRESULT ret = 0;
- switch (uMsg) {
- case WM_HIBERNATE:
- GC_printf0("Received WM_HIBERNATE, calling GC_gcollect\n");
- GC_gcollect();
- break;
- case WM_CLOSE:
- GC_printf0("Received WM_CLOSE, closing window\n");
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- ret = DefWindowProc(hwnd, uMsg, wParam, lParam);
- break;
- }
- return ret;
-}
-
-DWORD __stdcall thr_window(void *arg)
-{
- WNDCLASS win_class = {
- CS_NOCLOSE,
- window_proc,
- 0,
- 0,
- GetModuleHandle(NULL),
- NULL,
- NULL,
- (HBRUSH)(COLOR_APPWORKSPACE+1),
- NULL,
- L"GCtestWindow"
- };
- MSG msg;
-
- if (!RegisterClass(&win_class))
- FAIL;
-
- win_handle = CreateWindowEx(
- 0,
- L"GCtestWindow",
- L"GCtest",
- 0,
- CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- NULL,
- NULL,
- GetModuleHandle(NULL),
- NULL);
-
- if (win_handle == NULL)
- FAIL;
-
- SetEvent(win_created_h);
-
- ShowWindow(win_handle, SW_SHOW);
- UpdateWindow(win_handle);
-
- while (GetMessage(&msg, NULL, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return 0;
-}
-#endif
-
-#define NTEST 2
-
-# ifdef MSWINCE
-int APIENTRY GC_WinMain(HINSTANCE instance, HINSTANCE prev, LPWSTR cmd, int n)
-# else
-int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
-# endif
-{
-# if NTEST > 0
- HANDLE h[NTEST];
- int i;
-# endif
-# ifdef MSWINCE
- HANDLE win_thr_h;
-# endif
- DWORD thread_id;
-# if 0
- GC_enable_incremental();
-# endif
- GC_init();
- InitializeCriticalSection(&incr_cs);
- (void) GC_set_warn_proc(warn_proc);
-# ifdef MSWINCE
- win_created_h = CreateEvent(NULL, FALSE, FALSE, NULL);
- if (win_created_h == (HANDLE)NULL) {
- (void)GC_printf1("Event creation failed %lu\n", (unsigned long)GetLastError());
- FAIL;
- }
- win_thr_h = GC_CreateThread(NULL, 0, thr_window, 0, 0, &thread_id);
- if (win_thr_h == (HANDLE)NULL) {
- (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
- FAIL;
- }
- if (WaitForSingleObject(win_created_h, INFINITE) != WAIT_OBJECT_0)
- FAIL;
- CloseHandle(win_created_h);
-# endif
-# if NTEST > 0
- for (i = 0; i < NTEST; i++) {
- h[i] = GC_CreateThread(NULL, 0, thr_run_one_test, 0, 0, &thread_id);
- if (h[i] == (HANDLE)NULL) {
- (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
- FAIL;
- }
- }
-# endif /* NTEST > 0 */
- run_one_test();
-# if NTEST > 0
- for (i = 0; i < NTEST; i++) {
- if (WaitForSingleObject(h[i], INFINITE) != WAIT_OBJECT_0) {
- (void)GC_printf1("Thread wait failed %lu\n", (unsigned long)GetLastError());
- FAIL;
- }
- }
-# endif /* NTEST > 0 */
-# ifdef MSWINCE
- PostMessage(win_handle, WM_CLOSE, 0, 0);
- if (WaitForSingleObject(win_thr_h, INFINITE) != WAIT_OBJECT_0)
- FAIL;
-# endif
- check_heap_stats();
- return(0);
-}
-
-#endif /* GC_WIN32_THREADS */
-
-
-#ifdef PCR
-test()
-{
- PCR_Th_T * th1;
- PCR_Th_T * th2;
- int code;
-
- n_tests = 0;
- /* GC_enable_incremental(); */
- (void) GC_set_warn_proc(warn_proc);
- th1 = PCR_Th_Fork(run_one_test, 0);
- th2 = PCR_Th_Fork(run_one_test, 0);
- run_one_test();
- if (PCR_Th_T_Join(th1, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
- != PCR_ERes_okay || code != 0) {
- (void)GC_printf0("Thread 1 failed\n");
- }
- if (PCR_Th_T_Join(th2, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
- != PCR_ERes_okay || code != 0) {
- (void)GC_printf0("Thread 2 failed\n");
- }
- check_heap_stats();
- return(0);
-}
-#endif
-
-#if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS)
-void * thr_run_one_test(void * arg)
-{
- run_one_test();
- return(0);
-}
-
-#ifdef GC_DEBUG
-# define GC_free GC_debug_free
-#endif
-
-#if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
-main()
-{
- thread_t th1;
- thread_t th2;
- int code;
-
- n_tests = 0;
- GC_INIT(); /* Only needed if gc is dynamic library. */
-# ifndef MAKE_BACK_GRAPH
- GC_enable_incremental();
-# endif
- (void) GC_set_warn_proc(warn_proc);
- if (thr_keycreate(&fl_key, GC_free) != 0) {
- (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, 0, &th1)) != 0) {
- (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, THR_NEW_LWP, &th2)) != 0) {
- (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- run_one_test();
- if ((code = thr_join(th1, 0, 0)) != 0) {
- (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if (thr_join(th2, 0, 0) != 0) {
- (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
- FAIL;
- }
- check_heap_stats();
- (void)fflush(stdout);
- return(0);
-}
-#else /* pthreads */
-
-#ifndef GC_PTHREADS
- --> bad news
-#endif
-
-main()
-{
- pthread_t th1;
- pthread_t th2;
- pthread_attr_t attr;
- int code;
-
-# ifdef GC_IRIX_THREADS
- /* Force a larger stack to be preallocated */
- /* Since the initial cant always grow later. */
- *((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */
-# endif /* GC_IRIX_THREADS */
-# if defined(GC_HPUX_THREADS)
- /* Default stack size is too small, especially with the 64 bit ABI */
- /* Increase it. */
- if (pthread_default_stacksize_np(1024*1024, 0) != 0) {
- (void)GC_printf0("pthread_default_stacksize_np failed.\n");
- }
-# endif /* GC_HPUX_THREADS */
- GC_INIT();
-
- pthread_attr_init(&attr);
-# if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) \
- || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
- pthread_attr_setstacksize(&attr, 1000000);
-# endif
- n_tests = 0;
-# if (defined(MPROTECT_VDB)) \
- && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) \
- && !defined(MAKE_BACK_GRAPH)
- GC_enable_incremental();
- (void) GC_printf0("Switched to incremental mode\n");
-# if defined(MPROTECT_VDB)
- (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
-# else
-# ifdef PROC_VDB
- (void)GC_printf0("Reading dirty bits from /proc\n");
-# else
- (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
-# endif
-# endif
-# endif
- (void) GC_set_warn_proc(warn_proc);
- if ((code = pthread_key_create(&fl_key, 0)) != 0) {
- (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if ((code = pthread_create(&th1, &attr, thr_run_one_test, 0)) != 0) {
- (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if ((code = pthread_create(&th2, &attr, thr_run_one_test, 0)) != 0) {
- (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
- FAIL;
- }
- run_one_test();
- if ((code = pthread_join(th1, 0)) != 0) {
- (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
- FAIL;
- }
- if (pthread_join(th2, 0) != 0) {
- (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
- FAIL;
- }
- check_heap_stats();
- (void)fflush(stdout);
- pthread_attr_destroy(&attr);
- GC_printf1("Completed %d collections\n", GC_gc_no);
- return(0);
-}
-#endif /* GC_PTHREADS */
-#endif /* GC_SOLARIS_THREADS || GC_PTHREADS */
+++ /dev/null
-/****************************************************************************
-Copyright (c) 1994 by Xerox Corporation. All rights reserved.
-
-THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
-OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
-
-Permission is hereby granted to use or copy this program for any
-purpose, provided the above notices are retained on all copies.
-Permission to modify the code and to distribute modified code is
-granted, provided the above notices are retained, and a notice that
-the code was modified is included with the above copyright notice.
-****************************************************************************
-Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis
- modified on December 20, 1994 7:27 pm PST by boehm
-
-usage: test_cpp number-of-iterations
-
-This program tries to test the specific C++ functionality provided by
-gc_c++.h that isn't tested by the more general test routines of the
-collector.
-
-A recommended value for number-of-iterations is 10, which will take a
-few minutes to complete.
-
-***************************************************************************/
-
-#include "gc_cpp.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#define USE_STD_ALLOCATOR
-#ifdef USE_STD_ALLOCATOR
-# include "gc_allocator.h"
-#elif __GNUC__
-# include "new_gc_alloc.h"
-#else
-# include "gc_alloc.h"
-#endif
-extern "C" {
-#include "private/gc_priv.h"
-}
-#ifdef MSWIN32
-# include <windows.h>
-#endif
-#ifdef GC_NAME_CONFLICT
-# define USE_GC UseGC
- struct foo * GC;
-#else
-# define USE_GC GC
-#endif
-
-
-#define my_assert( e ) \
- if (! (e)) { \
- GC_printf1( "Assertion failure in " __FILE__ ", line %d: " #e "\n", \
- __LINE__ ); \
- exit( 1 ); }
-
-
-class A {public:
- /* An uncollectable class. */
-
- A( int iArg ): i( iArg ) {}
- void Test( int iArg ) {
- my_assert( i == iArg );}
- int i;};
-
-
-class B: public gc, public A {public:
- /* A collectable class. */
-
- B( int j ): A( j ) {}
- ~B() {
- my_assert( deleting );}
- static void Deleting( int on ) {
- deleting = on;}
- static int deleting;};
-
-int B::deleting = 0;
-
-
-class C: public gc_cleanup, public A {public:
- /* A collectable class with cleanup and virtual multiple inheritance. */
-
- C( int levelArg ): A( levelArg ), level( levelArg ) {
- nAllocated++;
- if (level > 0) {
- left = new C( level - 1 );
- right = new C( level - 1 );}
- else {
- left = right = 0;}}
- ~C() {
- this->A::Test( level );
- nFreed++;
- my_assert( level == 0 ?
- left == 0 && right == 0 :
- level == left->level + 1 && level == right->level + 1 );
- left = right = 0;
- level = -123456;}
- static void Test() {
- my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );}
-
- static int nFreed;
- static int nAllocated;
- int level;
- C* left;
- C* right;};
-
-int C::nFreed = 0;
-int C::nAllocated = 0;
-
-
-class D: public gc {public:
- /* A collectable class with a static member function to be used as
- an explicit clean-up function supplied to ::new. */
-
- D( int iArg ): i( iArg ) {
- nAllocated++;}
- static void CleanUp( void* obj, void* data ) {
- D* self = (D*) obj;
- nFreed++;
- my_assert( self->i == (int) (long) data );}
- static void Test() {
- my_assert( nFreed >= .8 * nAllocated );}
-
- int i;
- static int nFreed;
- static int nAllocated;};
-
-int D::nFreed = 0;
-int D::nAllocated = 0;
-
-
-class E: public gc_cleanup {public:
- /* A collectable class with clean-up for use by F. */
-
- E() {
- nAllocated++;}
- ~E() {
- nFreed++;}
-
- static int nFreed;
- static int nAllocated;};
-
-int E::nFreed = 0;
-int E::nAllocated = 0;
-
-
-class F: public E {public:
- /* A collectable class with clean-up, a base with clean-up, and a
- member with clean-up. */
-
- F() {
- nAllocated++;}
- ~F() {
- nFreed++;}
- static void Test() {
- my_assert( nFreed >= .8 * nAllocated );
- my_assert( 2 * nFreed == E::nFreed );}
-
- E e;
- static int nFreed;
- static int nAllocated;};
-
-int F::nFreed = 0;
-int F::nAllocated = 0;
-
-
-long Disguise( void* p ) {
- return ~ (long) p;}
-
-void* Undisguise( long i ) {
- return (void*) ~ i;}
-
-
-#ifdef MSWIN32
-int APIENTRY WinMain(
- HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow )
-{
- int argc;
- char* argv[ 3 ];
-
- for (argc = 1; argc < sizeof( argv ) / sizeof( argv[ 0 ] ); argc++) {
- argv[ argc ] = strtok( argc == 1 ? cmd : 0, " \t" );
- if (0 == argv[ argc ]) break;}
-
-#else
-# ifdef MACOS
- int main() {
-# else
- int main( int argc, char* argv[] ) {
-# endif
-#endif
-
- GC_INIT();
-
-# if defined(MACOS) // MacOS
- char* argv_[] = {"test_cpp", "10"}; // doesn't
- argv = argv_; // have a
- argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
-# endif
- int i, iters, n;
-# ifdef USE_STD_ALLOCATOR
- int *x = gc_allocator<int>().allocate(1);
- int **xptr = traceable_allocator<int *>().allocate(1);
-# else
-# ifdef __GNUC__
- int *x = (int *)gc_alloc::allocate(sizeof(int));
-# else
- int *x = (int *)alloc::allocate(sizeof(int));
-# endif
-# endif
- *x = 29;
-# ifdef USE_STD_ALLOCATOR
- *xptr = x;
- x = 0;
-# endif
- if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) {
- GC_printf0( "usage: test_cpp number-of-iterations\nAssuming 10 iters\n" );
- n = 10;}
-
- for (iters = 1; iters <= n; iters++) {
- GC_printf1( "Starting iteration %d\n", iters );
-
- /* Allocate some uncollectable As and disguise their pointers.
- Later we'll check to see if the objects are still there. We're
- checking to make sure these objects really are uncollectable. */
- long as[ 1000 ];
- long bs[ 1000 ];
- for (i = 0; i < 1000; i++) {
- as[ i ] = Disguise( new (NoGC) A( i ) );
- bs[ i ] = Disguise( new (NoGC) B( i ) );}
-
- /* Allocate a fair number of finalizable Cs, Ds, and Fs.
- Later we'll check to make sure they've gone away. */
- for (i = 0; i < 1000; i++) {
- C* c = new C( 2 );
- C c1( 2 ); /* stack allocation should work too */
- D* d = ::new (USE_GC, D::CleanUp, (void*)(long)i) D( i );
- F* f = new F;
- if (0 == i % 10) delete c;}
-
- /* Allocate a very large number of collectable As and Bs and
- drop the references to them immediately, forcing many
- collections. */
- for (i = 0; i < 1000000; i++) {
- A* a = new (USE_GC) A( i );
- B* b = new B( i );
- b = new (USE_GC) B( i );
- if (0 == i % 10) {
- B::Deleting( 1 );
- delete b;
- B::Deleting( 0 );}
-# ifdef FINALIZE_ON_DEMAND
- GC_invoke_finalizers();
-# endif
- }
-
- /* Make sure the uncollectable As and Bs are still there. */
- for (i = 0; i < 1000; i++) {
- A* a = (A*) Undisguise( as[ i ] );
- B* b = (B*) Undisguise( bs[ i ] );
- a->Test( i );
- delete a;
- b->Test( i );
- B::Deleting( 1 );
- delete b;
- B::Deleting( 0 );
-# ifdef FINALIZE_ON_DEMAND
- GC_invoke_finalizers();
-# endif
-
- }
-
- /* Make sure most of the finalizable Cs, Ds, and Fs have
- gone away. */
- C::Test();
- D::Test();
- F::Test();}
-
-# ifdef USE_STD_ALLOCATOR
- x = *xptr;
-# endif
- my_assert (29 == x[0]);
- GC_printf0( "The test appears to have succeeded.\n" );
- return( 0 );}
-
-
+++ /dev/null
-#define GC_LINUX_THREADS
-#include "leak_detector.h"
-#include <pthread.h>
-#include <stdio.h>
-
-void * test(void * arg) {
- int *p[10];
- int i;
- GC_find_leak = 1; /* for new collect versions not compiled */
- /* with -DFIND_LEAK. */
- for (i = 0; i < 10; ++i) {
- p[i] = malloc(sizeof(int)+i);
- }
- CHECK_LEAKS();
- for (i = 1; i < 10; ++i) {
- free(p[i]);
- }
-}
-
-#define NTHREADS 5
-
-int main() {
- int i;
- pthread_t t[NTHREADS];
- int code;
-
- for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
- printf("Thread creation failed %d\n", code);
- }
- }
- for (i = 0; i < NTHREADS; ++i) {
- if ((code = pthread_join(t[i], 0)) != 0) {
- printf("Thread join failed %lu\n", code);
- }
- }
- CHECK_LEAKS();
- CHECK_LEAKS();
- CHECK_LEAKS();
- return 0;
-}
+++ /dev/null
-#include <stdio.h>
-#define GC_DEBUG
-#include "gc.h"
-
-struct treenode {
- struct treenode *x;
- struct treenode *y;
-} * root[10];
-
-struct treenode * mktree(int i) {
- struct treenode * r = GC_MALLOC(sizeof(struct treenode));
- if (0 == i) return 0;
- if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
- r -> x = mktree(i-1);
- r -> y = mktree(i-1);
- return r;
-}
-
-int main()
-{
- int i;
- for (i = 0; i < 10; ++i) {
- root[i] = mktree(12);
- }
- GC_generate_random_backtrace();
- GC_generate_random_backtrace();
- GC_generate_random_backtrace();
- GC_generate_random_backtrace();
- return 0;
-}
--- /dev/null
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = foreign dejagnu
+
+EXPECT = expect
+
+# Override default.
+DEJATOOL = boehm-gc
+
+CLEANFILES = *.exe core* *.log *.sum
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains. So we overrule automake. This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+ @echo 'Making a new site.exp file...'
+ @echo '## these variables are automatically generated by make ##' >site.tmp
+ @echo '# Do not edit here. If you wish to override these values' >>site.tmp
+ @echo '# edit the last section' >>site.tmp
+ @echo 'set srcdir $(srcdir)' >>site.tmp
+ @echo "set objdir `pwd`" >>site.tmp
+ @echo 'set build_alias "$(build_alias)"' >>site.tmp
+ @echo 'set build_triplet $(build_triplet)' >>site.tmp
+ @echo 'set host_alias "$(host_alias)"' >>site.tmp
+ @echo 'set host_triplet $(host_triplet)' >>site.tmp
+ @echo 'set target_alias "$(target_alias)"' >>site.tmp
+ @echo 'set target_triplet $(target_triplet)' >>site.tmp
+ @echo 'set threadcflags "$(THREADCFLAGS)"' >>site.tmp
+ @echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
+ @echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
+ @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+ @test ! -f site.exp || \
+ sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+ @-rm -f site.bak
+ @test ! -f site.exp || mv site.exp site.bak
+ @mv site.tmp site.exp
--- /dev/null
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = testsuite
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
+ $(top_srcdir)/../config/depstand.m4 \
+ $(top_srcdir)/../config/lead-dot.m4 \
+ $(top_srcdir)/../config/multi.m4 \
+ $(top_srcdir)/../config/no-executables.m4 \
+ $(top_srcdir)/../config/override.m4 \
+ $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
+ $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
+ $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+CONFIG_HEADER = $(top_builddir)/include/gc_config.h \
+ $(top_builddir)/include/gc_ext_config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RUNTESTDEFAULTFLAGS = --tool $$tool --srcdir $$srcdir
+RUNTEST = runtest
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_CPPFLAGS = @AM_CPPFLAGS@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXTRA_TEST_LIBS = @EXTRA_TEST_LIBS@
+FGREP = @FGREP@
+GC_CFLAGS = @GC_CFLAGS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+O0_CFLAGS = @O0_CFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+THREADCFLAGS = @THREADCFLAGS@
+THREADLIBS = @THREADLIBS@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+addincludes = @addincludes@
+addlibs = @addlibs@
+addobjs = @addobjs@
+addtests = @addtests@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extra_ldflags_libgc = @extra_ldflags_libgc@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+mkinstalldirs = @mkinstalldirs@
+multi_basedir = @multi_basedir@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_all = @target_all@
+target_cpu = @target_cpu@
+target_noncanonical = @target_noncanonical@
+target_os = @target_os@
+target_vendor = @target_vendor@
+toolexecdir = @toolexecdir@
+toolexeclibdir = @toolexeclibdir@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign dejagnu
+EXPECT = expect
+
+# Override default.
+DEJATOOL = boehm-gc
+CLEANFILES = *.exe core* *.log *.sum
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign testsuite/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+check-DEJAGNU: site.exp
+ srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
+ EXPECT=$(EXPECT); export EXPECT; \
+ runtest=$(RUNTEST); \
+ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ exit_status=0; l='$(DEJATOOL)'; for tool in $$l; do \
+ if $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \
+ then :; else exit_status=1; fi; \
+ done; \
+ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
+ fi; \
+ exit $$exit_status
+
+distclean-DEJAGNU:
+ -rm -f site.exp site.bak
+ -l='$(DEJATOOL)'; for tool in $$l; do \
+ rm -f $$tool.sum $$tool.log; \
+ done
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-DEJAGNU distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: all all-am check check-DEJAGNU check-am clean clean-generic \
+ clean-libtool distclean distclean-DEJAGNU distclean-generic \
+ distclean-libtool distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ uninstall uninstall-am
+
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains. So we overrule automake. This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+ @echo 'Making a new site.exp file...'
+ @echo '## these variables are automatically generated by make ##' >site.tmp
+ @echo '# Do not edit here. If you wish to override these values' >>site.tmp
+ @echo '# edit the last section' >>site.tmp
+ @echo 'set srcdir $(srcdir)' >>site.tmp
+ @echo "set objdir `pwd`" >>site.tmp
+ @echo 'set build_alias "$(build_alias)"' >>site.tmp
+ @echo 'set build_triplet $(build_triplet)' >>site.tmp
+ @echo 'set host_alias "$(host_alias)"' >>site.tmp
+ @echo 'set host_triplet $(host_triplet)' >>site.tmp
+ @echo 'set target_alias "$(target_alias)"' >>site.tmp
+ @echo 'set target_triplet $(target_triplet)' >>site.tmp
+ @echo 'set threadcflags "$(THREADCFLAGS)"' >>site.tmp
+ @echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
+ @echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
+ @echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+ @test ! -f site.exp || \
+ sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+ @-rm -f site.bak
+ @test ! -f site.exp || mv site.exp site.bak
+ @mv site.tmp site.exp
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
--- /dev/null
+/****************************************************************************
+Copyright (c) 1994 by Xerox Corporation. All rights reserved.
+
+THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+
+Permission is hereby granted to use or copy this program for any
+purpose, provided the above notices are retained on all copies.
+Permission to modify the code and to distribute modified code is
+granted, provided the above notices are retained, and a notice that
+the code was modified is included with the above copyright notice.
+****************************************************************************
+Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis
+ modified on December 20, 1994 7:27 pm PST by boehm
+
+usage: test_cpp number-of-iterations
+
+This program tries to test the specific C++ functionality provided by
+gc_c++.h that isn't tested by the more general test routines of the
+collector.
+
+A recommended value for number-of-iterations is 10, which will take a
+few minutes to complete.
+
+***************************************************************************/
+
+#include "gc_cpp.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define USE_STD_ALLOCATOR
+#ifdef USE_STD_ALLOCATOR
+# include "gc_allocator.h"
+#elif __GNUC__
+# include "new_gc_alloc.h"
+#else
+# include "gc_alloc.h"
+#endif
+extern "C" {
+#include "private/gc_priv.h"
+}
+#ifdef MSWIN32
+# include <windows.h>
+#endif
+#ifdef GC_NAME_CONFLICT
+# define USE_GC UseGC
+ struct foo * GC;
+#else
+# define USE_GC GC
+#endif
+
+
+#define my_assert( e ) \
+ if (! (e)) { \
+ GC_printf1( "Assertion failure in " __FILE__ ", line %d: " #e "\n", \
+ __LINE__ ); \
+ exit( 1 ); }
+
+
+class A {public:
+ /* An uncollectable class. */
+
+ A( int iArg ): i( iArg ) {}
+ void Test( int iArg ) {
+ my_assert( i == iArg );}
+ int i;};
+
+
+class B: public gc, public A {public:
+ /* A collectable class. */
+
+ B( int j ): A( j ) {}
+ ~B() {
+ my_assert( deleting );}
+ static void Deleting( int on ) {
+ deleting = on;}
+ static int deleting;};
+
+int B::deleting = 0;
+
+
+class C: public gc_cleanup, public A {public:
+ /* A collectable class with cleanup and virtual multiple inheritance. */
+
+ C( int levelArg ): A( levelArg ), level( levelArg ) {
+ nAllocated++;
+ if (level > 0) {
+ left = new C( level - 1 );
+ right = new C( level - 1 );}
+ else {
+ left = right = 0;}}
+ ~C() {
+ this->A::Test( level );
+ nFreed++;
+ my_assert( level == 0 ?
+ left == 0 && right == 0 :
+ level == left->level + 1 && level == right->level + 1 );
+ left = right = 0;
+ level = -123456;}
+ static void Test() {
+ my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );}
+
+ static int nFreed;
+ static int nAllocated;
+ int level;
+ C* left;
+ C* right;};
+
+int C::nFreed = 0;
+int C::nAllocated = 0;
+
+
+class D: public gc {public:
+ /* A collectable class with a static member function to be used as
+ an explicit clean-up function supplied to ::new. */
+
+ D( int iArg ): i( iArg ) {
+ nAllocated++;}
+ static void CleanUp( void* obj, void* data ) {
+ D* self = (D*) obj;
+ nFreed++;
+ my_assert( self->i == (int) (long) data );}
+ static void Test() {
+ my_assert( nFreed >= .8 * nAllocated );}
+
+ int i;
+ static int nFreed;
+ static int nAllocated;};
+
+int D::nFreed = 0;
+int D::nAllocated = 0;
+
+
+class E: public gc_cleanup {public:
+ /* A collectable class with clean-up for use by F. */
+
+ E() {
+ nAllocated++;}
+ ~E() {
+ nFreed++;}
+
+ static int nFreed;
+ static int nAllocated;};
+
+int E::nFreed = 0;
+int E::nAllocated = 0;
+
+
+class F: public E {public:
+ /* A collectable class with clean-up, a base with clean-up, and a
+ member with clean-up. */
+
+ F() {
+ nAllocated++;}
+ ~F() {
+ nFreed++;}
+ static void Test() {
+ my_assert( nFreed >= .8 * nAllocated );
+ my_assert( 2 * nFreed == E::nFreed );}
+
+ E e;
+ static int nFreed;
+ static int nAllocated;};
+
+int F::nFreed = 0;
+int F::nAllocated = 0;
+
+
+long Disguise( void* p ) {
+ return ~ (long) p;}
+
+void* Undisguise( long i ) {
+ return (void*) ~ i;}
+
+
+#ifdef MSWIN32
+int APIENTRY WinMain(
+ HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow )
+{
+ int argc;
+ char* argv[ 3 ];
+
+ for (argc = 1; argc < sizeof( argv ) / sizeof( argv[ 0 ] ); argc++) {
+ argv[ argc ] = strtok( argc == 1 ? cmd : 0, " \t" );
+ if (0 == argv[ argc ]) break;}
+
+#else
+# ifdef MACOS
+ int main() {
+# else
+ int main( int argc, char* argv[] ) {
+# endif
+#endif
+
+ GC_INIT();
+
+# if defined(MACOS) // MacOS
+ char* argv_[] = {"test_cpp", "10"}; // doesn't
+ argv = argv_; // have a
+ argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
+# endif
+ int i, iters, n;
+# ifdef USE_STD_ALLOCATOR
+ int *x = gc_allocator<int>().allocate(1);
+ int **xptr = traceable_allocator<int *>().allocate(1);
+# else
+# ifdef __GNUC__
+ int *x = (int *)gc_alloc::allocate(sizeof(int));
+# else
+ int *x = (int *)alloc::allocate(sizeof(int));
+# endif
+# endif
+ *x = 29;
+# ifdef USE_STD_ALLOCATOR
+ *xptr = x;
+ x = 0;
+# endif
+ if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) {
+ GC_printf0( "usage: test_cpp number-of-iterations\nAssuming 10 iters\n" );
+ n = 10;}
+
+ for (iters = 1; iters <= n; iters++) {
+ GC_printf1( "Starting iteration %d\n", iters );
+
+ /* Allocate some uncollectable As and disguise their pointers.
+ Later we'll check to see if the objects are still there. We're
+ checking to make sure these objects really are uncollectable. */
+ long as[ 1000 ];
+ long bs[ 1000 ];
+ for (i = 0; i < 1000; i++) {
+ as[ i ] = Disguise( new (NoGC) A( i ) );
+ bs[ i ] = Disguise( new (NoGC) B( i ) );}
+
+ /* Allocate a fair number of finalizable Cs, Ds, and Fs.
+ Later we'll check to make sure they've gone away. */
+ for (i = 0; i < 1000; i++) {
+ C* c = new C( 2 );
+ C c1( 2 ); /* stack allocation should work too */
+ D* d = ::new (USE_GC, D::CleanUp, (void*)(long)i) D( i );
+ F* f = new F;
+ if (0 == i % 10) delete c;}
+
+ /* Allocate a very large number of collectable As and Bs and
+ drop the references to them immediately, forcing many
+ collections. */
+ for (i = 0; i < 1000000; i++) {
+ A* a = new (USE_GC) A( i );
+ B* b = new B( i );
+ b = new (USE_GC) B( i );
+ if (0 == i % 10) {
+ B::Deleting( 1 );
+ delete b;
+ B::Deleting( 0 );}
+# ifdef FINALIZE_ON_DEMAND
+ GC_invoke_finalizers();
+# endif
+ }
+
+ /* Make sure the uncollectable As and Bs are still there. */
+ for (i = 0; i < 1000; i++) {
+ A* a = (A*) Undisguise( as[ i ] );
+ B* b = (B*) Undisguise( bs[ i ] );
+ a->Test( i );
+ delete a;
+ b->Test( i );
+ B::Deleting( 1 );
+ delete b;
+ B::Deleting( 0 );
+# ifdef FINALIZE_ON_DEMAND
+ GC_invoke_finalizers();
+# endif
+
+ }
+
+ /* Make sure most of the finalizable Cs, Ds, and Fs have
+ gone away. */
+ C::Test();
+ D::Test();
+ F::Test();}
+
+# ifdef USE_STD_ALLOCATOR
+ x = *xptr;
+# endif
+ my_assert (29 == x[0]);
+ GC_printf0( "The test appears to have succeeded.\n" );
+ return( 0 );}
+
+
--- /dev/null
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+boehm-gc-init
+
+boehm-gc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "-O2" ""
+
+dg-finish
--- /dev/null
+/*
+ * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
+ * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
+ * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+/* An incomplete test for the garbage collector. */
+/* Some more obscure entry points are not tested at all. */
+/* This must be compiled with the same flags used to build the */
+/* GC. It uses GC internals to allow more precise results */
+/* checking for some of the tests. */
+
+# undef GC_BUILD
+
+#if defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH)
+# define GC_DEBUG
+#endif
+
+# if defined(mips) && defined(SYSTYPE_BSD43)
+ /* MIPS RISCOS 4 */
+# else
+# include <stdlib.h>
+# endif
+# include <stdio.h>
+# ifdef _WIN32_WCE
+# include <winbase.h>
+# define assert ASSERT
+# else
+# include <assert.h> /* Not normally used, but handy for debugging. */
+# endif
+# include <assert.h> /* Not normally used, but handy for debugging. */
+# include "gc.h"
+# include "gc_typed.h"
+# ifdef THREAD_LOCAL_ALLOC
+# include "gc_local_alloc.h"
+# endif
+# include "private/gc_priv.h" /* For output, locking, MIN_WORDS, */
+ /* and some statistics. */
+# include "private/gcconfig.h"
+
+# if defined(MSWIN32) || defined(MSWINCE)
+# include <windows.h>
+# endif
+
+# ifdef PCR
+# include "th/PCR_ThCrSec.h"
+# include "th/PCR_Th.h"
+# undef GC_printf0
+# define GC_printf0 printf
+# undef GC_printf1
+# define GC_printf1 printf
+# endif
+
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+# include <thread.h>
+# include <synch.h>
+# endif
+
+# if defined(GC_PTHREADS)
+# include <pthread.h>
+# endif
+
+# if defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS)
+ static CRITICAL_SECTION incr_cs;
+# endif
+
+#ifdef __STDC__
+# include <stdarg.h>
+#endif
+
+
+/* Allocation Statistics */
+int stubborn_count = 0;
+int uncollectable_count = 0;
+int collectable_count = 0;
+int atomic_count = 0;
+int realloc_count = 0;
+
+#if defined(GC_AMIGA_FASTALLOC) && defined(AMIGA)
+
+ extern void GC_amiga_free_all_mem(void);
+ void Amiga_Fail(void){GC_amiga_free_all_mem();abort();}
+# define FAIL (void)Amiga_Fail()
+ void *GC_amiga_gctest_malloc_explicitly_typed(size_t lb, GC_descr d){
+ void *ret=GC_malloc_explicitly_typed(lb,d);
+ if(ret==NULL){
+ if(!GC_dont_gc){
+ GC_gcollect();
+ ret=GC_malloc_explicitly_typed(lb,d);
+ }
+ if(ret==NULL){
+ GC_printf0("Out of memory, (typed allocations are not directly "
+ "supported with the GC_AMIGA_FASTALLOC option.)\n");
+ FAIL;
+ }
+ }
+ return ret;
+ }
+ void *GC_amiga_gctest_calloc_explicitly_typed(size_t a,size_t lb, GC_descr d){
+ void *ret=GC_calloc_explicitly_typed(a,lb,d);
+ if(ret==NULL){
+ if(!GC_dont_gc){
+ GC_gcollect();
+ ret=GC_calloc_explicitly_typed(a,lb,d);
+ }
+ if(ret==NULL){
+ GC_printf0("Out of memory, (typed allocations are not directly "
+ "supported with the GC_AMIGA_FASTALLOC option.)\n");
+ FAIL;
+ }
+ }
+ return ret;
+ }
+# define GC_malloc_explicitly_typed(a,b) GC_amiga_gctest_malloc_explicitly_typed(a,b)
+# define GC_calloc_explicitly_typed(a,b,c) GC_amiga_gctest_calloc_explicitly_typed(a,b,c)
+
+#else /* !AMIGA_FASTALLOC */
+
+# ifdef PCR
+# define FAIL (void)abort()
+# else
+# ifdef MSWINCE
+# define FAIL DebugBreak()
+# else
+# define FAIL GC_abort("Test failed");
+# endif
+# endif
+
+#endif /* !AMIGA_FASTALLOC */
+
+/* AT_END may be defined to exercise the interior pointer test */
+/* if the collector is configured with ALL_INTERIOR_POINTERS. */
+/* As it stands, this test should succeed with either */
+/* configuration. In the FIND_LEAK configuration, it should */
+/* find lots of leaks, since we free almost nothing. */
+
+struct SEXPR {
+ struct SEXPR * sexpr_car;
+ struct SEXPR * sexpr_cdr;
+};
+
+
+typedef struct SEXPR * sexpr;
+
+# define INT_TO_SEXPR(x) ((sexpr)(unsigned long)(x))
+
+# undef nil
+# define nil (INT_TO_SEXPR(0))
+# define car(x) ((x) -> sexpr_car)
+# define cdr(x) ((x) -> sexpr_cdr)
+# define is_nil(x) ((x) == nil)
+
+
+int extra_count = 0; /* Amount of space wasted in cons node */
+
+/* Silly implementation of Lisp cons. Intentionally wastes lots of space */
+/* to test collector. */
+# ifdef VERY_SMALL_CONFIG
+# define cons small_cons
+# else
+sexpr cons (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+ register int *p;
+ register int my_extra = extra_count;
+
+ stubborn_count++;
+ r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra);
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ for (p = (int *)r;
+ ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
+ if (*p) {
+ (void)GC_printf1("Found nonzero at 0x%lx - allocator is broken\n",
+ (unsigned long)p);
+ FAIL;
+ }
+ *p = 13;
+ }
+# ifdef AT_END
+ r = (sexpr)((char *)r + (my_extra & ~7));
+# endif
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = y;
+ my_extra++;
+ if ( my_extra >= 5000 ) {
+ extra_count = 0;
+ } else {
+ extra_count = my_extra;
+ }
+ GC_END_STUBBORN_CHANGE((char *)r);
+ return(r);
+}
+# endif
+
+#ifdef GC_GCJ_SUPPORT
+
+#include "gc_mark.h"
+#include "gc_gcj.h"
+
+/* The following struct emulates the vtable in gcj. */
+/* This assumes the default value of MARK_DESCR_OFFSET. */
+struct fake_vtable {
+ void * dummy; /* class pointer in real gcj. */
+ size_t descr;
+};
+
+struct fake_vtable gcj_class_struct1 = { 0, sizeof(struct SEXPR)
+ + sizeof(struct fake_vtable *) };
+ /* length based descriptor. */
+struct fake_vtable gcj_class_struct2 =
+ { 0, (3l << (CPP_WORDSZ - 3)) | GC_DS_BITMAP};
+ /* Bitmap based descriptor. */
+
+struct GC_ms_entry * fake_gcj_mark_proc(word * addr,
+ struct GC_ms_entry *mark_stack_ptr,
+ struct GC_ms_entry *mark_stack_limit,
+ word env )
+{
+ sexpr x;
+ if (1 == env) {
+ /* Object allocated with debug allocator. */
+ addr = (word *)GC_USR_PTR_FROM_BASE(addr);
+ }
+ x = (sexpr)(addr + 1); /* Skip the vtable pointer. */
+ mark_stack_ptr = GC_MARK_AND_PUSH(
+ (GC_PTR)(x -> sexpr_cdr), mark_stack_ptr,
+ mark_stack_limit, (GC_PTR *)&(x -> sexpr_cdr));
+ mark_stack_ptr = GC_MARK_AND_PUSH(
+ (GC_PTR)(x -> sexpr_car), mark_stack_ptr,
+ mark_stack_limit, (GC_PTR *)&(x -> sexpr_car));
+ return(mark_stack_ptr);
+}
+
+#endif /* GC_GCJ_SUPPORT */
+
+#ifdef THREAD_LOCAL_ALLOC
+
+#undef GC_REDIRECT_TO_LOCAL
+#include "gc_local_alloc.h"
+
+sexpr local_cons (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+ register int *p;
+ register int my_extra = extra_count;
+ static int my_random = 0;
+
+ collectable_count++;
+ r = (sexpr) GC_LOCAL_MALLOC(sizeof(struct SEXPR) + my_extra);
+# ifdef GC_GCJ_SUPPORT
+ if (collectable_count % 2 == 0) {
+ r = (sexpr) GC_LOCAL_GCJ_MALLOC(sizeof(struct SEXPR) + sizeof(GC_word) + my_extra,
+ &gcj_class_struct1);
+ r = (sexpr) ((GC_word *)r + 1);
+ }
+# endif
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ for (p = (int *)r;
+ ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
+ if (*p) {
+ (void)GC_printf1("Found nonzero at 0x%lx (local) - allocator is broken\n",
+ (unsigned long)p);
+ FAIL;
+ }
+ *p = 13;
+ }
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = y;
+ my_extra++;
+ if ( my_extra >= 5000 || my_extra == 200 && ++my_random % 37 != 0) {
+ extra_count = 0;
+ } else {
+ extra_count = my_extra;
+ }
+ return(r);
+}
+#endif /* THREAD_LOCAL_ALLOC */
+
+sexpr small_cons (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+
+ collectable_count++;
+ r = (sexpr) GC_MALLOC(sizeof(struct SEXPR));
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = y;
+ return(r);
+}
+
+sexpr small_cons_uncollectable (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+
+ uncollectable_count++;
+ r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR));
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = (sexpr)(~(unsigned long)y);
+ return(r);
+}
+
+#ifdef GC_GCJ_SUPPORT
+
+
+sexpr gcj_cons(x, y)
+sexpr x;
+sexpr y;
+{
+ GC_word * r;
+ sexpr result;
+ static int count = 0;
+
+ if (++count & 1) {
+# ifdef USE_MARK_BYTES
+ r = (GC_word *) GC_GCJ_FAST_MALLOC(4, &gcj_class_struct1);
+# else
+ r = (GC_word *) GC_GCJ_FAST_MALLOC(3, &gcj_class_struct1);
+# endif
+ } else {
+ r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR)
+ + sizeof(struct fake_vtable*),
+ &gcj_class_struct2);
+ }
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ result = (sexpr)(r + 1);
+ result -> sexpr_car = x;
+ result -> sexpr_cdr = y;
+ return(result);
+}
+#endif
+
+/* Return reverse(x) concatenated with y */
+sexpr reverse1(x, y)
+sexpr x, y;
+{
+ if (is_nil(x)) {
+ return(y);
+ } else {
+ return( reverse1(cdr(x), cons(car(x), y)) );
+ }
+}
+
+sexpr reverse(x)
+sexpr x;
+{
+# ifdef TEST_WITH_SYSTEM_MALLOC
+ malloc(100000);
+# endif
+ return( reverse1(x, nil) );
+}
+
+sexpr ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(small_cons(small_cons(INT_TO_SEXPR(low), nil), ints(low+1, up)));
+ }
+}
+
+#ifdef GC_GCJ_SUPPORT
+/* Return reverse(x) concatenated with y */
+sexpr gcj_reverse1(x, y)
+sexpr x, y;
+{
+ if (is_nil(x)) {
+ return(y);
+ } else {
+ return( gcj_reverse1(cdr(x), gcj_cons(car(x), y)) );
+ }
+}
+
+sexpr gcj_reverse(x)
+sexpr x;
+{
+ return( gcj_reverse1(x, nil) );
+}
+
+sexpr gcj_ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(gcj_cons(gcj_cons(INT_TO_SEXPR(low), nil), gcj_ints(low+1, up)));
+ }
+}
+#endif /* GC_GCJ_SUPPORT */
+
+#ifdef THREAD_LOCAL_ALLOC
+/* Return reverse(x) concatenated with y */
+sexpr local_reverse1(x, y)
+sexpr x, y;
+{
+ if (is_nil(x)) {
+ return(y);
+ } else {
+ return( local_reverse1(cdr(x), local_cons(car(x), y)) );
+ }
+}
+
+sexpr local_reverse(x)
+sexpr x;
+{
+ return( local_reverse1(x, nil) );
+}
+
+sexpr local_ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(local_cons(local_cons(INT_TO_SEXPR(low), nil), local_ints(low+1, up)));
+ }
+}
+#endif /* THREAD_LOCAL_ALLOC */
+
+/* To check uncollectable allocation we build lists with disguised cdr */
+/* pointers, and make sure they don't go away. */
+sexpr uncollectable_ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(small_cons_uncollectable(small_cons(INT_TO_SEXPR(low), nil),
+ uncollectable_ints(low+1, up)));
+ }
+}
+
+void check_ints(list, low, up)
+sexpr list;
+int low, up;
+{
+ if ((int)(GC_word)(car(car(list))) != low) {
+ (void)GC_printf0(
+ "List reversal produced incorrect list - collector is broken\n");
+ FAIL;
+ }
+ if (low == up) {
+ if (cdr(list) != nil) {
+ (void)GC_printf0("List too long - collector is broken\n");
+ FAIL;
+ }
+ } else {
+ check_ints(cdr(list), low+1, up);
+ }
+}
+
+# define UNCOLLECTABLE_CDR(x) (sexpr)(~(unsigned long)(cdr(x)))
+
+void check_uncollectable_ints(list, low, up)
+sexpr list;
+int low, up;
+{
+ if ((int)(GC_word)(car(car(list))) != low) {
+ (void)GC_printf0(
+ "Uncollectable list corrupted - collector is broken\n");
+ FAIL;
+ }
+ if (low == up) {
+ if (UNCOLLECTABLE_CDR(list) != nil) {
+ (void)GC_printf0("Uncollectable list too long - collector is broken\n");
+ FAIL;
+ }
+ } else {
+ check_uncollectable_ints(UNCOLLECTABLE_CDR(list), low+1, up);
+ }
+}
+
+/* Not used, but useful for debugging: */
+void print_int_list(x)
+sexpr x;
+{
+ if (is_nil(x)) {
+ (void)GC_printf0("NIL\n");
+ } else {
+ (void)GC_printf1("(%ld)", (long)(car(car(x))));
+ if (!is_nil(cdr(x))) {
+ (void)GC_printf0(", ");
+ (void)print_int_list(cdr(x));
+ } else {
+ (void)GC_printf0("\n");
+ }
+ }
+}
+
+/*
+ * A tiny list reversal test to check thread creation.
+ */
+#ifdef THREADS
+
+# if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
+ DWORD __stdcall tiny_reverse_test(void * arg)
+# else
+ void * tiny_reverse_test(void * arg)
+# endif
+{
+ int i;
+ for (i = 0; i < 5; ++i) {
+ check_ints(reverse(reverse(ints(1,10))), 1, 10);
+# ifdef THREAD_LOCAL_ALLOC
+ check_ints(local_reverse(local_reverse(local_ints(1,10))), 1, 10);
+# endif
+ }
+ return 0;
+}
+
+# if defined(GC_PTHREADS)
+ void fork_a_thread()
+ {
+ pthread_t t;
+ int code;
+ if ((code = pthread_create(&t, 0, tiny_reverse_test, 0)) != 0) {
+ (void)GC_printf1("Small thread creation failed %lu\n",
+ (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_join(t, 0)) != 0) {
+ (void)GC_printf1("Small thread join failed %lu\n",
+ (unsigned long)code);
+ FAIL;
+ }
+ }
+
+# elif defined(GC_WIN32_THREADS)
+ void fork_a_thread()
+ {
+ DWORD thread_id;
+ HANDLE h;
+ h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
+ if (h == (HANDLE)NULL) {
+ (void)GC_printf1("Small thread creation failed %lu\n",
+ (unsigned long)GetLastError());
+ FAIL;
+ }
+ if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) {
+ (void)GC_printf1("Small thread wait failed %lu\n",
+ (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+
+/* # elif defined(GC_SOLARIS_THREADS) */
+
+# else
+
+# define fork_a_thread()
+
+# endif
+
+#else
+
+# define fork_a_thread()
+
+#endif
+
+/* Try to force a to be strangely aligned */
+struct {
+ char dummy;
+ sexpr aa;
+} A;
+#define a A.aa
+
+/*
+ * Repeatedly reverse lists built out of very different sized cons cells.
+ * Check that we didn't lose anything.
+ */
+void reverse_test()
+{
+ int i;
+ sexpr b;
+ sexpr c;
+ sexpr d;
+ sexpr e;
+ sexpr *f, *g, *h;
+# if defined(MSWIN32) || defined(MACOS)
+ /* Win32S only allows 128K stacks */
+# define BIG 1000
+# else
+# if defined PCR
+ /* PCR default stack is 100K. Stack frames are up to 120 bytes. */
+# define BIG 700
+# else
+# if defined MSWINCE
+ /* WinCE only allows 64K stacks */
+# define BIG 500
+# else
+# if defined(OSF1)
+ /* OSF has limited stack space by default, and large frames. */
+# define BIG 200
+# else
+# if defined(__MACH__) && defined(__ppc64__)
+ /* Small stack and largish frames. */
+# define BIG 2500
+# else
+# define BIG 4500
+# endif
+# endif
+# endif
+# endif
+# endif
+
+ A.dummy = 17;
+ a = ints(1, 49);
+ b = ints(1, 50);
+ c = ints(1, BIG);
+ d = uncollectable_ints(1, 100);
+ e = uncollectable_ints(1, 1);
+ /* Check that realloc updates object descriptors correctly */
+ collectable_count++;
+ f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr));
+ realloc_count++;
+ f = (sexpr *)GC_REALLOC((GC_PTR)f, 6 * sizeof(sexpr));
+ f[5] = ints(1,17);
+ collectable_count++;
+ g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr));
+ realloc_count++;
+ g = (sexpr *)GC_REALLOC((GC_PTR)g, 800 * sizeof(sexpr));
+ g[799] = ints(1,18);
+ collectable_count++;
+ h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr));
+ realloc_count++;
+ h = (sexpr *)GC_REALLOC((GC_PTR)h, 2000 * sizeof(sexpr));
+# ifdef GC_GCJ_SUPPORT
+ h[1999] = gcj_ints(1,200);
+ for (i = 0; i < 51; ++i)
+ h[1999] = gcj_reverse(h[1999]);
+ /* Leave it as the reveresed list for now. */
+# else
+ h[1999] = ints(1,200);
+# endif
+ /* Try to force some collections and reuse of small list elements */
+ for (i = 0; i < 10; i++) {
+ (void)ints(1, BIG);
+ }
+ /* Superficially test interior pointer recognition on stack */
+ c = (sexpr)((char *)c + sizeof(char *));
+ d = (sexpr)((char *)d + sizeof(char *));
+
+# ifdef __STDC__
+ GC_FREE((void *)e);
+# else
+ GC_FREE((char *)e);
+# endif
+ check_ints(b,1,50);
+ check_ints(a,1,49);
+ for (i = 0; i < 50; i++) {
+ check_ints(b,1,50);
+ b = reverse(reverse(b));
+ }
+ check_ints(b,1,50);
+ check_ints(a,1,49);
+ for (i = 0; i < 60; i++) {
+ if (i % 10 == 0) fork_a_thread();
+ /* This maintains the invariant that a always points to a list of */
+ /* 49 integers. Thus this is thread safe without locks, */
+ /* assuming atomic pointer assignments. */
+ a = reverse(reverse(a));
+# ifdef THREAD_LOCAL_ALLOC
+ a = local_reverse(local_reverse(a));
+# endif
+# if !defined(AT_END) && !defined(THREADS)
+ /* This is not thread safe, since realloc explicitly deallocates */
+ if (i & 1) {
+ a = (sexpr)GC_REALLOC((GC_PTR)a, 500);
+ } else {
+ a = (sexpr)GC_REALLOC((GC_PTR)a, 8200);
+ }
+# endif
+ }
+ check_ints(a,1,49);
+ check_ints(b,1,50);
+ c = (sexpr)((char *)c - sizeof(char *));
+ d = (sexpr)((char *)d - sizeof(char *));
+ check_ints(c,1,BIG);
+ check_uncollectable_ints(d, 1, 100);
+ check_ints(f[5], 1,17);
+ check_ints(g[799], 1,18);
+# ifdef GC_GCJ_SUPPORT
+ h[1999] = gcj_reverse(h[1999]);
+# endif
+ check_ints(h[1999], 1,200);
+# ifndef THREADS
+ a = 0;
+# endif
+ b = c = 0;
+}
+
+#undef a
+
+/*
+ * The rest of this builds balanced binary trees, checks that they don't
+ * disappear, and tests finalization.
+ */
+typedef struct treenode {
+ int level;
+ struct treenode * lchild;
+ struct treenode * rchild;
+} tn;
+
+int finalizable_count = 0;
+int finalized_count = 0;
+VOLATILE int dropped_something = 0;
+
+# ifdef __STDC__
+ void finalizer(void * obj, void * client_data)
+# else
+ void finalizer(obj, client_data)
+ char * obj;
+ char * client_data;
+# endif
+{
+ tn * t = (tn *)obj;
+
+# ifdef PCR
+ PCR_ThCrSec_EnterSys();
+# endif
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+ static mutex_t incr_lock;
+ mutex_lock(&incr_lock);
+# endif
+# if defined(GC_PTHREADS)
+ static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&incr_lock);
+# else
+# ifdef GC_WIN32_THREADS
+ EnterCriticalSection(&incr_cs);
+# endif
+# endif
+ if ((int)(GC_word)client_data != t -> level) {
+ (void)GC_printf0("Wrong finalization data - collector is broken\n");
+ FAIL;
+ }
+ finalized_count++;
+ t -> level = -1; /* detect duplicate finalization immediately */
+# ifdef PCR
+ PCR_ThCrSec_ExitSys();
+# endif
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+ mutex_unlock(&incr_lock);
+# endif
+# if defined(GC_PTHREADS)
+ pthread_mutex_unlock(&incr_lock);
+# else
+# ifdef GC_WIN32_THREADS
+ LeaveCriticalSection(&incr_cs);
+# endif
+# endif
+}
+
+size_t counter = 0;
+
+# define MAX_FINALIZED 8000
+
+# if !defined(MACOS)
+ GC_FAR GC_word live_indicators[MAX_FINALIZED] = {0};
+#else
+ /* Too big for THINK_C. have to allocate it dynamically. */
+ GC_word *live_indicators = 0;
+#endif
+
+int live_indicators_count = 0;
+
+tn * mktree(n)
+int n;
+{
+# ifdef THREAD_LOCAL_ALLOC
+ tn * result = (tn *)GC_LOCAL_MALLOC(sizeof(tn));
+# else
+ tn * result = (tn *)GC_MALLOC(sizeof(tn));
+# endif
+
+ collectable_count++;
+# ifdef THREAD_LOCAL_ALLOC
+ /* Minimally exercise thread local allocation */
+ {
+ char * result = (char *)GC_LOCAL_MALLOC_ATOMIC(17);
+ memset(result, 'a', 17);
+ }
+# endif /* THREAD_LOCAL_ALLOC */
+# if defined(MACOS)
+ /* get around static data limitations. */
+ if (!live_indicators)
+ live_indicators =
+ (GC_word*)NewPtrClear(MAX_FINALIZED * sizeof(GC_word));
+ if (!live_indicators) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+# endif
+ if (n == 0) return(0);
+ if (result == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ result -> level = n;
+ result -> lchild = mktree(n-1);
+ result -> rchild = mktree(n-1);
+ if (counter++ % 17 == 0 && n >= 2) {
+ tn * tmp = result -> lchild -> rchild;
+
+ result -> lchild -> rchild = result -> rchild -> lchild;
+ result -> rchild -> lchild = tmp;
+ }
+ if (counter++ % 119 == 0) {
+ int my_index;
+
+ {
+# ifdef PCR
+ PCR_ThCrSec_EnterSys();
+# endif
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+ static mutex_t incr_lock;
+ mutex_lock(&incr_lock);
+# endif
+# if defined(GC_PTHREADS)
+ static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&incr_lock);
+# else
+# ifdef GC_WIN32_THREADS
+ EnterCriticalSection(&incr_cs);
+# endif
+# endif
+ /* Losing a count here causes erroneous report of failure. */
+ finalizable_count++;
+ my_index = live_indicators_count++;
+# ifdef PCR
+ PCR_ThCrSec_ExitSys();
+# endif
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+ mutex_unlock(&incr_lock);
+# endif
+# if defined(GC_PTHREADS)
+ pthread_mutex_unlock(&incr_lock);
+# else
+# ifdef GC_WIN32_THREADS
+ LeaveCriticalSection(&incr_cs);
+# endif
+# endif
+ }
+
+ GC_REGISTER_FINALIZER((GC_PTR)result, finalizer, (GC_PTR)(GC_word)n,
+ (GC_finalization_proc *)0, (GC_PTR *)0);
+ if (my_index >= MAX_FINALIZED) {
+ GC_printf0("live_indicators overflowed\n");
+ FAIL;
+ }
+ live_indicators[my_index] = 13;
+ if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
+ (GC_PTR *)(&(live_indicators[my_index])),
+ (GC_PTR)result) != 0) {
+ GC_printf0("GC_general_register_disappearing_link failed\n");
+ FAIL;
+ }
+ if (GC_unregister_disappearing_link(
+ (GC_PTR *)
+ (&(live_indicators[my_index]))) == 0) {
+ GC_printf0("GC_unregister_disappearing_link failed\n");
+ FAIL;
+ }
+ if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
+ (GC_PTR *)(&(live_indicators[my_index])),
+ (GC_PTR)result) != 0) {
+ GC_printf0("GC_general_register_disappearing_link failed 2\n");
+ FAIL;
+ }
+ }
+ return(result);
+}
+
+void chktree(t,n)
+tn *t;
+int n;
+{
+ if (n == 0 && t != 0) {
+ (void)GC_printf0("Clobbered a leaf - collector is broken\n");
+ FAIL;
+ }
+ if (n == 0) return;
+ if (t -> level != n) {
+ (void)GC_printf1("Lost a node at level %lu - collector is broken\n",
+ (unsigned long)n);
+ FAIL;
+ }
+ if (counter++ % 373 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%5001);
+ }
+ chktree(t -> lchild, n-1);
+ if (counter++ % 73 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%373);
+ }
+ chktree(t -> rchild, n-1);
+}
+
+# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+thread_key_t fl_key;
+
+void * alloc8bytes()
+{
+# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
+ return(GC_MALLOC(8));
+# else
+ void ** my_free_list_ptr;
+ void * my_free_list;
+
+ if (thr_getspecific(fl_key, (void **)(&my_free_list_ptr)) != 0) {
+ (void)GC_printf0("thr_getspecific failed\n");
+ FAIL;
+ }
+ if (my_free_list_ptr == 0) {
+ uncollectable_count++;
+ my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
+ if (thr_setspecific(fl_key, my_free_list_ptr) != 0) {
+ (void)GC_printf0("thr_setspecific failed\n");
+ FAIL;
+ }
+ }
+ my_free_list = *my_free_list_ptr;
+ if (my_free_list == 0) {
+ collectable_count++;
+ my_free_list = GC_malloc_many(8);
+ if (my_free_list == 0) {
+ (void)GC_printf0("alloc8bytes out of memory\n");
+ FAIL;
+ }
+ }
+ *my_free_list_ptr = GC_NEXT(my_free_list);
+ GC_NEXT(my_free_list) = 0;
+ return(my_free_list);
+# endif
+}
+
+#else
+
+# if defined(GC_PTHREADS)
+pthread_key_t fl_key;
+
+void * alloc8bytes()
+{
+# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
+ return(GC_MALLOC(8));
+# else
+ void ** my_free_list_ptr;
+ void * my_free_list;
+
+ my_free_list_ptr = (void **)pthread_getspecific(fl_key);
+ if (my_free_list_ptr == 0) {
+ uncollectable_count++;
+ my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
+ if (pthread_setspecific(fl_key, my_free_list_ptr) != 0) {
+ (void)GC_printf0("pthread_setspecific failed\n");
+ FAIL;
+ }
+ }
+ my_free_list = *my_free_list_ptr;
+ if (my_free_list == 0) {
+ my_free_list = GC_malloc_many(8);
+ if (my_free_list == 0) {
+ (void)GC_printf0("alloc8bytes out of memory\n");
+ FAIL;
+ }
+ }
+ *my_free_list_ptr = GC_NEXT(my_free_list);
+ GC_NEXT(my_free_list) = 0;
+ collectable_count++;
+ return(my_free_list);
+# endif
+}
+
+# else
+# define alloc8bytes() GC_MALLOC_ATOMIC(8)
+# endif
+#endif
+
+void alloc_small(n)
+int n;
+{
+ register int i;
+
+ for (i = 0; i < n; i += 8) {
+ atomic_count++;
+ if (alloc8bytes() == 0) {
+ (void)GC_printf0("Out of memory\n");
+ FAIL;
+ }
+ }
+}
+
+# if defined(THREADS) && defined(GC_DEBUG)
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 12
+# else
+# define TREE_HEIGHT 15
+# endif
+# else
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 13
+# else
+# define TREE_HEIGHT 16
+# endif
+# endif
+void tree_test()
+{
+ tn * root;
+ register int i;
+
+ root = mktree(TREE_HEIGHT);
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
+ chktree(root, TREE_HEIGHT);
+ if (finalized_count && ! dropped_something) {
+ (void)GC_printf0("Premature finalization - collector is broken\n");
+ FAIL;
+ }
+ dropped_something = 1;
+ GC_noop(root); /* Root needs to remain live until */
+ /* dropped_something is set. */
+ root = mktree(TREE_HEIGHT);
+ chktree(root, TREE_HEIGHT);
+ for (i = TREE_HEIGHT; i >= 0; i--) {
+ root = mktree(i);
+ chktree(root, i);
+ }
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
+}
+
+unsigned n_tests = 0;
+
+GC_word bm_huge[10] = {
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0x00ffffff,
+};
+
+/* A very simple test of explicitly typed allocation */
+void typed_test()
+{
+ GC_word * old, * new;
+ GC_word bm3 = 0x3;
+ GC_word bm2 = 0x2;
+ GC_word bm_large = 0xf7ff7fff;
+ GC_descr d1 = GC_make_descriptor(&bm3, 2);
+ GC_descr d2 = GC_make_descriptor(&bm2, 2);
+# ifndef LINT
+ GC_descr dummy = GC_make_descriptor(&bm_large, 32);
+# endif
+ GC_descr d3 = GC_make_descriptor(&bm_large, 32);
+ GC_descr d4 = GC_make_descriptor(bm_huge, 320);
+ GC_word * x = (GC_word *)GC_malloc_explicitly_typed(2000, d4);
+ register int i;
+
+ collectable_count++;
+ old = 0;
+ for (i = 0; i < 4000; i++) {
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d1);
+ if (0 != new[0] || 0 != new[1]) {
+ GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
+ FAIL;
+ }
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d2);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(33 * sizeof(GC_word), d3);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_calloc_explicitly_typed(4, 2 * sizeof(GC_word),
+ d1);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ if (i & 0xff) {
+ new = (GC_word *) GC_calloc_explicitly_typed(7, 3 * sizeof(GC_word),
+ d2);
+ } else {
+ new = (GC_word *) GC_calloc_explicitly_typed(1001,
+ 3 * sizeof(GC_word),
+ d2);
+ if (0 != new[0] || 0 != new[1]) {
+ GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
+ FAIL;
+ }
+ }
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ }
+ for (i = 0; i < 20000; i++) {
+ if (new[0] != 17) {
+ (void)GC_printf1("typed alloc failed at %lu\n",
+ (unsigned long)i);
+ FAIL;
+ }
+ new[0] = 0;
+ old = new;
+ new = (GC_word *)(old[1]);
+ }
+ GC_gcollect();
+ GC_noop(x);
+}
+
+int fail_count = 0;
+
+#ifndef __STDC__
+/*ARGSUSED*/
+void fail_proc1(x)
+GC_PTR x;
+{
+ fail_count++;
+}
+
+#else
+
+/*ARGSUSED*/
+void fail_proc1(GC_PTR x)
+{
+ fail_count++;
+}
+
+static void uniq(void *p, ...) {
+ va_list a;
+ void *q[100];
+ int n = 0, i, j;
+ q[n++] = p;
+ va_start(a,p);
+ for (;(q[n] = va_arg(a,void *));n++) ;
+ va_end(a);
+ for (i=0; i<n; i++)
+ for (j=0; j<i; j++)
+ if (q[i] == q[j]) {
+ GC_printf0(
+ "Apparently failed to mark form some function arguments.\n"
+ "Perhaps GC_push_regs was configured incorrectly?\n"
+ );
+ FAIL;
+ }
+}
+
+#endif /* __STDC__ */
+
+#ifdef THREADS
+# define TEST_FAIL_COUNT(n) 1
+#else
+# define TEST_FAIL_COUNT(n) (fail_count >= (n))
+#endif
+
+void run_one_test()
+{
+ char *x;
+# ifdef LINT
+ char *y = 0;
+# else
+ char *y = (char *)(size_t)fail_proc1;
+# endif
+ DCL_LOCK_STATE;
+
+# ifdef FIND_LEAK
+ (void)GC_printf0(
+ "This test program is not designed for leak detection mode\n");
+ (void)GC_printf0("Expect lots of problems.\n");
+# endif
+ GC_FREE(0);
+# ifndef DBG_HDRS_ALL
+ collectable_count += 3;
+ if (GC_size(GC_malloc(7)) != 8 &&
+ GC_size(GC_malloc(7)) != MIN_WORDS * sizeof(GC_word)
+ || GC_size(GC_malloc(15)) != 16) {
+ (void)GC_printf0("GC_size produced unexpected results\n");
+ FAIL;
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc(0)) != MIN_WORDS * sizeof(GC_word)) {
+ (void)GC_printf1("GC_malloc(0) failed: GC_size returns %ld\n",
+ GC_size(GC_malloc(0)));
+ FAIL;
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc_uncollectable(0)) != MIN_WORDS * sizeof(GC_word)) {
+ (void)GC_printf0("GC_malloc_uncollectable(0) failed\n");
+ FAIL;
+ }
+ GC_is_valid_displacement_print_proc = fail_proc1;
+ GC_is_visible_print_proc = fail_proc1;
+ collectable_count += 1;
+ x = GC_malloc(16);
+ if (GC_base(x + 13) != x) {
+ (void)GC_printf0("GC_base(heap ptr) produced incorrect result\n");
+ FAIL;
+ }
+# ifndef PCR
+ if (GC_base(y) != 0) {
+ (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n");
+ FAIL;
+ }
+# endif
+ if (GC_same_obj(x+5, x) != x + 5) {
+ (void)GC_printf0("GC_same_obj produced incorrect result\n");
+ FAIL;
+ }
+ if (GC_is_visible(y) != y || GC_is_visible(x) != x) {
+ (void)GC_printf0("GC_is_visible produced incorrect result\n");
+ FAIL;
+ }
+ if (!TEST_FAIL_COUNT(1)) {
+# if!(defined(RS6000) || defined(POWERPC) || defined(IA64)) || defined(M68K)
+ /* ON RS6000s function pointers point to a descriptor in the */
+ /* data segment, so there should have been no failures. */
+ /* The same applies to IA64. Something similar seems to */
+ /* be going on with NetBSD/M68K. */
+ (void)GC_printf0("GC_is_visible produced wrong failure indication\n");
+ FAIL;
+# endif
+ }
+ if (GC_is_valid_displacement(y) != y
+ || GC_is_valid_displacement(x) != x
+ || GC_is_valid_displacement(x + 3) != x + 3) {
+ (void)GC_printf0(
+ "GC_is_valid_displacement produced incorrect result\n");
+ FAIL;
+ }
+# if defined(__STDC__) && !defined(MSWIN32) && !defined(MSWINCE)
+ /* Harder to test under Windows without a gc.h declaration. */
+ {
+ size_t i;
+ extern void *GC_memalign();
+
+ GC_malloc(17);
+ for (i = sizeof(GC_word); i < 512; i *= 2) {
+ GC_word result = (GC_word) GC_memalign(i, 17);
+ if (result % i != 0 || result == 0 || *(int *)result != 0) FAIL;
+ }
+ }
+# endif
+# ifndef ALL_INTERIOR_POINTERS
+# if defined(RS6000) || defined(POWERPC)
+ if (!TEST_FAIL_COUNT(1)) {
+# else
+ if (GC_all_interior_pointers && !TEST_FAIL_COUNT(1)
+ || !GC_all_interior_pointers && !TEST_FAIL_COUNT(2)) {
+# endif
+ (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n");
+ FAIL;
+ }
+# endif
+# endif /* DBG_HDRS_ALL */
+ /* Test floating point alignment */
+ collectable_count += 2;
+ *(double *)GC_MALLOC(sizeof(double)) = 1.0;
+ *(double *)GC_MALLOC(sizeof(double)) = 1.0;
+# ifdef GC_GCJ_SUPPORT
+ GC_REGISTER_DISPLACEMENT(sizeof(struct fake_vtable *));
+ GC_init_gcj_malloc(0, (void *)fake_gcj_mark_proc);
+# endif
+ /* Make sure that fn arguments are visible to the collector. */
+# ifdef __STDC__
+ uniq(
+ GC_malloc(12), GC_malloc(12), GC_malloc(12),
+ (GC_gcollect(),GC_malloc(12)),
+ GC_malloc(12), GC_malloc(12), GC_malloc(12),
+ (GC_gcollect(),GC_malloc(12)),
+ GC_malloc(12), GC_malloc(12), GC_malloc(12),
+ (GC_gcollect(),GC_malloc(12)),
+ GC_malloc(12), GC_malloc(12), GC_malloc(12),
+ (GC_gcollect(),GC_malloc(12)),
+ GC_malloc(12), GC_malloc(12), GC_malloc(12),
+ (GC_gcollect(),GC_malloc(12)),
+ (void *)0);
+# endif
+ /* Repeated list reversal test. */
+ reverse_test();
+# ifdef PRINTSTATS
+ GC_printf0("-------------Finished reverse_test\n");
+# endif
+# ifndef DBG_HDRS_ALL
+ typed_test();
+# ifdef PRINTSTATS
+ GC_printf0("-------------Finished typed_test\n");
+# endif
+# endif /* DBG_HDRS_ALL */
+ tree_test();
+ LOCK();
+ n_tests++;
+ UNLOCK();
+# if defined(THREADS) && defined(HANDLE_FORK)
+ if (fork() == 0) {
+ GC_gcollect();
+ tiny_reverse_test(0);
+ GC_gcollect();
+ GC_printf0("Finished a child process\n");
+ exit(0);
+ }
+# endif
+ /* GC_printf1("Finished %x\n", pthread_self()); */
+}
+
+void check_heap_stats()
+{
+ unsigned long max_heap_sz;
+ register int i;
+ int still_live;
+ int late_finalize_count = 0;
+
+# ifdef VERY_SMALL_CONFIG
+ /* these are something of a guess */
+ if (sizeof(char *) > 4) {
+ max_heap_sz = 4500000;
+ } else {
+ max_heap_sz = 2800000;
+ }
+# else
+ if (sizeof(char *) > 4) {
+ max_heap_sz = 19000000;
+ } else {
+ max_heap_sz = 11000000;
+ }
+# endif
+# ifndef ALIGN_DOUBLE
+ /* We end up needing more small object pages. */
+ max_heap_sz += 2000000;
+# endif
+# ifdef GC_DEBUG
+ max_heap_sz *= 2;
+# ifdef SAVE_CALL_CHAIN
+ max_heap_sz *= 3;
+# ifdef SAVE_CALL_COUNT
+ max_heap_sz += max_heap_sz * SAVE_CALL_COUNT/4;
+# endif
+# endif
+# endif
+ /* Garbage collect repeatedly so that all inaccessible objects */
+ /* can be finalized. */
+ while (GC_collect_a_little()) { }
+ for (i = 0; i < 16; i++) {
+ GC_gcollect();
+ late_finalize_count += GC_invoke_finalizers();
+ }
+ (void)GC_printf1("Completed %lu tests\n", (unsigned long)n_tests);
+ (void)GC_printf1("Allocated %lu collectable objects\n", (unsigned long)collectable_count);
+ (void)GC_printf1("Allocated %lu uncollectable objects\n", (unsigned long)uncollectable_count);
+ (void)GC_printf1("Allocated %lu atomic objects\n", (unsigned long)atomic_count);
+ (void)GC_printf1("Allocated %lu stubborn objects\n", (unsigned long)stubborn_count);
+ (void)GC_printf2("Finalized %lu/%lu objects - ",
+ (unsigned long)finalized_count,
+ (unsigned long)finalizable_count);
+# ifdef FINALIZE_ON_DEMAND
+ if (finalized_count != late_finalize_count) {
+ (void)GC_printf0("Demand finalization error\n");
+ FAIL;
+ }
+# endif
+ if (finalized_count > finalizable_count
+ || finalized_count < finalizable_count/2) {
+ (void)GC_printf0("finalization is probably broken\n");
+ FAIL;
+ } else {
+ (void)GC_printf0("finalization is probably ok\n");
+ }
+ still_live = 0;
+ for (i = 0; i < MAX_FINALIZED; i++) {
+ if (live_indicators[i] != 0) {
+ still_live++;
+ }
+ }
+ i = finalizable_count - finalized_count - still_live;
+ if (0 != i) {
+ (void)GC_printf2
+ ("%lu disappearing links remain and %ld more objects were not finalized\n",
+ (unsigned long) still_live, (long)i);
+ if (i > 10) {
+ GC_printf0("\tVery suspicious!\n");
+ } else {
+ GC_printf0("\tSlightly suspicious, but probably OK.\n");
+ }
+ }
+ (void)GC_printf1("Total number of bytes allocated is %lu\n",
+ (unsigned long)
+ WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc));
+ (void)GC_printf1("Final heap size is %lu bytes\n",
+ (unsigned long)GC_get_heap_size());
+ if (WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc)
+# ifdef VERY_SMALL_CONFIG
+ < 2700000*n_tests) {
+# else
+ < 33500000*n_tests) {
+# endif
+ (void)GC_printf0("Incorrect execution - missed some allocations\n");
+ FAIL;
+ }
+ if (GC_get_heap_size() > max_heap_sz*n_tests) {
+ (void)GC_printf0("Unexpected heap growth - collector may be broken\n");
+ FAIL;
+ }
+ (void)GC_printf0("Collector appears to work\n");
+}
+
+#if defined(MACOS)
+void SetMinimumStack(long minSize)
+{
+ long newApplLimit;
+
+ if (minSize > LMGetDefltStack())
+ {
+ newApplLimit = (long) GetApplLimit()
+ - (minSize - LMGetDefltStack());
+ SetApplLimit((Ptr) newApplLimit);
+ MaxApplZone();
+ }
+}
+
+#define cMinStackSpace (512L * 1024L)
+
+#endif
+
+#ifdef __STDC__
+ void warn_proc(char *msg, GC_word p)
+#else
+ void warn_proc(msg, p)
+ char *msg;
+ GC_word p;
+#endif
+{
+ GC_printf1(msg, (unsigned long)p);
+ /*FAIL;*/
+}
+
+
+#if !defined(PCR) && !defined(GC_SOLARIS_THREADS) \
+ && !defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) \
+ || defined(LINT)
+#if defined(MSWIN32) && !defined(__MINGW32__)
+ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n)
+#else
+ int main()
+#endif
+{
+# if defined(DJGPP)
+ int dummy;
+# endif
+ n_tests = 0;
+
+# if defined(DJGPP)
+ /* No good way to determine stack base from library; do it */
+ /* manually on this platform. */
+ GC_stackbottom = (GC_PTR)(&dummy);
+# endif
+# if defined(MACOS)
+ /* Make sure we have lots and lots of stack space. */
+ SetMinimumStack(cMinStackSpace);
+ /* Cheat and let stdio initialize toolbox for us. */
+ printf("Testing GC Macintosh port.\n");
+# endif
+ GC_INIT(); /* Only needed on a few platforms. */
+ (void) GC_set_warn_proc(warn_proc);
+# if (defined(MPROTECT_VDB) || defined(PROC_VDB)) \
+ && !defined(MAKE_BACK_GRAPH)
+ GC_enable_incremental();
+ (void) GC_printf0("Switched to incremental mode\n");
+# if defined(MPROTECT_VDB)
+ (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
+# else
+# ifdef PROC_VDB
+ (void)GC_printf0("Reading dirty bits from /proc\n");
+# else
+ (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
+# endif
+# endif
+# endif
+ run_one_test();
+ check_heap_stats();
+# ifndef MSWINCE
+ (void)fflush(stdout);
+# endif
+# ifdef LINT
+ /* Entry points we should be testing, but aren't. */
+ /* Some can be tested by defining GC_DEBUG at the top of this file */
+ /* This is a bit SunOS4 specific. */
+ GC_noop(GC_expand_hp, GC_add_roots, GC_clear_roots,
+ GC_register_disappearing_link,
+ GC_register_finalizer_ignore_self,
+ GC_debug_register_displacement,
+ GC_print_obj, GC_debug_change_stubborn,
+ GC_debug_end_stubborn_change, GC_debug_malloc_uncollectable,
+ GC_debug_free, GC_debug_realloc, GC_generic_malloc_words_small,
+ GC_init, GC_make_closure, GC_debug_invoke_finalizer,
+ GC_page_was_ever_dirty, GC_is_fresh,
+ GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page,
+ GC_set_max_heap_size, GC_get_bytes_since_gc,
+ GC_get_total_bytes, GC_pre_incr, GC_post_incr);
+# endif
+# ifdef MSWIN32
+ GC_win32_free_heap();
+# endif
+ return(0);
+}
+# endif
+
+#if defined(GC_WIN32_THREADS) && !defined(CYGWIN32)
+
+DWORD __stdcall thr_run_one_test(void *arg)
+{
+ run_one_test();
+ return 0;
+}
+
+#ifdef MSWINCE
+HANDLE win_created_h;
+HWND win_handle;
+
+LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret = 0;
+ switch (uMsg) {
+ case WM_HIBERNATE:
+ GC_printf0("Received WM_HIBERNATE, calling GC_gcollect\n");
+ GC_gcollect();
+ break;
+ case WM_CLOSE:
+ GC_printf0("Received WM_CLOSE, closing window\n");
+ DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ ret = DefWindowProc(hwnd, uMsg, wParam, lParam);
+ break;
+ }
+ return ret;
+}
+
+DWORD __stdcall thr_window(void *arg)
+{
+ WNDCLASS win_class = {
+ CS_NOCLOSE,
+ window_proc,
+ 0,
+ 0,
+ GetModuleHandle(NULL),
+ NULL,
+ NULL,
+ (HBRUSH)(COLOR_APPWORKSPACE+1),
+ NULL,
+ L"GCtestWindow"
+ };
+ MSG msg;
+
+ if (!RegisterClass(&win_class))
+ FAIL;
+
+ win_handle = CreateWindowEx(
+ 0,
+ L"GCtestWindow",
+ L"GCtest",
+ 0,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL);
+
+ if (win_handle == NULL)
+ FAIL;
+
+ SetEvent(win_created_h);
+
+ ShowWindow(win_handle, SW_SHOW);
+ UpdateWindow(win_handle);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+#endif
+
+#define NTEST 2
+
+# ifdef MSWINCE
+int APIENTRY GC_WinMain(HINSTANCE instance, HINSTANCE prev, LPWSTR cmd, int n)
+# else
+int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
+# endif
+{
+# if NTEST > 0
+ HANDLE h[NTEST];
+ int i;
+# endif
+# ifdef MSWINCE
+ HANDLE win_thr_h;
+# endif
+ DWORD thread_id;
+# if 0
+ GC_enable_incremental();
+# endif
+ GC_init();
+ InitializeCriticalSection(&incr_cs);
+ (void) GC_set_warn_proc(warn_proc);
+# ifdef MSWINCE
+ win_created_h = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (win_created_h == (HANDLE)NULL) {
+ (void)GC_printf1("Event creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ win_thr_h = GC_CreateThread(NULL, 0, thr_window, 0, 0, &thread_id);
+ if (win_thr_h == (HANDLE)NULL) {
+ (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ if (WaitForSingleObject(win_created_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+ CloseHandle(win_created_h);
+# endif
+# if NTEST > 0
+ for (i = 0; i < NTEST; i++) {
+ h[i] = GC_CreateThread(NULL, 0, thr_run_one_test, 0, 0, &thread_id);
+ if (h[i] == (HANDLE)NULL) {
+ (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+# endif /* NTEST > 0 */
+ run_one_test();
+# if NTEST > 0
+ for (i = 0; i < NTEST; i++) {
+ if (WaitForSingleObject(h[i], INFINITE) != WAIT_OBJECT_0) {
+ (void)GC_printf1("Thread wait failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+# endif /* NTEST > 0 */
+# ifdef MSWINCE
+ PostMessage(win_handle, WM_CLOSE, 0, 0);
+ if (WaitForSingleObject(win_thr_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+# endif
+ check_heap_stats();
+ return(0);
+}
+
+#endif /* GC_WIN32_THREADS */
+
+
+#ifdef PCR
+test()
+{
+ PCR_Th_T * th1;
+ PCR_Th_T * th2;
+ int code;
+
+ n_tests = 0;
+ /* GC_enable_incremental(); */
+ (void) GC_set_warn_proc(warn_proc);
+ th1 = PCR_Th_Fork(run_one_test, 0);
+ th2 = PCR_Th_Fork(run_one_test, 0);
+ run_one_test();
+ if (PCR_Th_T_Join(th1, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
+ != PCR_ERes_okay || code != 0) {
+ (void)GC_printf0("Thread 1 failed\n");
+ }
+ if (PCR_Th_T_Join(th2, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
+ != PCR_ERes_okay || code != 0) {
+ (void)GC_printf0("Thread 2 failed\n");
+ }
+ check_heap_stats();
+ return(0);
+}
+#endif
+
+#if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS)
+void * thr_run_one_test(void * arg)
+{
+ run_one_test();
+ return(0);
+}
+
+#ifdef GC_DEBUG
+# define GC_free GC_debug_free
+#endif
+
+#if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS)
+main()
+{
+ thread_t th1;
+ thread_t th2;
+ int code;
+
+ n_tests = 0;
+ GC_INIT(); /* Only needed if gc is dynamic library. */
+# ifndef MAKE_BACK_GRAPH
+ GC_enable_incremental();
+# endif
+ (void) GC_set_warn_proc(warn_proc);
+ if (thr_keycreate(&fl_key, GC_free) != 0) {
+ (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, 0, &th1)) != 0) {
+ (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, THR_NEW_LWP, &th2)) != 0) {
+ (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ run_one_test();
+ if ((code = thr_join(th1, 0, 0)) != 0) {
+ (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if (thr_join(th2, 0, 0) != 0) {
+ (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ check_heap_stats();
+ (void)fflush(stdout);
+ return(0);
+}
+#else /* pthreads */
+
+#ifndef GC_PTHREADS
+ --> bad news
+#endif
+
+main()
+{
+ pthread_t th1;
+ pthread_t th2;
+ pthread_attr_t attr;
+ int code;
+
+# ifdef GC_IRIX_THREADS
+ /* Force a larger stack to be preallocated */
+ /* Since the initial cant always grow later. */
+ *((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */
+# endif /* GC_IRIX_THREADS */
+# if defined(GC_HPUX_THREADS)
+ /* Default stack size is too small, especially with the 64 bit ABI */
+ /* Increase it. */
+ if (pthread_default_stacksize_np(1024*1024, 0) != 0) {
+ (void)GC_printf0("pthread_default_stacksize_np failed.\n");
+ }
+# endif /* GC_HPUX_THREADS */
+ GC_INIT();
+
+ pthread_attr_init(&attr);
+# if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) \
+ || defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)
+ pthread_attr_setstacksize(&attr, 1000000);
+# endif
+ n_tests = 0;
+# if (defined(MPROTECT_VDB)) \
+ && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) \
+ && !defined(MAKE_BACK_GRAPH)
+ GC_enable_incremental();
+ (void) GC_printf0("Switched to incremental mode\n");
+# if defined(MPROTECT_VDB)
+ (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
+# else
+# ifdef PROC_VDB
+ (void)GC_printf0("Reading dirty bits from /proc\n");
+# else
+ (void)GC_printf0("Using DEFAULT_VDB dirty bit implementation\n");
+# endif
+# endif
+# endif
+ (void) GC_set_warn_proc(warn_proc);
+ if ((code = pthread_key_create(&fl_key, 0)) != 0) {
+ (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_create(&th1, &attr, thr_run_one_test, 0)) != 0) {
+ (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_create(&th2, &attr, thr_run_one_test, 0)) != 0) {
+ (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ run_one_test();
+ if ((code = pthread_join(th1, 0)) != 0) {
+ (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if (pthread_join(th2, 0) != 0) {
+ (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ check_heap_stats();
+ (void)fflush(stdout);
+ pthread_attr_destroy(&attr);
+ GC_printf1("Completed %d collections\n", GC_gc_no);
+ return(0);
+}
+#endif /* GC_PTHREADS */
+#endif /* GC_SOLARIS_THREADS || GC_PTHREADS */
--- /dev/null
+#include "leak_detector.h"
+
+int main() {
+ int *p[10];
+ int i;
+ GC_find_leak = 1; /* for new collect versions not compiled */
+ /* with -DFIND_LEAK. */
+ for (i = 0; i < 10; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ for (i = 1; i < 10; ++i) {
+ free(p[i]);
+ }
+ for (i = 0; i < 9; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ return 0;
+}
--- /dev/null
+/*
+ * Test at the boundary between small and large objects.
+ * Inspired by a test case from Zoltan Varga.
+ */
+#include <gc.h>
+#include <stdio.h>
+
+int main ()
+{
+ int i;
+
+ GC_all_interior_pointers = 0;
+
+ for (i = 0; i < 20000; ++i) {
+ GC_malloc_atomic (4096);
+ GC_malloc (4096);
+ }
+ for (i = 0; i < 20000; ++i) {
+ GC_malloc_atomic (2048);
+ GC_malloc (2048);
+ }
+ printf("Final heap size is %ld\n", GC_get_heap_size());
+ return 0;
+}
+
--- /dev/null
+#define GC_LINUX_THREADS
+#include "leak_detector.h"
+#include <pthread.h>
+#include <stdio.h>
+
+void * test(void * arg) {
+ int *p[10];
+ int i;
+ GC_find_leak = 1; /* for new collect versions not compiled */
+ /* with -DFIND_LEAK. */
+ for (i = 0; i < 10; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ for (i = 1; i < 10; ++i) {
+ free(p[i]);
+ }
+}
+
+#define NTHREADS 5
+
+int main() {
+ int i;
+ pthread_t t[NTHREADS];
+ int code;
+
+ for (i = 0; i < NTHREADS; ++i) {
+ if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
+ printf("Thread creation failed %d\n", code);
+ }
+ }
+ for (i = 0; i < NTHREADS; ++i) {
+ if ((code = pthread_join(t[i], 0)) != 0) {
+ printf("Thread join failed %lu\n", code);
+ }
+ }
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ return 0;
+}
--- /dev/null
+/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
+
+#include <stdio.h>
+#define GC_DEBUG
+#include "gc.h"
+
+struct treenode {
+ struct treenode *x;
+ struct treenode *y;
+} * root[10];
+
+struct treenode * mktree(int i) {
+ struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+ if (0 == i) return 0;
+ if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+ r -> x = mktree(i-1);
+ r -> y = mktree(i-1);
+ return r;
+}
+
+int main()
+{
+ int i;
+ for (i = 0; i < 10; ++i) {
+ root[i] = mktree(12);
+ }
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+ return 0;
+}
--- /dev/null
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+boehm-gc-init
+
+# Gather list of tests, skipping library source files.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
+set tests [prune $tests $srcdir/$subdir/*lib.c]
+
+boehm-gc-dg-runtest $tests "-O2" ""
+
+dg-finish
--- /dev/null
+#include <stdio.h>
+
+#ifndef GC_DEBUG
+# define GC_DEBUG
+#endif
+
+#include "gc.h"
+
+struct treenode {
+ struct treenode *x;
+ struct treenode *y;
+} * root[10];
+
+struct treenode * libsrl_mktree(int i)
+{
+ struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+ if (0 == i) return 0;
+ if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+ r -> x = libsrl_mktree(i-1);
+ r -> y = libsrl_mktree(i-1);
+ return r;
+}
+
+void * libsrl_init(void)
+{
+ GC_INIT();
+ return GC_MALLOC(sizeof(struct treenode));
+}
+
+void * libsrl_collect (void)
+{
+ GC_gcollect();
+}
--- /dev/null
+/* { dg-add-shlib "staticrootslib.c" } */
+
+#include <stdio.h>
+
+#ifndef GC_DEBUG
+# define GC_DEBUG
+#endif
+
+#include "gc.h"
+#include "gc_backptr.h"
+
+struct treenode {
+ struct treenode *x;
+ struct treenode *y;
+} * root[10];
+
+static char *staticroot = 0;
+
+extern struct treenode * libsrl_mktree(int i);
+extern void * libsrl_init(void);
+extern void * libsrl_collect (void);
+
+int main(void)
+{
+ int i;
+ staticroot = libsrl_init();
+ for (i = 0; i < sizeof(struct treenode); ++i) {
+ staticroot[i] = 0x42;
+ }
+ libsrl_collect();
+ for (i = 0; i < 10; ++i) {
+ root[i] = libsrl_mktree(12);
+ libsrl_collect();
+ }
+ for (i = 0; i < sizeof(struct treenode); ++i) {
+ if (staticroot[i] != 0x42)
+ return -1;
+ }
+ for (i = 0; i < 10; ++i) {
+ root[i] = libsrl_mktree(12);
+ libsrl_collect();
+ }
+ for (i = 0; i < sizeof(struct treenode); ++i) {
+ if (staticroot[i] != 0x42)
+ return -1;
+ }
+ return 0;
+}
--- /dev/null
+load_lib "standard.exp"
--- /dev/null
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+proc load_gcc_lib { filename } {
+ global srcdir loaded_libs
+ load_file $srcdir/../../gcc/testsuite/lib/$filename
+ set loaded_libs($filename) ""
+}
+
+load_lib dg.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+# Required by target-supports-dg.exp.
+load_gcc_lib target-supports.exp
+# For dg-skip-if.
+load_gcc_lib target-supports-dg.exp
+# For ${tool}_exit.
+load_gcc_lib gcc-defs.exp
+# For prune_gcc_output.
+load_gcc_lib prune.exp
+
+set dg-do-what-default run
+
+# Define boehm-gc callbacks for dg.exp.
+
+# FIXME: The next two are independent of boehm-gc; move to some library.
+proc ${tool}-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+ # Set up the compiler flags, based on what we're going to do.
+
+ set options [list]
+ switch $do_what {
+ "compile" {
+ set compile_type "assembly"
+ set output_file "[file rootname [file tail $prog]].s"
+ }
+ "assemble" {
+ set compile_type "object"
+ set output_file "[file rootname [file tail $prog]].o"
+ }
+ "ltassemble" {
+ # Needs to be different from assemble since we cannot determine
+ # from $prog whether to produce a regular or a libtool object.
+ set compile_type "object"
+ set output_file "[file rootname [file tail $prog]].lo"
+ }
+ "link" {
+ set compile_type "executable"
+ # Don't add .exe extension, libtool may strip if from output file.
+ set output_file "[file rootname [file tail $prog]]"
+ # If we're linking a libtool object, produce a libtool library.
+ if { [file extension $prog] == ".lo" } {
+ set output_file "lib$output_file.la"
+ }
+ }
+ "run" {
+ set compile_type "executable"
+ # FIXME: "./" is to cope with "." not being in $PATH.
+ # Should this be handled elsewhere?
+ # YES.
+ set output_file "./[file rootname [file tail $prog]]"
+ # This is the only place where we care if an executable was
+ # created or not. If it was, dg.exp will try to run it.
+ remote_file build delete $output_file
+ }
+ default {
+ perror "$do_what: not a valid dg-do keyword"
+ return ""
+ }
+ }
+
+ if { $extra_tool_flags != "" } {
+ lappend options "additional_flags=$extra_tool_flags"
+ }
+
+ set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options];
+
+ return [list $comp_output $output_file]
+}
+
+proc ${tool}-dg-test { prog do_what extra_tool_flags } {
+ global tool
+
+ return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc boehm-gc-init { args } {
+ global gluefile wrap_flags
+ global srcdir
+ global blddirgc
+ global TOOL_EXECUTABLE
+ global GCC_UNDER_TEST
+ global objdir
+ global gc_include
+ global gc_lib
+ global gc_lib_conv
+ global tool
+ global tool_root_dir
+ global ld_library_path
+
+ set blddirgc [lookfor_file [get_multilibs] ${tool}]
+ verbose "blddirgc: $blddirgc"
+
+ if ![info exists GCC_UNDER_TEST] then {
+ if [info exists TOOL_EXECUTABLE] {
+ set GCC_UNDER_TEST $TOOL_EXECUTABLE
+ } else {
+ set GCC_UNDER_TEST "[find_gcc]"
+ }
+ }
+
+ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+ if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+ }
+ verbose "gccdir: $gccdir"
+
+ set ld_library_path "."
+ append ld_library_path ":${gccdir}"
+
+ set compiler "${gccdir}/xgcc"
+ if { [is_remote host] == 0 && [which $compiler] != 0 } {
+ foreach i "[exec $compiler --print-multi-lib]" {
+ set mldir ""
+ regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+ set mldir [string trimright $mldir "\;@"]
+ if { "$mldir" == "." } {
+ continue
+ }
+ if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+ append ld_library_path ":${gccdir}/${mldir}"
+ }
+ }
+ }
+ # Add the library path for boehm-gc.
+ append ld_library_path ":${blddirgc}/.libs"
+
+ # Add the library path for boehm-gc.lib libtool libraries.
+ append ld_library_path ":.libs"
+
+ verbose "ld_library_path: $ld_library_path"
+
+ # Point to the headers in boehm-gc.
+ set gc_include "${blddirgc}/include"
+ verbose "gc_include: $gc_include"
+
+ set gc_lib "${blddirgc}/libgcjgc.la"
+ verbose "gc_lib: $gc_lib"
+
+ set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
+ verbose "gc_lib_conv: $gc_lib_conv"
+
+ set_ld_library_path_env_vars
+ boehm-gc_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc boehm-gc_target_compile { source dest type options } {
+ global gluefile wrap_flags;
+ global srcdir
+ global TOOL_OPTIONS
+ global GCC_UNDER_TEST
+ global libtool
+ global gc_include
+ global gc_lib
+ global gc_lib_conv
+ global threadcflags
+ global threadlibs
+ global extra_test_libs
+
+ if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
+ lappend options "libs=${gluefile}"
+ lappend options "ldflags=$wrap_flags"
+ }
+
+ # TOOL_OPTIONS must come first, so that it doesn't override testcase
+ # specific options.
+ if [info exists TOOL_OPTIONS] {
+ lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
+ }
+
+ # Map type to libtool mode.
+ switch $type {
+ "object" {
+ set mode "compile"
+ }
+ "executable" {
+ set mode "link"
+ }
+ default {
+ perror "$type: unhandled type"
+ return ""
+ }
+ }
+
+ # Set this once for reuse in boehm-gc.lib/lib.exp.
+ set libtool "../libtool"
+ # We have to run silently to avoid DejaGnu lossage.
+ lappend options "compiler=$libtool --silent --tag=CC --mode=$mode \
+ $GCC_UNDER_TEST"
+
+ lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include"
+ lappend options "additional_flags=${threadcflags}"
+
+ lappend options "libs=-Wc,-shared-libgcc"
+
+ if { [file extension $dest] == ".la" } {
+ lappend options "libs=${gc_lib_conv}"
+ } else {
+ lappend options "libs=${gc_lib}"
+ }
+ lappend options "libs=${threadlibs} ${extra_test_libs}"
+
+ verbose "options: $options"
+ return [target_compile $source $dest $type $options]
+}
+
+# Prune harmless messages.
+proc boehm-gc-dg-prune { system text } {
+ # Prune the same messages as the gcc testsuite does.
+ set text [prune_gcc_output $text]
+
+ # Ignore harmless Darwin ranlib warnings.
+ regsub -all "(^|\n)(ranlib: file: \[^\n\]* has no symbols\n?)+" $text "\\1" text
+
+ return $text
+}
+
+# Build shared library from LIB.
+proc boehm-gc-build-shlib { lib flags extra-flags } {
+ global subdir
+ global dg-do-what-default
+ global libtool
+ global gc_lib_conv
+
+ # Determine basename.
+ set basename "[file rootname [file tail $lib]]"
+ verbose "basename: $basename"
+
+ # DejaGnu 1.4.4 doesn't support nested calls to dg-test. Restore
+ # original state before calling it again.
+ if { [info procs dg-save-unknown] != [list] } {
+ rename unknown ""
+ rename dg-save-unknown unknown
+ }
+
+ set saved-dg-do-what ${dg-do-what-default}
+
+ # Compile $lib into libtool object.
+ set dg-do-what-default ltassemble
+ dg-test -keep-output $lib $flags ${extra-flags}
+
+ # FIXME: Explain options.
+ set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
+
+ # There's no way to get output_file out of dg-test, only
+ # ${tool}-dg-test returns it, so hardcode that here.
+ set dg-do-what-default link
+ dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt"
+
+ set dg-do-what-default ${saved-dg-do-what}
+
+ # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test expects them.
+ if { [info procs dg-save-unknown] == [list] } {
+ rename unknown dg-save-unknown
+ proc unknown {} {
+ }
+ }
+
+ remote_exec host $libtool "--mode=clean rm -f $basename.lo"
+
+ return lib$basename.la
+}
+
+# Handle dg-add-shlib.
+proc dg-add-shlib { args } {
+ global tool
+ global srcdir subdir
+ global shlib
+
+ if { [llength $args] > 2 } {
+ error "[lindex $args 0]: too many arguments"
+ return
+ }
+
+ set lib [lindex $args 1]
+ set lib "$srcdir/$subdir/$lib"
+ verbose -log "dg-add-shlib $lib"
+
+ upvar tool_flags flags
+ upvar default_extra_tool_flags extra-flags
+ # Build support library.
+ set shlib [boehm-gc-build-shlib $lib $flags ${extra-flags}]
+
+ uplevel lappend tool_flags $shlib
+}
+
+# Run boehm-gc testcases.
+proc boehm-gc-dg-runtest { testcases flags extra-flags } {
+ global runtests
+ global libtool
+ global shlib
+
+ set shlib ""
+
+ foreach testcase $testcases {
+ # If we're only testing specific files and this isn't one of them,
+ # skip it.
+ if ![runtest_file_p $runtests $testcase] {
+ return
+ }
+
+ # Run testcase.
+ # Keep output, otherwise libtool below won't remove the corresponding
+ # file in .libs.
+ dg-test -keep-output $testcase $flags ${extra-flags}
+
+ # Remove $execname and eventually $shlib.
+ remote_exec host $libtool "--mode=clean rm -f \
+ [file rootname [file tail $testcase]] $shlib"
+ }
+}