]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_cthreads.c
Config fixes
[openldap] / libraries / libldap_r / thr_cthreads.c
1 /* thr_cthreads.c - wrapper for mach cthreads */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2005 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16 /* This work was initially developed by Luke Howard for inclusion
17  * in U-MICH LDAP 3.3.
18  */
19
20 #include "portable.h"
21
22 #if defined( HAVE_MACH_CTHREADS )
23 #include "ldap_pvt_thread.h"
24
25 int
26 ldap_int_thread_initialize( void )
27 {
28         return 0;
29 }
30
31 int
32 ldap_int_thread_destroy( void )
33 {
34         return 0;
35 }
36
37 int 
38 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
39         int detach,
40         void *(*start_routine)( void *), void *arg)
41 {
42         *thread = cthread_fork( (cthread_fn_t) start_routine, arg);
43         return ( *thread == NULL ? -1 : 0 );    
44 }
45
46 void 
47 ldap_pvt_thread_exit( void *retval )
48 {
49         cthread_exit( (any_t) retval );
50 }
51
52 int 
53 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **thread_return )
54 {
55         void *status;
56         status = (void *) cthread_join ( thread );
57         if (thread_return != NULL)
58                 {
59                 *thread_return = status;
60                 }
61         return 0;
62 }
63
64 int 
65 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
66 {
67         return 0;
68 }
69
70 int 
71 ldap_pvt_thread_yield( void )
72 {
73         cthread_yield();
74         return 0;
75 }
76
77 int 
78 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
79 {
80         condition_init( cond );
81         return( 0 );
82 }
83
84 int 
85 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
86 {
87         condition_clear( cond );
88         return( 0 );
89 }
90
91 int 
92 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
93 {
94         condition_signal( cond );
95         return( 0 );
96 }
97
98 int
99 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
100 {
101         condition_broadcast( cond );
102         return( 0 );
103 }
104
105 int 
106 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond, 
107                           ldap_pvt_thread_mutex_t *mutex )
108 {
109         condition_wait( cond, mutex );
110         return( 0 );    
111 }
112
113 int 
114 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
115 {
116         mutex_init( mutex );
117         mutex->name = NULL;
118         return ( 0 );
119 }
120
121 int 
122 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
123 {
124         mutex_clear( mutex );
125         return ( 0 );   
126 }
127         
128 int 
129 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
130 {
131         mutex_lock( mutex );
132         return ( 0 );
133 }
134
135 int 
136 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
137 {
138         mutex_unlock( mutex );
139         return ( 0 );
140 }
141
142 int
143 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
144 {
145         return mutex_try_lock( mutex );
146 }
147
148 ldap_pvt_thread_t
149 ldap_pvt_thread_self( void )
150 {
151         return cthread_self();
152 }
153
154 #endif /* HAVE_MACH_CTHREADS */