]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap_r/thr_posix.c
Use 'long' for LBER_INT_T.
[openldap] / libraries / libldap_r / thr_posix.c
index 09f283d829d16158362d8b010292a56f9bbd600d..c44bee48c315ff463008ef9177c3b2b500db6dc7 100644 (file)
@@ -1,3 +1,4 @@
+/* $OpenLDAP$ */
 /*
  * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
  * All rights reserved.
  */
 
 #include "portable.h"
-#include "ldap_pvt_thread.h"
 
 #if defined( HAVE_PTHREADS )
 
+#include <ac/errno.h>
+
+#include "ldap_pvt_thread.h"
+
+
+#if HAVE_PTHREADS_D4
+#  define LDAP_PVT_THREAD_ATTR_DEFAULT         pthread_attr_default
+#  define LDAP_PVT_THREAD_CONDATTR_DEFAULT     pthread_condattr_default
+#  define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT    pthread_mutexattr_default
+#else
+#  define LDAP_PVT_THREAD_ATTR_DEFAULT         NULL
+#  define LDAP_PVT_THREAD_CONDATTR_DEFAULT     NULL
+#  define LDAP_PVT_THREAD_MUTEXATTR_DEFAULT    NULL
+#endif
+
+
 int
 ldap_pvt_thread_initialize( void )
 {
 #if defined( LDAP_THREAD_CONCURRENCY ) && HAVE_PTHREAD_SETCONCURRENCY
-       ldap_pvt_thread_setconcurrency( LDAP_THREAD_CONCURRENCY );
+       ldap_pvt_thread_set_concurrency( LDAP_THREAD_CONCURRENCY );
 #endif
        return 0;
 }
 
+int
+ldap_pvt_thread_destroy( void )
+{
+       return 0;
+}
+
 #ifdef HAVE_PTHREAD_SETCONCURRENCY
 int
 ldap_pvt_thread_set_concurrency(int n)
@@ -59,7 +81,8 @@ ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
        void *(*start_routine)( void * ),
        void *arg)
 {
-       int rtn = pthread_create( thread, NULL, start_routine, arg );
+       int rtn = pthread_create( thread, LDAP_PVT_THREAD_ATTR_DEFAULT,
+                                 start_routine, arg );
 
        if( detach ) {
 #ifdef HAVE_PTHREADS_FINAL
@@ -95,7 +118,7 @@ ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
        return pthread_kill( thread, signo );
 #else
        /* pthread package with DCE */
-       if (kill( getpid(), sig )<0)
+       if (kill( getpid(), signo )<0)
                return errno;
        return 0;
 #endif
@@ -104,12 +127,20 @@ ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
 int 
 ldap_pvt_thread_yield( void )
 {
-#ifdef HAVE_SCHED_YIELD
+#ifdef _POSIX_THREAD_IS_GNU_PTH
+       sched_yield();
+       return 0;
+
+#elif HAVE_SCHED_YIELD
        return sched_yield();
+
 #elif HAVE_PTHREAD_YIELD
-       return pthread_yield();
+       pthread_yield();
+       return 0;
+
 #elif HAVE_THR_YIELD
        return thr_yield();
+
 #else
        return 0;
 #endif   
@@ -118,7 +149,7 @@ ldap_pvt_thread_yield( void )
 int 
 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
 {
-       return pthread_cond_init( cond, NULL );
+       return pthread_cond_init( cond, LDAP_PVT_THREAD_CONDATTR_DEFAULT );
 }
 
 int 
@@ -149,7 +180,7 @@ ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
 int 
 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
 {
-       return pthread_mutex_init( mutex, NULL );
+       return pthread_mutex_init( mutex, LDAP_PVT_THREAD_MUTEXATTR_DEFAULT );
 }
 
 int