[m-rev.] upgrade GC to v7.6.4

Peter Wang novalazy at gmail.com
Fri Feb 23 18:20:58 AEDT 2018


Hi,

I plan to upgrade the GC from v7.6.2 to v7.6.4 so that it builds on
OpenBSD. Other than that, the differences are minimal (see below).

I've rebased our changes on top of v7.6.4 and pushed a tag
release-7_6-mercury-20180223. I will also force update the
release-7_6-mercury branch for consistency, if there are no objections.
The branch serves no particular purpose.

Peter


diff --git a/.gitignore b/.gitignore
index 6404ebad..4e5c4ddf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,11 +42,15 @@ mercury_boehm_gc_conf.h
 /cord/de_win.res
 /cord/tests/de_win.rbj
 /cord/tests/de_win.res
+/cords
 /cordtest
 /core
 /de
 /disclaim_bench
 /disclaim_test
+/dont_ar_1
+/dont_ar_3
+/dont_ar_4
 /gc-*
 /gc.a
 /gc.log
diff --git a/.travis.yml b/.travis.yml
index 6fa66521..e406f7ec 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,6 @@ matrix:
       apt:
         packages:
         - libatomic-ops-dev
-    dist: trusty
     env:
     - MAKEFILE_TARGETS="distcheck"
     - AUTOMAKE_VER=1.15
@@ -35,7 +34,6 @@ matrix:
         packages:
         - libatomic-ops-dev
     compiler: clang
-    dist: trusty
     env:
     - CONF_OPTIONS="--enable-cplusplus"
     - NO_CLONE_LIBATOMIC_OPS=true
@@ -45,7 +43,6 @@ matrix:
         packages:
         - libatomic-ops-dev
     compiler: gcc
-    dist: trusty
     env:
     - CONF_OPTIONS="--enable-gc-assertions --enable-cplusplus"
     - NO_CLONE_LIBATOMIC_OPS=true
@@ -107,7 +104,6 @@ matrix:
         packages:
         - libatomic-ops-dev
     compiler: gcc
-    dist: trusty
     env:
     - CONF_OPTIONS="--with-libatomic-ops=yes --enable-gc-assertions --enable-cplusplus"
     - NO_CLONE_LIBATOMIC_OPS=true
@@ -140,7 +136,6 @@ matrix:
     - CONF_OPTIONS="--enable-cplusplus --disable-docs"
   - os: linux
     compiler: gcc
-    dist: trusty
     env:
     - CFLAGS_EXTRA="-std=c11 -D GC_NO_SIGSETJMP"
     - CONF_OPTIONS="--disable-threads --enable-gc-assertions --enable-cplusplus"
@@ -232,7 +227,6 @@ matrix:
         sources:
         - llvm-toolchain-trusty-4.0
     compiler: clang-4.0
-    dist: trusty
     language: c
     env:
     - CSA_CHECK=true
@@ -265,7 +259,6 @@ matrix:
         packages:
         - musl-tools
     compiler: musl-gcc
-    dist: trusty
     language: c
     env:
     - CONF_OPTIONS="--disable-parallel-mark --enable-gc-assertions"
@@ -277,13 +270,13 @@ matrix:
         sources:
         - llvm-toolchain-trusty-4.0
     compiler: clang-4.0
-    dist: trusty
     language: c
     env:
     - CXX=clang++-4.0
     - CFLAGS_EXTRA="-fsanitize=address -fno-common -fno-omit-frame-pointer"
     - CONF_OPTIONS="--enable-cplusplus"
     - TESTS_CUSTOM_RUN=true
+    sudo: required
   - os: linux
     addons:
       apt:
@@ -292,7 +285,6 @@ matrix:
         sources:
         - ubuntu-toolchain-r-test
     compiler: gcc-5
-    dist: trusty
     language: c
     env:
     - CFLAGS_EXTRA="-fsanitize=address -O0"
@@ -310,7 +302,6 @@ matrix:
         sources:
         - llvm-toolchain-trusty-4.0
     compiler: clang-4.0
-    dist: trusty
     language: c
     env:
     - CFLAGS_EXTRA="-fsanitize=memory -fno-omit-frame-pointer -D NO_INCREMENTAL"
