]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/thr_posix.c
Prefer thr_yield over sched_yield for Solaris
[openldap] / libraries / libldap_r / thr_posix.c
index a2812302915c15f3b1f9aaa90cf2a9a0fe0d39c6..5ddc03a871f5393b6061076a4cd17e3ea9c55873 100644 (file)
@@ -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 );
        }
@@ -164,9 +162,10 @@ ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
 int 
 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
 {
-#if HAVE_PTHREADS > 6
+#if ( HAVE_PTHREAD_KILL && HAVE_PTHREADS > 6 )
+       /* MacOS 10.1 is detected as v10 but has no pthread_kill() */
        return pthread_kill( thread, signo );
-#elif HAVE_PTHREADS > 4
+#elif ( HAVE_PTHREAD_KILL && HAVE_PTHREADS > 4 )
        if ( pthread_kill( thread, signo ) < 0 ) return errno;
        return 0;
 #else
@@ -180,16 +179,16 @@ ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
 int 
 ldap_pvt_thread_yield( void )
 {
-#if HAVE_PTHREADS == 10
+#if HAVE_THR_YIELD
+       return thr_yield();
+
+#elif HAVE_PTHREADS == 10
        return sched_yield();
 
 #elif defined(_POSIX_THREAD_IS_GNU_PTH)
        sched_yield();
        return 0;
 
-#elif HAVE_THR_YIELD
-       return thr_yield();
-
 #elif HAVE_PTHREADS == 6
        pthread_yield(NULL);
        return 0;