POSIX threads tweaks for Draft 4 vs Draft 5

This commit is contained in:
Howard Chu 2002-09-12 23:12:18 +00:00
parent dd77936809
commit 2e6a83049e
3 changed files with 504 additions and 521 deletions

View File

@ -621,12 +621,10 @@ dnl
dnl ==================================================================== dnl ====================================================================
dnl Check POSIX Thread version dnl Check POSIX Thread version
dnl 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 version of the POSIX.4a Draft that is implemented.
dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes. dnl 10 == POSIX.4a Final == POSIX.1c-1996 for our purposes.
dnl 0 implies that the version could not be detected dnl Existence of pthreads.h should be tested separately.
dnl or that pthreads.h does exist. Existence of pthreads.h
dnl should be tested separately.
dnl dnl
dnl tests: dnl tests:
dnl pthread_yield() was dropped in Draft 9, so 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 PTHREAD_MUTEX_INITIALIZER was introduced in Draft 5. It's not
dnl interesting to us because we don't try to statically dnl interesting to us because we don't try to statically
dnl initialize mutexes. 5-10 has it. dnl initialize mutexes. 5-10 has it.
dnl pthread_attr_create was renamed to pthread_attr_init after Draft 4. dnl pthread_attr_create was renamed to pthread_attr_init in Draft 6.
dnl Draft 6-10 has _init, Draft 4 has _create. (dunno about 5) dnl Draft 6-10 has _init, Draft 4-5 has _create.
dnl dnl
dnl Draft 9 and 10 are equivalent for our purposes. dnl Draft 9 and 10 are equivalent for our purposes.
dnl dnl
@ -660,9 +658,7 @@ AC_DEFUN([OL_POSIX_THREAD_VERSION],
#ifdef PTHREAD_MUTEX_INITIALIZER #ifdef PTHREAD_MUTEX_INITIALIZER
draft5 draft5
#endif #endif
], ol_cv_pthread_version=5, [ ], ol_cv_pthread_version=5, ol_cv_pthread_version=4) ],
AC_EGREP_HEADER(pthread_attr_create,pthread.h,
ol_cv_pthread_version=4, ol_cv_pthread_version=0) ]) ],
ol_cv_pthread_version=6) ]) ], ol_cv_pthread_version=6) ]) ],
ol_cv_pthread_version=8) ], ol_cv_pthread_version=8) ],
ol_cv_pthread_version=10) ol_cv_pthread_version=10)

1003
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@
#include "ldap_pvt_thread.h" #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_ATTR_DEFAULT pthread_attr_default
# define LDAP_INT_THREAD_CONDATTR_DEFAULT pthread_condattr_default # define LDAP_INT_THREAD_CONDATTR_DEFAULT pthread_condattr_default
# define LDAP_INT_THREAD_MUTEXATTR_DEFAULT pthread_mutexattr_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; pthread_attr_t attr;
/* Always create the thread attrs, so we can set stacksize if we need to */ /* 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); pthread_attr_init(&attr);
#else #else
pthread_attr_create(&attr); pthread_attr_create(&attr);
@ -122,12 +122,10 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
#endif #endif
#endif #endif
rtn = pthread_create( thread, &attr, start_routine, arg ); rtn = pthread_create( thread, &attr, start_routine, arg );
#if HAVE_PTHREADS > 4 #if HAVE_PTHREADS > 5
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
#else #else
pthread_attr_delete(&attr); pthread_attr_delete(&attr);
#endif
#if HAVE_PTHREADS < 6
if( detach ) { if( detach ) {
pthread_detach( thread ); pthread_detach( thread );
} }