slurping an empty file should return '' rather than undef, with
[p5sagit/p5-mst-13.2.git] / thread.h
index 8e95b98..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 */
@@ -128,16 +136,6 @@ struct perl_thread *getTHR _((void));
 #  endif
 #endif
 
-#if !defined(ATTR_JOINABLE) && defined(PTHREAD_CREATE_JOINABLE)
-#  define ATTR_JOINABLE PTHREAD_CREATE_JOINABLE
-#endif
-#if !defined(ATTR_JOINABLE) && defined(PTHREAD_CREATE_UNDETACHED)
-#  define ATTR_JOINABLE PTHREAD_CREATE_UNDETACHED
-#endif
-#if !defined(ATTR_JOINABLE) && defined(__UNDETACHED)
-#  define ATTR_JOINABLE __UNDETACHED
-#endif
-
 #ifndef MUTEX_INIT
 #define MUTEX_INIT(m)                                          \
     STMT_START {                                               \
@@ -226,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 \
@@ -248,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