Replace ATTR_JOINABLE with true Configure probe
Jarkko Hietaniemi [Mon, 2 Nov 1998 12:03:08 +0000 (12:03 +0000)]
for PTHREAD_CREATE_JOINABLE (or equivalent:
PTHREAD_CREATE_UNDETACHED or __UNDETACHED).
Remove ATTR_JOINABLE itself: Thread.xs uses
PTHREAD_CREATE_JOINABLE (or equivalent) directly.

Really scan for <mach/cthreads.h> only if usethreads.

p4raw-id: //depot/cfgperl@2181

Configure
config_h.SH
ext/Thread/Thread.xs
thread.h

index f0c31da..d6e9555 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -20,7 +20,7 @@
 
 # $Id: Head.U,v 3.0.1.9 1997/02/28 15:02:09 ram Exp $
 #
-# Generated on Wed Oct 28 11:58:44 EET 1998 [metaconfig 3.0 PL70]
+# Generated on Mon Nov  2 13:57:54 EET 1998 [metaconfig 3.0 PL70]
 # (with additional metaconfig patches by jhi@iki.fi)
 
 cat >/tmp/c1$$ <<EOF
@@ -409,6 +409,8 @@ d_pause=''
 d_pipe=''
 d_poll=''
 d_portable=''
+d_pthread_create_joinable=''
+pthread_create_joinable=''
 d_pthread_yield=''
 d_sched_yield=''
 sched_yield=''
@@ -8176,6 +8178,62 @@ eval $inlibc
 set poll d_poll
 eval $inlibc
 
+: how to create joinable pthreads
+if test "X$usethreads" = "X$define"; then
+       echo " "
+       echo "Checking what constant to use for creating joinable pthreads..." >&4 
+       $cat >try.c <<'EOCP'
+#include <pthread.h>
+int main() {
+    int detachstate = JOINABLE;
+}
+EOCP
+       set try -DJOINABLE=PTHREAD_CREATE_JOINABLE
+       if eval $compile; then
+               echo "You seem to use PTHREAD_CREATE_JOINABLE." >&2
+               val="$undef"
+               set d_pthread_create_joinable
+               eval $setvar
+               val=0
+               set pthread_create_joinable
+               eval $setvar
+       else
+               set try -DJOINABLE=PTHREAD_CREATE_UNDETACHED
+               if eval $compile; then
+                       echo "You seem to use PTHREAD_CREATE_UNDETACHED." >&2
+                       val="$define"
+                       set d_pthread_create_joinable
+                       eval $setvar
+                       val=PTHREAD_CREATE_UNDETACHED
+                       set pthread_create_joinable
+                       eval $setvar
+               else            
+                       set try -DJOINABLE=__UNDETACHED
+                       if eval $compile; then
+                               echo "You seem to use __UNDETACHED." >&2
+                               val="$define"
+                               set d_pthread_create_joinable
+                               eval $setvar
+                               val=__UNDETACHED
+                               set pthread_create_joinable
+                               eval $setvar
+                       else
+                               echo "Egads, nothing obvious found.  Guessing that you use 0." >&2
+                               val="$define"
+                               set d_pthread_create_joinable
+                               eval $setvar
+                               val=0
+                               set pthread_create_joinable
+                               eval $setvar
+                       fi
+               fi
+       fi
+       $rm -f try try.*
+else
+    d_pthread_create_joinable="$undef"
+    pthread_create_joinable=0
+fi
+
 
 : see whether the various POSIXish _yields exist
 $cat >try.c <<EOP
@@ -11382,8 +11440,14 @@ set locale.h i_locale
 eval $inhdr
 
 : see if mach cthreads are available
-set mach/cthreads.h i_machcthr
-eval $inhdr
+if test "X$usethreads" = "X$define"; then
+       set mach/cthreads.h i_machcthr
+       eval $inhdr
+else
+       i_machcthr="$undef"
+fi
+
+
 
 : see if this is a math.h system
 set math.h i_math
@@ -12299,6 +12363,7 @@ d_phostname='$d_phostname'
 d_pipe='$d_pipe'
 d_poll='$d_poll'
 d_portable='$d_portable'
+d_pthread_create_joinable='$d_pthread_create_joinable'
 d_pthread_yield='$d_pthread_yield'
 d_pwage='$d_pwage'
 d_pwchange='$d_pwchange'
@@ -12604,6 +12669,7 @@ prefixexp='$prefixexp'
 privlib='$privlib'
 privlibexp='$privlibexp'
 prototype='$prototype'
+pthread_create_joinable='$pthread_create_joinable'
 ptrsize='$ptrsize'
 randbits='$randbits'
 randfunc='$randfunc'
index bfdb62a..878fd1b 100644 (file)
@@ -2267,6 +2267,15 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un-
  */
 #define ARCHNAME "$archname"           /**/
 
+/* PTHREAD_CREATE_JOINABLE:
+ *     This symbol, if defined, indicates how to create pthread
+ *     in joinable (aka undetached) state.  Not defined here if
+ *     pthread.h already has defined PTHREAD_CREATE_JOINABLE.
+ *     If defined, possible values are PTHREAD_CREATE_UNDETACHED
+ *     and __UNDETACHED.
+ */
+#$d_pthread_create_joinable PTHREAD_CREATE_JOINABLE $pthread_create_joinable /**/
+
 /* HAS_PTHREAD_YIELD:
  *     This symbol, if defined, indicates that the pthread_yield 
  *     routine is available to yield the execution of the current
index 208daf2..fb9aba9 100644 (file)
@@ -229,7 +229,7 @@ newthread (SV *startsv, AV *initargs, char *classname)
     static pthread_attr_t attr;
     static int attr_inited = 0;
     sigset_t fullmask, oldmask;
-    static int attr_joinable = ATTR_JOINABLE;
+    static int attr_joinable = PTHREAD_CREATE_JOINABLE;
 #endif
 
     savethread = thr;
index 8e95b98..1312b30 100644 (file)
--- a/thread.h
+++ b/thread.h
@@ -128,16 +128,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 {                                               \