# 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
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);
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
#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)) { \
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
#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