2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
5 * Redistribution and use in source and binary forms are permitted only
6 * as authorized by the OpenLDAP Public License. A copy of this
7 * license is available at http://www.OpenLDAP.org/license.html or
8 * in file LICENSE in the top-level directory of the distribution.
11 /* thr_cthreads.c - wrapper for mach cthreads */
14 #include "ldap_pvt_thread.h"
16 #if defined( HAVE_MACH_CTHREADS )
18 /***********************************************************************
20 * under NEXTSTEP or OPENSTEP use CThreads *
21 * lukeh@xedoc.com.au *
23 ***********************************************************************/
26 ldap_pvt_thread_initialize( void )
32 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
34 void *(*start_routine)( void *), void *arg)
36 *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
37 return ( *thread == NULL ? -1 : 0 );
41 ldap_pvt_thread_exit( void *retval )
43 cthread_exit( (any_t) retval );
47 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
50 status = (void *) cthread_join ( tid );
51 if (thread_return != NULL)
53 *thread_return = status;
59 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
65 ldap_pvt_thread_yield( void )
72 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
74 condition_init( cond );
79 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
81 condition_clear( cond );
86 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
88 condition_signal( cond );
93 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
95 condition_broadcast( cond );
100 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
101 ldap_pvt_thread_mutex_t *mutex )
103 condition_wait( cond, mutex );
108 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
116 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
118 mutex_clear( mutex );
123 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
130 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
132 mutex_unlock( mutex );
137 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
139 return mutex_try_lock( mutex );
142 #endif /* HAVE_MACH_CTHREADS */