@@ -331,7 +322,6 @@ matrix:
         sources:
         - llvm-toolchain-trusty-4.0
     compiler: clang-4.0
-    dist: trusty
     language: c
     env:
     - CXX=clang++-4.0
@@ -346,7 +336,6 @@ matrix:
         sources:
         - llvm-toolchain-trusty-4.0
     compiler: clang-4.0
-    dist: trusty
     language: c
     env:
     - CFLAGS_EXTRA="-m32 -D _FORTIFY_SOURCE=2 -D GC_DISABLE_INCREMENTAL"
@@ -360,7 +349,6 @@ matrix:
         sources:
         - ubuntu-toolchain-r-test
     compiler: gcc-5
-    dist: trusty
     language: c
     env:
     - CXX=g++-5
@@ -375,7 +363,6 @@ matrix:
         sources:
         - ubuntu-toolchain-r-test
     compiler: gcc-5
-    dist: trusty
     language: c
     env:
     - CFLAGS_EXTRA="-m32 -O3"
@@ -390,7 +377,6 @@ matrix:
         sources:
         - ubuntu-toolchain-r-test
     compiler: gcc-5
-    dist: trusty
     language: c
     env:
     - CFLAGS_EXTRA="-mx32 -march=native -D _FORTIFY_SOURCE=2 -D NO_INCREMENTAL"
@@ -402,7 +388,6 @@ matrix:
         - g++-mingw-w64
         - gcc-mingw-w64
     compiler: x86_64-w64-mingw32-gcc
-    dist: trusty
     language: c
     env:
     - CXX=x86_64-w64-mingw32-g++
@@ -414,7 +399,6 @@ matrix:
         packages:
         - gcc-mingw-w64
     compiler: i686-w64-mingw32-gcc
-    dist: trusty
     language: c
     env:
     - CONF_OPTIONS="--host=i686-w64-mingw32 --enable-munmap"
diff --git a/AUTHORS b/AUTHORS
index bc54ca5d..e500dc3d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -154,6 +154,7 @@ George Talbot <Gtalbot at ansarisbio.com>
 Gerard A Allan
 Glauco Masotti <glauco.masotti at libero.it>
 Grzegorz Jakacki <jakacki at acm.org>
+Gustavo Giraldez <ggiraldez at manas.com.ar>
 Gustavo Rodriguez-Rivera <grr at cs.purdue.edu>
 H.J. Lu <hjl.tools at gmail.com>
 Hamayama <hamay1010 at gmail.com>
diff --git a/ChangeLog b/ChangeLog
index 8c6b550c..59864d18 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,23 @@
 
+== [7.6.4] 2018-01-26 ==
+
+* Add note of set_free_space_divisor, set_warn_proc ABI change after gc-7.1
+* Change compiler invocation example in gc.man to use dynamic libgc
+* Delete dont_ar_* build intermediate files on make clean (Makefile.direct)
+* Do not declare dl_iterate_phdr as weak for DragonFly
+* Fix 'cords' parallel build in Makefile.direct
+* Fix 'undeclared identifier USRSTACK' compiler error on OpenBSD-6.2
+* Fix error code in abort message if sem_wait failed in start_world (NetBSD)
+* Fix GC allocation mutex in child after a fork
+* Fix global operator delete definition for C++14 in gc_cpp
+* Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old
+* Fix libgc version which was changed in linkage breaking way
+* Fix missing EOLn output in threadlibs tool
+* Fix threadlibs tool to output '-lpthread' for DragonFly
+* Prevent DATASTART redefinition for NaCl
+* Remove obsolete advice about linking with _DYNAMIC=0 (Linux)
+
+
 == [7.6.2] 2017-12-23 ==
 
 * Add assertion that no hb_n_marks underflow occurs
@@ -301,6 +320,12 @@ Also, includes 7.4.6 changes
 Also, includes 7.4.4 changes
 
 
+== [7.4.10] 2018-01-22 ==
+
+* Fix error code in abort message if sem_wait failed in start_world (NetBSD)
+Also, includes 7.2j changes
+
+
 == [7.4.8] 2017-12-22 ==
 
 * Eliminate 'this statement may fall through' GCC warnings
