This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [PATCH MANIFEST, lib/ExtUtils/testlib.t] More Tests
[perl5.git] / thread.h
index 1923aed..309d388 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -1,8 +1,15 @@
-#if defined(USE_THREADS) || defined(USE_ITHREADS)
+#if defined(USE_5005THREADS) || defined(USE_ITHREADS)
+
+#if defined(VMS)
+#include <builtins.h>
+#endif
 
 #ifdef WIN32
 #  include <win32thread.h>
 #else
+#ifdef NETWARE
+#  include <nw5thread.h>
+#else
 #  ifdef OLD_PTHREADS_API /* Here be dragons. */
 #    define DETACH(t) \
     STMT_START {                                               \
@@ -35,6 +42,7 @@
 #    if defined(__hpux) && defined(__ux_version) && __ux_version <= 1020
 #      define pthread_attr_init(a) pthread_attr_create(a)
        /* XXX pthread_setdetach_np() missing in DCE threads on HP-UX 10.20 */
+#      define PTHREAD_ATTR_SETDETACHSTATE(a,s) (0)
 #      define PTHREAD_CREATE(t,a,s,d) pthread_create(t,a,s,d)
 #      define pthread_key_create(k,d) pthread_keycreate(k,(pthread_destructor_t)(d))
 #      define pthread_mutexattr_init(a) pthread_mutexattr_create(a)
@@ -49,6 +57,7 @@
 #    define pthread_mutexattr_default NULL
 #    define pthread_condattr_default  NULL
 #  endif
+#endif /* NETWARE */
 #endif
 
 #ifndef PTHREAD_CREATE
 #  endif
 #endif
 
+#ifdef DGUX
+#  define THREAD_CREATE_NEEDS_STACK (16*1024)
+#endif
+
 #ifdef I_MACH_CTHREADS
 
 /* cthreads interface */
     } 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
-#  define PERL_GET_CONTEXT     pthread_getspecific(PL_thr_key)
+#  define PERL_GET_CONTEXT     PTHREAD_GETSPECIFIC(PL_thr_key)
 #endif
 
 #ifndef PERL_SET_CONTEXT
     } STMT_END
 #endif
 
+#ifndef PTHREAD_ATFORK
+#  ifdef HAS_PTHREAD_ATFORK
+#    define PTHREAD_ATFORK(prepare,parent,child)               \
+       pthread_atfork(prepare,parent,child)
+#  else
+#    define PTHREAD_ATFORK(prepare,parent,child)               \
+       NOOP
+#  endif
+#endif
+
 #ifndef THREAD_RET_TYPE
 #  define THREAD_RET_TYPE      void *
 #  define THREAD_RET_CAST(p)   ((void *)(p))
 #endif /* THREAD_RET */
 
-#if defined(USE_THREADS)
+#if defined(USE_5005THREADS)
 
 /* Accessor for per-thread SVs */
 #  define THREADSV(i) (thr->threadsvp[i])
@@ -334,8 +371,8 @@ typedef struct condpair {
 #define MgCONDP(mg) (&((condpair_t *)(mg->mg_ptr))->cond)
 #define MgOWNER(mg) ((condpair_t *)(mg->mg_ptr))->owner
 
-#endif /* USE_THREADS */
-#endif /* USE_THREADS || USE_ITHREADS */
+#endif /* USE_5005THREADS */
+#endif /* USE_5005THREADS || USE_ITHREADS */
 
 #ifndef MUTEX_LOCK
 #  define MUTEX_LOCK(m)