1 /* thrmach.c - wrapper for mach cthreads */
4 #include "ldap_pvt_thread.h"
6 #if defined( HAVE_MACH_CTHREADS )
8 /***********************************************************************
10 * under NEXTSTEP or OPENSTEP use CThreads *
11 * lukeh@xedoc.com.au *
13 ***********************************************************************/
16 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
17 ldap_pvt_thread_attr_t *attr,
18 void *(*start_routine)( void *), void *arg)
20 *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
21 return ( *thread == NULL ? -1 : 0 );
25 ldap_pvt_thread_exit( void *retval )
27 cthread_exit( (any_t) retval );
31 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
34 status = (void *) cthread_join ( tid );
35 if (thread_return != NULL)
37 *thread_return = status;
43 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
49 ldap_pvt_thread_yield( void )
56 ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr )
63 ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr )
69 ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate )
76 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond,
77 ldap_pvt_thread_condattr_t *attr )
79 condition_init( cond );
84 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
86 condition_signal( cond );
91 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
93 condition_broadcast( cv );
98 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
99 ldap_pvt_thread_mutex_t *mutex )
101 condition_wait( cond, mutex );
106 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex,
107 ldap_pvt_thread_mutexattr_t *attr )
115 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
117 mutex_clear( mutex );
122 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
129 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
131 mutex_unlock( mutex );
136 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
138 return mutex_try_lock( mutex );
141 #endif /* HAVE_MACH_CTHREADS */