]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_cthreads.c
8a308e75b39cfa45e3baee5c5debef9c292cefdd
[openldap] / libraries / libldap_r / thr_cthreads.c
1 /* thrmach.c - wrapper for mach cthreads */
2
3 #include "portable.h"
4 #include "ldap_pvt_thread.h"
5
6 #if defined( HAVE_MACH_CTHREADS )
7
8 /***********************************************************************
9  *                                                                     *
10  * under NEXTSTEP or OPENSTEP use CThreads                             *
11  * lukeh@xedoc.com.au                                                  *
12  *                                                                     *
13  ***********************************************************************/
14
15 int 
16 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
17                        ldap_pvt_thread_attr_t *attr,
18                        void *(*start_routine)( void *), void *arg)
19 {
20         *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
21         return ( *thread == NULL ? -1 : 0 );    
22 }
23
24 void 
25 ldap_pvt_thread_exit( void *retval )
26 {
27         cthread_exit( (any_t) retval );
28 }
29
30 int 
31 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
32 {
33         void *status;
34         status = (void *) cthread_join ( tid );
35         if (thread_return != NULL)
36                 {
37                 *thread_return = status;
38                 }
39         return 0;
40 }
41
42 int 
43 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
44 {
45         return 0;
46 }
47
48 int 
49 ldap_pvt_thread_yield( void )
50 {
51         cthread_yield();
52         return 0;
53 }
54
55 int 
56 ldap_pvt_thread_attr_init( ldap_pvt_thread_attr_t *attr )
57 {
58         *attr = 0;
59         return( 0 );
60 }
61
62 int 
63 ldap_pvt_thread_attr_destroy( ldap_pvt_thread_attr_t *attr )
64 {
65         return( 0 );
66 }
67
68 int 
69 ldap_pvt_thread_attr_setdetachstate( ldap_pvt_thread_attr_t *attr, int dstate )
70 {
71         *attr = dstate;
72         return( 0 );
73 }
74
75 int 
76 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond, 
77                           ldap_pvt_thread_condattr_t *attr )
78 {
79         condition_init( cond );
80         return( 0 );
81 }
82
83 int 
84 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
85 {
86         condition_signal( cond );
87         return( 0 );
88 }
89
90 int
91 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cv )
92 {
93         condition_broadcast( cv );
94         return( 0 );
95 }
96
97 int 
98 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
99                           ldap_pvt_thread_mutex_t *mutex )
100 {
101         condition_wait( cond, mutex );
102         return( 0 );    
103 }
104
105 int 
106 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex,
107                            ldap_pvt_thread_mutexattr_t *attr )
108 {
109         mutex_init( mutex );
110         mutex->name = NULL;
111         return ( 0 );
112 }
113
114 int 
115 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
116 {
117         mutex_clear( mutex );
118         return ( 0 );   
119 }
120         
121 int 
122 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
123 {
124         mutex_lock( mutex );
125         return ( 0 );
126 }
127
128 int 
129 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
130 {
131         mutex_unlock( mutex );
132         return ( 0 );
133 }
134
135 int
136 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
137 {
138         return mutex_try_lock( mutex );
139 }
140
141 #endif /* HAVE_MACH_CTHREADS */