@@ -740,6 +765,14 @@ Also, includes 7.2e, 7.2d, 7.2c, 7.2b changes
 Also, includes 7.2 changes
 
 
+== [7.2j] 2018-01-21 ==
+
+* Fix GC allocation mutex in child after a fork
+* Fix last_reclaimed..gc_no interval comparison to threshold in unmap_old
+* Fix libgc version which was changed in linkage breaking way
+* Fix missing EOLn output in threadlibs tool
+
+
 == [7.2i] 2017-12-21 ==
 
 * Avoid data race in finalized_count (gctest)
diff --git a/Makefile.am b/Makefile.am
index 93401fe8..205af63d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,8 +14,8 @@
 # Info (current:revision:age) for the Libtool versioning system.
 # These numbers should be updated at most once just before the release,
 # and, optionally, at most once during the development (after the release).
-LIBGC_VER_INFO = 4:1:2
-LIBGCCPP_VER_INFO = 4:0:3
+LIBGC_VER_INFO = 4:2:3
+LIBGCCPP_VER_INFO = 4:1:3
 
 ## FIXME: `make distcheck' in this directory will not currently work.
 ##     This is most likely to the explicit flags passed to submakes.
diff --git a/Makefile.direct b/Makefile.direct
index fb3701ed..f2c603ec 100644
--- a/Makefile.direct
+++ b/Makefile.direct
@@ -325,6 +325,7 @@ cords: $(CORD_OBJS) cord/cordtest $(UTILS) base_lib
 	./if_mach M68K AMIGA $(AR) -vrus gc.a $(CORD_OBJS)
 	./if_not_there dont_ar_3 $(AR) ru gc.a $(CORD_OBJS)
 	./if_not_there dont_ar_3 $(RANLIB) gc.a || cat /dev/null
+	echo > cords
 
 gc_cpp.o: $(srcdir)/gc_cpp.cc $(srcdir)/include/gc_cpp.h $(srcdir)/include/gc.h
 	$(CXX) -c $(CXXFLAGS) $(srcdir)/gc_cpp.cc
