]> git.sur5r.net Git - openldap/blob - libraries/libldap_r/thr_stub.c
Avoid premature free
[openldap] / libraries / libldap_r / thr_stub.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-2000 The OpenLDAP Foundation, Redwood City, California, USA
4  * All rights reserved.
5  *
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.
10  */
11
12 /* thr_stub.c - stubs for the threads */
13
14 #include "portable.h"
15
16 #if defined( NO_THREADS )
17
18 #include "ldap_pvt_thread.h"
19
20 /***********************************************************************
21  *                                                                     *
22  * no threads package defined for this system - fake ok returns from   *
23  * all threads routines (making it single-threaded).                   *
24  *                                                                     *
25  ***********************************************************************/
26
27 int
28 ldap_int_thread_initialize( void )
29 {
30         return 0;
31 }
32
33 int
34 ldap_int_thread_destroy( void )
35 {
36         return 0;
37 }
38
39 static void* ldap_int_status = NULL;
40
41 int 
42 ldap_pvt_thread_create( ldap_pvt_thread_t * thread, 
43         int detach,
44         void *(*start_routine)(void *),
45         void *arg)
46 {
47         if( ! detach ) ldap_int_status = NULL;
48         start_routine( arg );
49         return 0;
50 }
51
52 void 
53 ldap_pvt_thread_exit( void *retval )
54 {
55         if( retval != NULL ) {
56                 ldap_int_status = retval;
57         }
58         return;
59 }
60
61 int 
62 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status )
63 {
64         if(status != NULL) *status = ldap_int_status;
65         return 0;
66 }
67
68 int 
69 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
70 {
71         return 0;
72 }
73
74 int 
75 ldap_pvt_thread_yield( void )
76 {
77         return 0;
78 }
79
80 int 
81 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
82 {
83         return 0;
84 }
85
86 int 
87 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
88 {
89         return 0;
90 }
91
92 int 
93 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
94 {
95         return 0;
96 }
97
98 int 
99 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
100 {
101         return 0;
102 }
103
104 int 
105 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
106                           ldap_pvt_thread_mutex_t *mutex )
107 {
108         return 0;
109 }
110
111 int 
112 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
113 {
114         return 0;
115 }
116
117 int 
118 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
119 {
120         return 0;
121 }
122
123 int 
124 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
125 {
126         return 0;
127 }
128
129 int 
130 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
131 {
132         return 0;
133 }
134
135 int 
136 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
137 {
138         return 0;
139 }
140
141 /*
142  * NO_THREADS requires a separate tpool implementation since
143  * generic ldap_pvt_thread_pool_wrapper loops forever.
144  */
145 int
146 ldap_pvt_thread_pool_init (
147         ldap_pvt_thread_pool_t *pool_out,
148         int max_concurrency, int max_pending )
149 {
150         *pool_out = (ldap_pvt_thread_pool_t) 0;
151         return(0);
152 }
153
154 int
155 ldap_pvt_thread_pool_submit (
156         ldap_pvt_thread_pool_t *pool,
157         void *(*start_routine)( void * ), void *arg )
158 {
159         (start_routine)(arg);
160         return(0);
161 }
162
163 int
164 ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t *tpool, int max_threads )
165 {
166         return(0);
167 }
168
169 int
170 ldap_pvt_thread_pool_backload (
171         ldap_pvt_thread_pool_t *pool )
172 {
173         return(0);
174 }
175
176 int
177 ldap_pvt_thread_pool_destroy (
178         ldap_pvt_thread_pool_t *pool, int run_pending )
179 {
180         return(0);
181 }
182
183 #endif /* NO_THREADS */