mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-09 02:52:04 +08:00
POSIX threads tweaks for Draft 4 vs Draft 5
This commit is contained in:
parent
dd77936809
commit
2e6a83049e
@ -621,12 +621,10 @@ dnl
|
||||
dnl ====================================================================
|
||||
dnl Check POSIX Thread version
|
||||
dnl
|
||||
dnl defines ol_cv_pthread_version to 0, 4, 5, 6, 7, 10, depending on the
|
||||
dnl defines ol_cv_pthread_version to 4, 5, 6, 7, 10, depending on the
|
||||
dnl version of the POSIX.4a Draft that is implemented.
|
||||
dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
|
||||
dnl 0 implies that the version could not be detected
|
||||
dnl or that pthreads.h does exist. Existence of pthreads.h
|
||||
dnl should be tested separately.
|
||||
dnl Existence of pthreads.h should be tested separately.
|
||||
dnl
|
||||
dnl tests:
|
||||
dnl pthread_yield() was dropped in Draft 9, so
|
||||
@ -639,8 +637,8 @@ dnl pthread_attr_default was dropped in Draft 6, only 4 and 5 have it
|
||||
dnl PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
|
||||
dnl interesting to us because we don't try to statically
|
||||
dnl initialize mutexes. 5-10 has it.
|
||||
dnl pthread_attr_create was renamed to pthread_attr_init after Draft 4.
|
||||
dnl Draft 6-10 has _init, Draft 4 has _create. (dunno about 5)
|
||||
dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
|
||||
dnl Draft 6-10 has _init, Draft 4-5 has _create.
|
||||
dnl
|
||||
dnl Draft 9 and 10 are equivalent for our purposes.
|
||||
dnl
|
||||
@ -660,9 +658,7 @@ AC_DEFUN([OL_POSIX_THREAD_VERSION],
|
||||
#ifdef PTHREAD_MUTEX_INITIALIZER
|
||||
draft5
|
||||
#endif
|
||||
], ol_cv_pthread_version=5, [
|
||||
AC_EGREP_HEADER(pthread_attr_create,pthread.h,
|
||||
ol_cv_pthread_version=4, ol_cv_pthread_version=0) ]) ],
|
||||
], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ],
|
||||
ol_cv_pthread_version=6) ]) ],
|
||||
ol_cv_pthread_version=8) ],
|
||||
ol_cv_pthread_version=10)
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "ldap_pvt_thread.h"
|
||||
|
||||
|
||||
#if HAVE_PTHREADS == 4
|
||||
#if HAVE_PTHREADS < 6
|
||||
# define LDAP_INT_THREAD_ATTR_DEFAULT pthread_attr_default
|
||||
# define LDAP_INT_THREAD_CONDATTR_DEFAULT pthread_condattr_default
|
||||
# define LDAP_INT_THREAD_MUTEXATTR_DEFAULT pthread_mutexattr_default
|
||||
@ -102,7 +102,7 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
|
||||
pthread_attr_t attr;
|
||||
|
||||
/* Always create the thread attrs, so we can set stacksize if we need to */
|
||||
#if HAVE_PTHREADS > 4
|
||||
#if HAVE_PTHREADS > 5
|
||||
pthread_attr_init(&attr);
|
||||
#else
|
||||
pthread_attr_create(&attr);
|
||||
@ -122,12 +122,10 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
|
||||
#endif
|
||||
#endif
|
||||
rtn = pthread_create( thread, &attr, start_routine, arg );
|
||||
#if HAVE_PTHREADS > 4
|
||||
#if HAVE_PTHREADS > 5
|
||||
pthread_attr_destroy(&attr);
|
||||
#else
|
||||
pthread_attr_delete(&attr);
|
||||
#endif
|
||||
#if HAVE_PTHREADS < 6
|
||||
if( detach ) {
|
||||
pthread_detach( thread );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user