@@ -494,7 +495,8 @@ if_not_there: $(srcdir)/tools/if_not_there.sh
 clean:
 	rm -f gc.a *.i *.o *.exe tests/*.o gctest gctest_dyn_link test_cpp \
 	      setjmp_test mon.out gmon.out a.out core if_not_there if_mach \
-	      base_lib c++ threadlibs $(CORD_OBJS) cord/cordtest cord/de
+	      base_lib c++ $(CORD_OBJS) cord/cordtest cord/de cords \
+	      dont_ar_* threadlibs
 	-rm -f *~
 
 gctest: tests/test.o base_lib $(UTILS)
diff --git a/README.md b/README.md
index 6eb32b61..67b6d5b5 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # Boehm-Demers-Weiser Garbage Collector
 
-This is version 7.6.2 of a conservative garbage
+This is version 7.6.4 of a conservative garbage
 collector for C and C++.
 
 
diff --git a/allchblk.c b/allchblk.c
index 90331dc8..b1c15bf0 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -408,7 +408,9 @@ GC_INNER void GC_unmap_old(void)
         hhdr = HDR(h);
         if (!IS_MAPPED(hhdr)) continue;
 
-        if ((unsigned short)GC_gc_no - hhdr -> hb_last_reclaimed >
+        /* Check that the interval is larger than the threshold (the    */
+        /* truncated counter value wrapping is handled correctly).      */
+        if ((unsigned short)(GC_gc_no - hhdr->hb_last_reclaimed) >
                 (unsigned short)GC_unmap_threshold) {
           GC_unmap((ptr_t)h, hhdr -> hb_sz);
           hhdr -> hb_flags |= WAS_UNMAPPED;
diff --git a/configure.ac b/configure.ac
index faadc1e0..da9cded0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@
 dnl Process this file with autoconf to produce configure.
 
 # Initialization
-AC_INIT(gc,7.6.2,https://github.com/ivmai/bdwgc/issues)
+AC_INIT(gc,7.6.4,https://github.com/ivmai/bdwgc/issues)
     ## version must conform to [0-9]+[.][0-9]+[.][0-9]+
 AC_CONFIG_SRCDIR(gcj_mlc.c)
 AC_CONFIG_MACRO_DIR([m4])
diff --git a/doc/README.linux b/doc/README.linux
index f490365c..bfa8b185 100644
--- a/doc/README.linux
+++ b/doc/README.linux
@@ -8,8 +8,7 @@ See below for M68K specific notes.
 
 Incremental GC is generally supported.
 
-Dynamic libraries are supported on an ELF system.  A static executable
-should be linked with the gcc option "-Wl,-defsym,_DYNAMIC=0".
+Dynamic libraries are supported on an ELF system.
 
 The collector appears to work reliably with Linux threads, but beware
 of older versions of glibc and gdb.
diff --git a/doc/gc.man b/doc/gc.man
index 201729f8..b5070d36 100644
--- a/doc/gc.man
+++ b/doc/gc.man
@@ -11,7 +11,7 @@ void GC_free(void *ptr);
 void * GC_realloc(void *ptr, size_t size);
 .br
 .sp
-cc ... gc.a
+cc ... -lgc
 .LP
 .SH DESCRIPTION
 .I GC_malloc
diff --git a/dyn_load.c b/dyn_load.c
index 8813e03b..0f36f777 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -426,7 +426,7 @@ GC_INNER GC_bool GC_register_main_static_data(void)
 # endif
 #endif /* __GLIBC__ >= 2 || PLATFORM_ANDROID */
 
-#if (defined(FREEBSD) && __FreeBSD__ >= 7)
+#if (defined(FREEBSD) && __FreeBSD__ >= 7) || defined(__DragonFly__)
   /* On the FreeBSD system, any target system at major version 7 shall   */
   /* have dl_iterate_phdr; therefore, we need not make it weak as below. */
 # ifndef HAVE_DL_ITERATE_PHDR
diff --git a/gc_cpp.cc b/gc_cpp.cc
index 185ec25a..103e66f8 100644
--- a/gc_cpp.cc
+++ b/gc_cpp.cc
@@ -63,4 +63,18 @@ built-in "new" and "delete".
     }
 # endif // GC_OPERATOR_NEW_ARRAY
 
+# if __cplusplus > 201103L // C++14
+    void operator delete(void* obj, size_t size) GC_DECL_DELETE_THROW {
+      (void)size; // size is ignored
+      GC_FREE(obj);
+    }
+
+#   if defined(GC_OPERATOR_NEW_ARRAY) && !defined(CPPCHECK)
+      void operator delete[](void* obj, size_t size) GC_DECL_DELETE_THROW {
+        (void)size;
+        GC_FREE(obj);
+      }
+#   endif
+# endif // C++14
+
 #endif // !_MSC_VER
diff --git a/include/gc.h b/include/gc.h
index 3d5bdaec..7bbab77d 100644
--- a/include/gc.h
+++ b/include/gc.h
@@ -329,6 +329,8 @@ GC_API GC_ATTR_DEPRECATED GC_word GC_free_space_divisor;
                         /* GC_call_with_alloc_lock() is required to     */
                         /* avoid data races (if the value is modified   */
                         /* after the GC is put to multi-threaded mode). */
+                        /* In version 7.1 (and before), the setter      */
+                        /* returned the old value.                      */
 GC_API void GC_CALL GC_set_free_space_divisor(GC_word);
 GC_API GC_word GC_CALL GC_get_free_space_divisor(void);
 
@@ -1305,7 +1307,8 @@ GC_API int GC_CALL GC_invoke_finalizers(void);
 /* GC_set_warn_proc can be used to redirect or filter warning messages. */
 /* p may not be a NULL pointer.  msg is printf format string (arg must  */
 /* match the format).  Both the setter and the getter acquire the GC    */
-/* lock (to avoid data races).                                          */
+/* lock (to avoid data races).  In version 7.1 (and before), the setter */
+/* returned the old warn_proc value.                                    */
 typedef void (GC_CALLBACK * GC_warn_proc)(char * /* msg */,
                                           GC_word /* arg */);
 GC_API void GC_CALL GC_set_warn_proc(GC_warn_proc /* p */) GC_ATTR_NONNULL(1);
diff --git a/include/gc_version.h b/include/gc_version.h
index 9d71b3cd..9e31cb84 100644
--- a/include/gc_version.h
+++ b/include/gc_version.h
@@ -30,7 +30,7 @@
 /* it to keep the old-style build process working.              */
 #define GC_TMP_VERSION_MAJOR 7
 #define GC_TMP_VERSION_MINOR 6
-#define GC_TMP_VERSION_MICRO 2 /* 7.6.2 */
+#define GC_TMP_VERSION_MICRO 4 /* 7.6.4 */
 
 #ifdef GC_VERSION_MAJOR
 # if GC_TMP_VERSION_MAJOR != GC_VERSION_MAJOR \
diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h
index bec8a681..ffbdc142 100644
--- a/include/private/gcconfig.h
+++ b/include/private/gcconfig.h
@@ -977,7 +977,13 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+        /* USRSTACK is defined in <machine/vmparam.h> but that is       */
+        /* protected by _KERNEL in <uvm/uvm_param.h> file.              */
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int __data_start[];
 #     define DATASTART ((ptr_t)__data_start)
@@ -1088,6 +1094,7 @@
 #   undef STACK_GRAN
 #   define STACK_GRAN 0x10000
 #   define HEURISTIC1
+#   define NO_PTHREAD_GETATTR_NP
 #   define USE_MMAP
 #   define USE_MUNMAP
 #   define USE_MMAP_ANON
@@ -1198,7 +1205,11 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int __data_start[];
 #     define DATASTART ((ptr_t)__data_start)
@@ -1345,24 +1356,6 @@
 #         define HEAP_START DATAEND
 #       endif
 #   endif /* DGUX */
-
-#   ifdef NACL
-#      define OS_TYPE "NACL"
-       extern int etext[];
-/* #define DATASTART ((ptr_t)((((word) (etext)) + 0xfff) & ~0xfff)) */
-#      define DATASTART ((ptr_t)0x10000000)
-       extern int _end[];
-#      define DATAEND ((ptr_t)_end)
-#      undef STACK_GRAN
-#      define STACK_GRAN 0x10000
-#      define HEURISTIC1
-#      define NO_PTHREAD_GETATTR_NP
-#      define GETPAGESIZE() 65536
-#      ifndef MAX_NACL_GC_THREADS
-#        define MAX_NACL_GC_THREADS 1024
-#      endif
-#   endif /* NACL */
-
 #   ifdef LINUX
 #       define OS_TYPE "LINUX"
 #       define LINUX_STACKBOTTOM
@@ -1484,7 +1477,11 @@
 #       ifndef GC_OPENBSD_THREADS
 #         include <sys/param.h>
 #         include <uvm/uvm_extern.h>
+#         ifdef USRSTACK
 #           define STACKBOTTOM ((ptr_t)USRSTACK)
+#         else
+#           define HEURISTIC2
+#         endif
 #       endif
         extern int __data_start[];
 #       define DATASTART ((ptr_t)__data_start)
@@ -1729,7 +1726,11 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int _fdata[];
 #     define DATASTART ((ptr_t)_fdata)
@@ -1857,7 +1858,11 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int __data_start[];
 #     define DATASTART ((ptr_t)__data_start)
@@ -1887,7 +1892,11 @@
 #       ifndef GC_OPENBSD_THREADS
 #         include <sys/param.h>
 #         include <uvm/uvm_extern.h>
+#         ifdef USRSTACK
 #           define STACKBOTTOM ((ptr_t)USRSTACK)
+#         else
+#           define HEURISTIC2
+#         endif
 #       endif
         extern int __data_start[];
 #       define DATASTART ((ptr_t)__data_start)
@@ -2289,7 +2298,11 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int __data_start[];
 #     define DATASTART ((ptr_t)__data_start)
@@ -2346,7 +2359,11 @@
 #     ifndef GC_OPENBSD_THREADS
 #       include <sys/param.h>
 #       include <uvm/uvm_extern.h>
+#       ifdef USRSTACK
 #         define STACKBOTTOM ((ptr_t)USRSTACK)
+#       else
+#         define HEURISTIC2
+#       endif
 #     endif
       extern int __data_start[];
 #     define DATASTART ((ptr_t)__data_start)
@@ -2410,7 +2427,11 @@
 #       ifndef GC_OPENBSD_THREADS
 #         include <sys/param.h>
 #         include <uvm/uvm_extern.h>
+#         ifdef USRSTACK
 #           define STACKBOTTOM ((ptr_t)USRSTACK)
+#         else
+#           define HEURISTIC2
+#         endif
 #       endif
         extern int __data_start[];
         extern int _end[];
diff --git a/pthread_stop_world.c b/pthread_stop_world.c
index ae03db37..c1afb5aa 100644
--- a/pthread_stop_world.c
+++ b/pthread_stop_world.c
@@ -1060,12 +1060,10 @@ GC_INNER void GC_start_world(void)
     }
 #   ifdef GC_NETBSD_THREADS_WORKAROUND
       for (i = 0; i < n_live_threads; i++) {
-        int code;
-
-        while (0 != (code = sem_wait(&GC_restart_ack_sem))) {
+        while (0 != sem_wait(&GC_restart_ack_sem)) {
           if (errno != EINTR) {
             ABORT_ARG1("sem_wait() for restart handler failed",
-                       ": errcode= %d", code);
+                       ": errcode= %d", errno);
           }
         }
       }
diff --git a/pthread_support.c b/pthread_support.c
index f9ccd9cb..335e6ebb 100644
--- a/pthread_support.c
+++ b/pthread_support.c
@@ -1084,6 +1084,26 @@ static void fork_child_proc(void)
 #   endif /* PARALLEL_MARK */
     RESTORE_CANCEL(fork_cancel_state);
     UNLOCK();
+    /* Even though after a fork the child only inherits the single      */
+    /* thread that called the fork(), if another thread in the parent   */
+    /* was attempting to lock the mutex while being held in             */
+    /* fork_child_prepare(), the mutex will be left in an inconsistent  */
+    /* state in the child after the UNLOCK.  This is the case, at       */
+    /* least, in Mac OS X and leads to an unusable GC in the child      */
+    /* which will block when attempting to perform any GC operation     */
+    /* that acquires the allocation mutex.                              */
+#   ifdef USE_PTHREAD_LOCKS
+      GC_ASSERT(I_DONT_HOLD_LOCK());
+      /* Reinitialize the mutex.  It should be safe since we are        */
+      /* running this in the child which only inherits a single thread. */
+      /* mutex_destroy() may return EBUSY, which makes no sense, but    */
+      /* that is the reason for the need of the reinitialization.       */
+      (void)pthread_mutex_destroy(&GC_allocate_ml);
+      /* TODO: Probably some targets might need the default mutex       */
+      /* attribute to be passed instead of NULL.                        */
+      if (0 != pthread_mutex_init(&GC_allocate_ml, NULL))
+        ABORT("pthread_mutex_init failed (in child)");
+#   endif
 }
 
   /* Routines for fork handling by client (no-op if pthread_atfork works). */
diff --git a/tools/threadlibs.c b/tools/threadlibs.c
index a97f91b8..bebca536 100644
--- a/tools/threadlibs.c
+++ b/tools/threadlibs.c
@@ -42,10 +42,10 @@ int main(void)
 #       ifdef GC_USE_DLOPEN_WRAP
           printf("-ldl ");
 #       endif
-#       if (__FREEBSD_version >= 500000)
-          printf("-lpthread\n");
-#       else
+#       if (__FREEBSD_version < 500000)
           printf("-pthread\n");
+#       else /* __FREEBSD__ || __DragonFly__ */
+          printf("-lpthread\n");
 #       endif
 #   endif
 #   if defined(GC_NETBSD_THREADS)
@@ -71,7 +71,7 @@ int main(void)
 #      endif
 #   endif
 #   if defined(GC_OSF1_THREADS)
-        printf("-pthread -lrt"); /* DOB: must be -pthread, not -lpthread */
+        printf("-pthread -lrt\n"); /* DOB: must be -pthread, not -lpthread */
 #   endif
     /* You need GCC 3.0.3 to build this one!            */
     /* DG/UX native gcc doesn't know what "-pthread" is */


More information about the reviews mailing list