From 0d85d8777a6ec9fdcc93593180474ebff6fbbccb Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Tue, 20 Oct 1998 15:01:20 +0000 Subject: OLD_PTHREADS_API reorganizing. p4raw-id: //depot/cfgperl@2028 --- thread.h | 61 +++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 18 deletions(-) (limited to 'thread.h') 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 #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 -- cgit v1.2.1