Update todo with POSIX 1003.1 1996 Edition reminder.
[p5sagit/p5-mst-13.2.git] / thread.h
index 1312b30..695f288 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -50,6 +50,14 @@ struct perl_thread *getTHR _((void));
 #  define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,s)
 #endif
 
+#ifndef PTHREAD_CREATE_JOINABLE
+#  ifdef OLD_PTHREAD_CREATE_JOINABLE
+#    define PTHREAD_CREATE_JOINABLE OLD_PTHREAD_CREATE_JOINABLE
+#  else
+#    define PTHREAD_CREATE_JOINABLE 0 /* Panic?  No, guess. */
+#  endif
+#endif
+
 #ifdef I_MACH_CTHREADS
 
 /* cthreads interface */
@@ -216,6 +224,8 @@ struct perl_thread *getTHR _((void));
  * from thrsv which is cached in the per-interpreter structure.
  * Systems with very fast pthread_get_specific (which should be all systems
  * but unfortunately isn't) may wish to simplify to "...*thr = THR".
+ *
+ * The use of PL_threadnum should be safe here.
  */
 #ifndef dTHR
 #  define dTHR \
@@ -238,30 +248,27 @@ struct perl_thread *getTHR _((void));
  * try only locking them if there may be more than one thread in existence.
  * Systems with very fast mutexes (and/or slow conditionals) may wish to
  * remove the "if (threadnum) ..." test.
+ * XXX do NOT use C<if (PL_threadnum) ...> -- it sets up race conditions!
  */
 #define LOCK_SV_MUTEX                          \
     STMT_START {                               \
-       if (PL_threadnum)                       \
-           MUTEX_LOCK(&PL_sv_mutex);           \
+       MUTEX_LOCK(&PL_sv_mutex);               \
     } STMT_END
 
 #define UNLOCK_SV_MUTEX                                \
     STMT_START {                               \
-       if (PL_threadnum)                       \
-           MUTEX_UNLOCK(&PL_sv_mutex);         \
+       MUTEX_UNLOCK(&PL_sv_mutex);             \
     } STMT_END
 
 /* Likewise for strtab_mutex */
 #define LOCK_STRTAB_MUTEX                      \
     STMT_START {                               \
-       if (PL_threadnum)                       \
-           MUTEX_LOCK(&PL_strtab_mutex);       \
+       MUTEX_LOCK(&PL_strtab_mutex);           \
     } STMT_END
 
 #define UNLOCK_STRTAB_MUTEX                    \
     STMT_START {                               \
-       if (PL_threadnum)                       \
-           MUTEX_UNLOCK(&PL_strtab_mutex);     \
+       MUTEX_UNLOCK(&PL_strtab_mutex);         \
     } STMT_END
 
 #ifndef THREAD_RET_TYPE