$NetBSD: patch-ak,v 1.11 2014/11/30 08:40:51 spz Exp $
--- libgc/pthread_support.c.orig	2014-09-22 13:23:05.000000000 +0000
+++ libgc/pthread_support.c
@@ -71,7 +71,7 @@
       defined(GC_DARWIN_THREADS) || defined(GC_AIX_THREADS)) || \
       defined(GC_NETBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
       defined(GC_FREEBSD_THREADS) && !defined(USE_PTHREAD_SPECIFIC) || \
-      defined(GC_OPENBSD_THREADS)
+      !defined(USE_COMPILER_TLS) || defined(GC_OPENBSD_THREADS)
 #   define USE_PTHREAD_SPECIFIC
 # endif
 #endif
@@ -1282,6 +1282,22 @@ void GC_end_blocking(void) {
 #define __d10_sleep sleep
 #endif /* GC_DGUX386_THREADS */
 
+#undef nanosleep
+#undef usleep
+#undef sleep
+
+/* A wrapper for the standard C nanosleep function     */
+int WRAP_FUNC(nanosleep) (const struct timespec *rqtp, struct timespec *rmtp)
+{
+    int result;
+
+    GC_start_blocking();
+    result = REAL_FUNC(nanosleep)(rqtp, rmtp);
+    GC_end_blocking();
+
+    return result;
+}
+
 /* A wrapper for the standard C sleep function	*/
 int WRAP_FUNC(sleep) (unsigned int seconds)
 {
