]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_cthreads.c
Move the input data exhaustion loop to connection.c from daemon.c
[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
15 #if defined( HAVE_MACH_CTHREADS )
16 #include "ldap_pvt_thread.h"
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_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 ( tid );
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 #endif /* HAVE_MACH_CTHREADS */