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