3 * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
6 * Redistribution and use in source and binary forms are permitted only
7 * as authorized by the OpenLDAP Public License. A copy of this
8 * license is available at http://www.OpenLDAP.org/license.html or
9 * in file LICENSE in the top-level directory of the distribution.
12 /* thr_thr.c - wrappers around solaris threads */
16 #if defined( HAVE_GNU_PTH )
18 #include "ldap_pvt_thread.h"
26 static pth_attr_t detach_attr;
29 ldap_pvt_thread_initialize( void )
31 detach_attr = pth_attr_new();
32 pth_attr_set( detach_attr, PTH_ATTR_JOINABLE, FALSE );
37 ldap_pvt_thread_destroy( void )
39 pth_attr_destroy(detach_attr);
45 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
47 void *(*start_routine)( void *),
50 *thread = pth_spawn( detach ? detach_attr : PTH_ATTR_DEFAULT,
53 return *thread == NULL;
57 ldap_pvt_thread_exit( void *retval )
62 int ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
64 pth_join( thread, thread_return );
69 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
71 pth_raise( thread, signo );
76 ldap_pvt_thread_yield( void )
83 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
85 return( pth_cond_init( cond ) );
89 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
91 return( pth_cond_notify( cond, 0 ) );
95 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
97 return( pth_cond_notify( cond, 1 ) );
101 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
102 ldap_pvt_thread_mutex_t *mutex )
104 return( pth_cond_await( cond, mutex, NULL ) );
108 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cv )
114 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
116 return( pth_mutex_init( mutex ) );
120 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
126 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
128 return( pth_mutex_acquire( mutex, 0, NULL ) );
132 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
134 return( pth_mutex_release( mutex ) );
138 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
140 return( pth_mutex_acquire( mutex, 1, NULL ) );
143 #endif /* HAVE_GNU_PTH */