Back out change to h2xs till it passes its test.
[p5sagit/p5-mst-13.2.git] / thread.h
index 87e8974..a82c01b 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -7,6 +7,9 @@
 #ifdef WIN32
 #  include <win32thread.h>
 #else
+#ifdef NETWARE
+#  include <nw5thread.h>
+#else
 #  ifdef OLD_PTHREADS_API /* Here be dragons. */
 #    define DETACH(t) \
     STMT_START {                                               \
@@ -54,6 +57,7 @@
 #    define pthread_mutexattr_default NULL
 #    define pthread_condattr_default  NULL
 #  endif
+#endif /* NETWARE */
 #endif
 
 #ifndef PTHREAD_CREATE
     } STMT_END
 #endif /* JOIN */
 
+/* Use an unchecked fetch of thread-specific data instead of a checked one.
+ * It would fail if the key were bogus, but if the key were bogus then
+ * Really Bad Things would be happening anyway. --dan */
+#if (defined(__ALPHA) && (__VMS_VER >= 70000000)) || \
+    (defined(__alpha) && defined(__osf__)) /* Available only on >= 4.0 */
+#  define HAS_PTHREAD_UNCHECKED_GETSPECIFIC_NP /* Configure test needed */
+#endif
+
+#ifdef HAS_PTHREAD_UNCHECKED_GETSPECIFIC_NP
+#  define PTHREAD_GETSPECIFIC(key) pthread_unchecked_getspecific_np(key)
+#else
+#  define PTHREAD_GETSPECIFIC(key) pthread_getspecific(key)
+#endif
+
 #ifndef PERL_GET_CONTEXT
-/* True for Tru64 version 4.0 and up as well */
-#  if defined(__ALPHA) && (__VMS_VER >= 70000000)
-#    define PERL_GET_CONTEXT   pthread_unchecked_getspecific_np(PL_thr_key)
-#  else
-#    define PERL_GET_CONTEXT   pthread_getspecific(PL_thr_key)
-#  endif
+#  define PERL_GET_CONTEXT     PTHREAD_GETSPECIFIC(PL_thr_key)
 #endif
 
 #ifndef PERL_SET_CONTEXT
     } STMT_END
 #endif
 
+void Perl_atfork_lock(void);
+void Perl_atfork_unlock(void);
+
+#ifndef PTHREAD_ATFORK
+#  ifdef HAS_PTHREAD_ATFORK
+#    define PTHREAD_ATFORK(prepare,parent,child)               \
+       pthread_atfork(prepare,parent,child)
+#  else
+#    ifdef HAS_FORK
+#      define PTHREAD_ATFORK(prepare,parent,child)             \
+        Perl_croak(aTHX_ "No pthread_atfork() -- fork() too unsafe");
+#    else
+#      define PTHREAD_ATFORK(prepare,parent,child)             \
+        NOOP
+#    endif
+#  endif
+#endif
+
 #ifndef THREAD_RET_TYPE
 #  define THREAD_RET_TYPE      void *
 #  define THREAD_RET_CAST(p)   ((void *)(p))
@@ -443,3 +474,7 @@ typedef struct condpair {
 #ifndef INIT_THREADS
 #  define INIT_THREADS NOOP
 #endif
+
+#ifndef PTHREAD_ATFORK
+#  define PTHREAD_ATFORK(prepare,parent,child) NOOP
+#endif