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_cthreads.c - wrapper for mach cthreads */
16 #if defined( HAVE_MACH_CTHREADS )
17 #include "ldap_pvt_thread.h"
19 /***********************************************************************
21 * under NEXTSTEP or OPENSTEP use CThreads *
22 * lukeh@xedoc.com.au *
24 ***********************************************************************/
27 ldap_int_thread_initialize( void )
33 ldap_int_thread_destroy( void )
39 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
41 void *(*start_routine)( void *), void *arg)
43 *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
44 return ( *thread == NULL ? -1 : 0 );
48 ldap_pvt_thread_exit( void *retval )
50 cthread_exit( (any_t) retval );
54 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
57 status = (void *) cthread_join ( thread );
58 if (thread_return != NULL)
60 *thread_return = status;
66 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
72 ldap_pvt_thread_yield( void )
79 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
81 condition_init( cond );
86 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
88 condition_clear( cond );
93 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
95 condition_signal( cond );
100 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
102 condition_broadcast( cond );
107 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
108 ldap_pvt_thread_mutex_t *mutex )
110 condition_wait( cond, mutex );
115 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
123 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
125 mutex_clear( mutex );
130 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
137 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
139 mutex_unlock( mutex );
144 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
146 return mutex_try_lock( mutex );
149 #endif /* HAVE_MACH_CTHREADS */