summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1998-10-20 15:01:20 +0000
committerJarkko Hietaniemi <jhi@iki.fi>1998-10-20 15:01:20 +0000
commit0d85d8777a6ec9fdcc93593180474ebff6fbbccb (patch)
treeb7a90ec24c4eeb104282c17fe156d049c6fbbf70
parentfe572743bdc94988ae47d8a129c5f974e72052a1 (diff)
downloadperl-0d85d8777a6ec9fdcc93593180474ebff6fbbccb.tar.gz
OLD_PTHREADS_API reorganizing.
p4raw-id: //depot/cfgperl@2028
-rw-r--r--dosish.h13
-rw-r--r--ext/Thread/Thread.xs36
-rw-r--r--thread.h61
-rw-r--r--util.c4
-rw-r--r--vmesa/vmesaish.h8
5 files changed, 52 insertions, 70 deletions
diff --git a/dosish.h b/dosish.h
index 1d52d0c0cd..589bd56cf8 100644
--- a/dosish.h
+++ b/dosish.h
@@ -16,20 +16,7 @@
# define NO_LOCALECONV_MON_THOUSANDS_SEP
# endif
# ifdef USE_THREADS
-# define NEED_PTHREAD_INIT
# define OLD_PTHREADS_API
-# define YIELD pthread_yield(NULL)
-# define DETACH(t) \
- STMT_START { \
- if (pthread_detach(&(t)->self)) { \
- MUTEX_UNLOCK(&(t)->mutex); \
- croak("panic: DETACH"); \
- } \
- } STMT_END
-# define pthread_mutexattr_default NULL
-# define pthread_condattr_default NULL
-# define pthread_addr_t any_t
-# define PTHREAD_CREATE_JOINABLE (&err)
# endif
#else /* DJGPP */
# ifdef WIN32
diff --git a/ext/Thread/Thread.xs b/ext/Thread/Thread.xs
index 84f9f57fc5..0c589a95ad 100644
--- a/ext/Thread/Thread.xs
+++ b/ext/Thread/Thread.xs
@@ -230,9 +230,7 @@ newthread (SV *startsv, AV *initargs, char *classname)
static int attr_inited = 0;
sigset_t fullmask, oldmask;
#endif
-#ifdef PTHREAD_SETDETACHSTATE_ARG2_POINTER
static int attr_joinable = ATTR_JOINABLE;
-#endif
savethread = thr;
thr = new_struct_thread(thr);
@@ -259,39 +257,17 @@ newthread (SV *startsv, AV *initargs, char *classname)
err = 0;
if (!attr_inited) {
attr_inited = 1;
-#ifdef OLD_PTHREADS_API
- err = pthread_attr_create(&attr);
-#else
err = pthread_attr_init(&attr);
-#endif
-#ifdef OLD_PTHREADS_API
-#ifdef VMS
-/* This is available with the old pthreads API, but only with */
-/* DecThreads (VMS and Digital Unix (which has and uses the new one)) */
- if (err == 0)
- err = pthread_attr_setdetach_np(&attr, ATTR_JOINABLE);
-#endif
-#else /* !defined(VMS) */
-#ifdef ATTR_JOINABLE
+# ifdef PTHREAD_ATTR_SETDETACHSTATE
if (err == 0)
- err = pthread_attr_setdetachstate(&attr, ATTR_JOINABLE);
-#else /* !defined(ATTR_JOINABLE) */
-#ifdef __UNDETACHED
- if (err == 0)
- err = pthread_attr_setdetachstate(&attr, &__undetached);
-#else /* !defined(__UNDETACHED) */
+ err = PTHREAD_ATTR_SETDETACHSTATE(&attr, attr_joinable);
+
+# else
croak("panic: can't pthread_attr_setdetachstate");
-#endif /* __UNDETACHED */
-#endif /* ATTR_JOINABLE */
-#endif /* VMS */
-#endif /* OLD_PTHREADS_API */
+# endif
}
if (err == 0)
-#ifdef OLD_PTHREADS_API
- err = pthread_create(&thr->self, attr, threadstart, (void*) thr);
-#else
- err = pthread_create(&thr->self, &attr, threadstart, (void*) thr);
-#endif
+ err = PTHREAD_CREATE(&thr->self, attr, threadstart, (void*) thr);
/* Go */
MUTEX_UNLOCK(&thr->mutex);
#endif
diff --git a/thread.h b/thread.h
index 22373e6c54..bca5f83bfe 100644
--- a/thread.h
+++ b/thread.h
@@ -3,14 +3,7 @@
#ifdef WIN32
# include <win32thread.h>
#else
-/* XXX What we really need is Configure probing for all of these
- * pthread thingies, old, medium, and new, not the blanket statement of
- * OLD_PTHREADS_API. --jhi */
-# if defined(OLD_PTHREADS_API) && !defined(DJGPP) && !defined(__OPEN_VM) && !defined(OEMVS)
- /* POSIXish threads */
-# define pthread_mutexattr_init(a) pthread_mutexattr_create(a)
-# define pthread_mutexattr_settype(a,t) pthread_mutexattr_setkind_np(a,t)
-# define pthread_key_create(k,d) pthread_keycreate(k,(pthread_destructor_t)(d))
+# ifdef OLD_PTHREADS_API /* Here be dragons. */
# define DETACH(t) \
STMT_START { \
if (pthread_detach(&(t)->self)) { \
@@ -18,10 +11,47 @@
croak("panic: DETACH"); \
} \
} STMT_END
-# else
+# define THR getTHR
+struct perl_thread *getTHR _((void));
+# define PTHREAD_GETSPECIFIC_INT
+# ifdef DJGPP
+# define pthread_addr_t any_t
+# define NEED_PTHREAD_INIT
+# define PTHREAD_CREATE_JOINABLE (&err)
+# endif
+# ifdef __OPEN_VM
+# define pthread_addr_t void *
+# endif
+# ifdef VMS
+# define pthread_attr_init(a) pthread_attr_create(a)
+# define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_setdetach_np(a,s)
+# define pthread_key_create(k,d) pthread_keycreate(k,(pthread_destructor_t)(d))
+# define pthread_mutexattr_init(a) pthread_mutexattr_create(a)
+# endif
+# if defined(DJGPP) || defined(__OPEN_VM)
+# define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,&(s))
+# define YIELD pthread_yield(NULL)
+# endif
+# if defined(DJGPP) || defined(VMS)
+# define PTHREAD_CREATE(t,a,s,d) pthread_create(t,a,s,d)
+# endif
+# if defined(__OPEN_VM) || defined(VMS)
+# define pthread_mutexattr_settype(a,t) pthread_mutexattr_setkind_np(a,t)
+# endif
+# endif
+# ifndef VMS
# define pthread_mutexattr_default NULL
-# define pthread_condattr_default NULL
-# endif /* OLD_PTHREADS_API */
+# define pthread_condattr_default NULL
+# endif
+#endif
+
+#ifndef PTHREAD_CREATE
+/* You are not supposed to pass NULL as the 2nd arg of PTHREAD_CREATE(). */
+# define PTHREAD_CREATE(t,a,s,d) pthread_create(t,&(a),s,d)
+#endif
+
+#ifndef PTHREAD_ATTR_SETDETACHSTATE
+# define PTHREAD_ATTR_SETDETACHSTATE(a,s) pthread_attr_setdetachstate(a,s)
#endif
#ifndef YIELD
@@ -131,13 +161,8 @@
#endif /* SET_THR */
#ifndef THR
-# ifdef OLD_PTHREADS_API
-struct perl_thread *getTHR _((void));
-# define THR getTHR()
-# else
-# define THR ((struct perl_thread *) pthread_getspecific(PL_thr_key))
-# endif /* OLD_PTHREADS_API */
-#endif /* THR */
+#define THR ((struct perl_thread *) pthread_getspecific(PL_thr_key))
+#endif
/*
* dTHR is performance-critical. Here, we only do the pthread_get_specific
diff --git a/util.c b/util.c
index e705402bba..e47b95d001 100644
--- a/util.c
+++ b/util.c
@@ -2767,7 +2767,7 @@ perl_cond *cp;
}
#endif /* FAKE_THREADS */
-#ifdef OLD_PTHREADS_API
+#ifdef PTHREAD_GETSPECIFIC_INT
struct perl_thread *
getTHR _((void))
{
@@ -2777,7 +2777,7 @@ getTHR _((void))
croak("panic: pthread_getspecific");
return (struct perl_thread *) t;
}
-#endif /* OLD_PTHREADS_API */
+#endif
MAGIC *
condpair_magic(SV *sv)
diff --git a/vmesa/vmesaish.h b/vmesa/vmesaish.h
index 379d5b4c4e..a6bd901cdb 100644
--- a/vmesa/vmesaish.h
+++ b/vmesa/vmesaish.h
@@ -6,11 +6,5 @@
void * dlopen(const char *);
void * dlsym(void *, const char *);
void * dlerror(void);
-# ifdef YIELD
-# undef YIELD
-# endif
-# define YIELD pthread_yield(NULL)
-# define pthread_mutexattr_default NULL
-# define pthread_condattr_default NULL
- typedef void * pthread_addr_t;
+# define OLD_PTHREADS_API
#endif