summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xConfigure46
-rw-r--r--config_h.SH6
-rw-r--r--perl.h25
-rw-r--r--thread.h62
4 files changed, 117 insertions, 22 deletions
diff --git a/Configure b/Configure
index 175536cd6d..3bedfdfc3b 100755
--- 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 Thu Oct 22 10:24:53 EET DST 1998 [metaconfig 3.0 PL70]
+# Generated on Tue Oct 27 09:57:04 EET 1998 [metaconfig 3.0 PL70]
# (with additional metaconfig patches by jhi@iki.fi)
cat >/tmp/c1$$ <<EOF
@@ -558,6 +558,7 @@ d_int64t=''
i_inttypes=''
i_limits=''
i_locale=''
+i_machcthr=''
i_malloc=''
i_math=''
i_memory=''
@@ -7827,8 +7828,21 @@ set inet_aton d_inetaton
eval $inlibc
: see if inttypes.h is available
-set inttypes.h i_inttypes
-eval $inhdr
+: we want a real compile instead of Inhdr because some systems
+: have an inttypes.h which includes non-existent headers
+$cat >try.c <<EOCP
+#include <inttypes.h>
+extern int foo;
+EOCP
+set try
+if eval $compile; then
+ val="$define"
+else
+ val="$undef"
+fi
+set i_inttypes
+eval $setvar
+
: check for int64_t
case "$use64bits" in
"$define" )
@@ -8239,6 +8253,13 @@ if test "X$usethreads" = "X$define"; then
echo $n "Checking whether pthreads are created joinable. $c" >&4
$cat >try.c <<'EOCP'
#include <pthread.h>
+#ifdef PTHREAD_CREATE_UNDETACHED
+# define ATTR_JOINABLE PTHREAD_CREATE_UNDETACHED
+#else
+# ifdef __UNDETACHED
+# define ATTR_JOINABLE __UNDETACHED
+# endif
+#endif
#include <stdio.h>
int main() {
pthread_attr_t attr;
@@ -8246,12 +8267,12 @@ int main() {
printf("%s\n",
pthread_attr_init(&attr) == 0 &&
#if PTHREAD_ATTR_GETDETACHSTATE_INT
- pthread_attr_getdetachstate(&attr) == 0 &&
+ pthread_attr_getdetachstate(&attr) == ATTR_JOINABLE &&
#else
pthread_attr_getdetachstate(&attr, &detachstate) == 0 &&
+ detachstate == PTHREAD_ATTR_JOINABLE
#endif
- detachstate == PTHREAD_CREATE_DETACHED ?
- "detached" : "joinable");
+ ? "detached" : "joinable");
exit(0);
}
EOCP
@@ -8846,9 +8867,9 @@ END
eval $setvar
case "$d_semctl_semid_ds" in
$define)
- echo "You can $also use struct semid_ds * for semctl IPC_STAT." >&4
+ echo "You can $also use struct semid_ds* for semctl IPC_STAT." >&4
;;
- *) echo "You cannot use struct semid_ds * for semctl IPC_STAT." >&4
+ *) echo "You cannot use struct semid_ds* for semctl IPC_STAT." >&4
;;
esac
$rm -f try.h
@@ -10864,7 +10885,9 @@ EOM
: The first arg can be int, unsigned, or size_t
: The last arg may or may not be 'const'
val=''
- for xxx in 'fd_set *' 'int *' 'void *'; do
+ : void pointer has been seen but using that
+ : breaks the selectminbits test
+ for xxx in 'fd_set *' 'int *'; do
for nfd in 'int' 'size_t' 'unsigned long' 'unsigned' ; do
for tmo in 'struct timeval *' 'const struct timeval *'; do
case "$val" in
@@ -11410,6 +11433,10 @@ eval $setvar
set locale.h i_locale
eval $inhdr
+: see if mach cthreads are available
+set mach/cthreads.h i_machcthr
+eval $inhdr
+
: see if this is a math.h system
set math.h i_math
eval $inhdr
@@ -12486,6 +12513,7 @@ i_grp='$i_grp'
i_inttypes='$i_inttypes'
i_limits='$i_limits'
i_locale='$i_locale'
+i_machcthr='$i_machcthr'
i_malloc='$i_malloc'
i_math='$i_math'
i_memory='$i_memory'
diff --git a/config_h.SH b/config_h.SH
index 264c54db09..76ac7626ad 100644
--- a/config_h.SH
+++ b/config_h.SH
@@ -2292,6 +2292,12 @@ sed <<!GROK!THIS! >config.h -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un-
*/
#$d_pthreads_created_joinable PTHREADS_CREATED_JOINABLE /**/
+/* I_MACH_CTHREADS:
+ * This symbol, if defined, indicates to the C program that it should
+ * include <mach/cthreads.h>.
+ */
+#$i_machcthr I_MACH_CTHREADS /**/
+
/* MULTIPLICITY:
* This symbol, if defined, indicates that Perl should
* be built to use multiplicity.
diff --git a/perl.h b/perl.h
index 7e9fd94ceb..1561884b78 100644
--- a/perl.h
+++ b/perl.h
@@ -309,12 +309,6 @@ register struct op *op asm(stringify(OP_IN_REGISTER));
# include <pthread.h>
#endif
-/* HP-UX 10.X CMA (Common Multithreaded Architecure) insists that
- pthread.h must be included before all other header files.
-*/
-#if defined(USE_THREADS) && defined(PTHREAD_H_FIRST)
-# include <pthread.h>
-#endif
#ifndef _TYPES_ /* If types.h defines this it's easy. */
# ifndef major /* Does everyone's types.h define this? */
# include <sys/types.h>
@@ -1381,17 +1375,22 @@ typedef I32 (*filter_t) _((int, SV *, int));
# ifdef OS2
# include "os2thread.h"
# else
-# include <pthread.h>
-typedef pthread_t perl_os_thread;
-typedef pthread_mutex_t perl_mutex;
-typedef pthread_cond_t perl_cond;
-typedef pthread_key_t perl_key;
+# ifdef I_MACH_CTHREADS
+typedef cthread_t perl_os_thread;
+typedef mutex_t perl_mutex;
+typedef condition_t perl_cond;
+typedef void * perl_key;
+# else /* Posix threads */
+# include <pthread.h>
+typedef pthread_t perl_os_thread;
+typedef pthread_mutex_t perl_mutex;
+typedef pthread_cond_t perl_cond;
+typedef pthread_key_t perl_key;
+# endif /* I_MACH_CTHREADS */
# endif /* OS2 */
# endif /* WIN32 */
# endif /* FAKE_THREADS */
#endif /* USE_THREADS */
-
-
#ifdef VMS
# define STATUS_NATIVE PL_statusvalue_vms
diff --git a/thread.h b/thread.h
index 4d2c7dd43c..9e607e0c00 100644
--- a/thread.h
+++ b/thread.h
@@ -50,6 +50,68 @@ struct perl_thread *getTHR _((void));
# define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,s)
#endif
+#ifdef I_MACH_CTHREADS
+
+/* cthreads interface */
+
+/* #include <mach/cthreads.h> is in perl.h #ifdef I_MACH_CTHREADS */
+
+#define MUTEX_INIT(m) \
+ STMT_START { \
+ *m = mutex_alloc(); \
+ if (*m) { \
+ mutex_init(*m); \
+ } else { \
+ croak("panic: MUTEX_INIT"); \
+ } \
+ } STMT_END
+
+#define MUTEX_LOCK(m) mutex_lock(*m)
+#define MUTEX_UNLOCK(m) mutex_unlock(*m)
+#define MUTEX_DESTROY(m) \
+ STMT_START { \
+ mutex_free(*m); \
+ *m = 0; \
+ } STMT_END
+
+#define COND_INIT(c) \
+ STMT_START { \
+ *c = condition_alloc(); \
+ if (*c) { \
+ condition_init(*c); \
+ } else { \
+ croak("panic: COND_INIT"); \
+ } \
+ } STMT_END
+
+#define COND_SIGNAL(c) condition_signal(*c)
+#define COND_BROADCAST(c) condition_broadcast(*c)
+#define COND_WAIT(c, m) condition_wait(*c, *m)
+#define COND_DESTROY(c) \
+ STMT_START { \
+ condition_free(*c); \
+ *c = 0; \
+ } STMT_END
+
+#define THREAD_CREATE(thr, f) (thr->self = cthread_fork(f, thr), 0)
+#define THREAD_POST_CREATE(thr)
+
+#define THREAD_RET_TYPE any_t
+#define THREAD_RET_CAST(x) ((any_t) x)
+
+#define DETACH(t) cthread_detach(t->self)
+#define JOIN(t, avp) (*(avp) = (AV *)cthread_join(t->self))
+
+#define SET_THR(thr) cthread_set_data(cthread_self(), thr)
+#define THR cthread_data(cthread_self())
+
+#define INIT_THREADS cthread_init()
+#define YIELD cthread_yield()
+#define ALLOC_THREAD_KEY
+#define SET_THREAD_SELF(thr) (thr->self = cthread_self())
+
+#endif /* I_MACH_CTHREADS */
+
#ifndef YIELD
# ifdef SCHED_YIELD
# define YIELD SCHED_YIELD