1 /* thr_stub.c - stubs for the threads */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2021 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 
17 #include "portable.h"
18 
19 #if defined( NO_THREADS )
20 
21 #include "ldap_pvt_thread.h" /* Get the thread interface */
22 #define LDAP_THREAD_IMPLEMENTATION
23 #define LDAP_THREAD_POOL_IMPLEMENTATION
24 #include "ldap_thr_debug.h"  /* May rename the symbols defined below */
25 
26 /***********************************************************************
27  *                                                                     *
28  * no threads package defined for this system - fake ok returns from   *
29  * all threads routines (making it single-threaded).                   *
30  *                                                                     *
31  ***********************************************************************/
32 
33 int
ldap_int_thread_initialize(void)34 ldap_int_thread_initialize( void )
35 {
36 	return 0;
37 }
38 
39 int
ldap_int_thread_destroy(void)40 ldap_int_thread_destroy( void )
41 {
42 	return 0;
43 }
44 
45 static void* ldap_int_status = NULL;
46 
47 int
ldap_pvt_thread_create(ldap_pvt_thread_t * thread,int detach,void * (* start_routine)(void *),void * arg)48 ldap_pvt_thread_create( ldap_pvt_thread_t * thread,
49 	int detach,
50 	void *(*start_routine)(void *),
51 	void *arg)
52 {
53 	if( ! detach ) ldap_int_status = NULL;
54 	start_routine( arg );
55 	return 0;
56 }
57 
58 void
ldap_pvt_thread_exit(void * retval)59 ldap_pvt_thread_exit( void *retval )
60 {
61 	if( retval != NULL ) {
62 		ldap_int_status = retval;
63 	}
64 	return;
65 }
66 
67 int
ldap_pvt_thread_join(ldap_pvt_thread_t thread,void ** status)68 ldap_pvt_thread_join( ldap_pvt_thread_t thread, void **status )
69 {
70 	if(status != NULL) *status = ldap_int_status;
71 	return 0;
72 }
73 
74 int
ldap_pvt_thread_kill(ldap_pvt_thread_t thread,int signo)75 ldap_pvt_thread_kill( ldap_pvt_thread_t thread, int signo )
76 {
77 	return 0;
78 }
79 
80 int
ldap_pvt_thread_yield(void)81 ldap_pvt_thread_yield( void )
82 {
83 	return 0;
84 }
85 
86 int
ldap_pvt_thread_cond_init(ldap_pvt_thread_cond_t * cond)87 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t *cond )
88 {
89 	return 0;
90 }
91 
92 int
ldap_pvt_thread_cond_destroy(ldap_pvt_thread_cond_t * cond)93 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t *cond )
94 {
95 	return 0;
96 }
97 
98 int
ldap_pvt_thread_cond_signal(ldap_pvt_thread_cond_t * cond)99 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t *cond )
100 {
101 	return 0;
102 }
103 
104 int
ldap_pvt_thread_cond_broadcast(ldap_pvt_thread_cond_t * cond)105 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t *cond )
106 {
107 	return 0;
108 }
109 
110 int
ldap_pvt_thread_cond_wait(ldap_pvt_thread_cond_t * cond,ldap_pvt_thread_mutex_t * mutex)111 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t *cond,
112 			  ldap_pvt_thread_mutex_t *mutex )
113 {
114 	return 0;
115 }
116 
117 int
ldap_pvt_thread_mutex_init(ldap_pvt_thread_mutex_t * mutex)118 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t *mutex )
119 {
120 	return 0;
121 }
122 
123 int
ldap_pvt_thread_mutex_destroy(ldap_pvt_thread_mutex_t * mutex)124 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t *mutex )
125 {
126 	return 0;
127 }
128 
129 int
ldap_pvt_thread_mutex_lock(ldap_pvt_thread_mutex_t * mutex)130 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t *mutex )
131 {
132 	return 0;
133 }
134 
135 int
ldap_pvt_thread_mutex_trylock(ldap_pvt_thread_mutex_t * mutex)136 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t *mutex )
137 {
138 	return 0;
139 }
140 
141 int
ldap_pvt_thread_mutex_unlock(ldap_pvt_thread_mutex_t * mutex)142 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t *mutex )
143 {
144 	return 0;
145 }
146 
147 /*
148  * NO_THREADS requires a separate tpool implementation since
149  * generic ldap_pvt_thread_pool_wrapper loops forever.
150  */
151 int
ldap_pvt_thread_pool_init(ldap_pvt_thread_pool_t * pool_out,int max_concurrency,int max_pending)152 ldap_pvt_thread_pool_init (
153 	ldap_pvt_thread_pool_t *pool_out,
154 	int max_concurrency, int max_pending )
155 {
156 	*pool_out = (ldap_pvt_thread_pool_t) 0;
157 	return(0);
158 }
159 
160 int
ldap_pvt_thread_pool_submit(ldap_pvt_thread_pool_t * pool,ldap_pvt_thread_start_t * start_routine,void * arg)161 ldap_pvt_thread_pool_submit (
162 	ldap_pvt_thread_pool_t *pool,
163 	ldap_pvt_thread_start_t *start_routine, void *arg )
164 {
165 	(start_routine)(NULL, arg);
166 	return(0);
167 }
168 
169 int
ldap_pvt_thread_pool_retract(ldap_pvt_thread_pool_t * pool,ldap_pvt_thread_start_t * start_routine,void * arg)170 ldap_pvt_thread_pool_retract (
171 	ldap_pvt_thread_pool_t *pool,
172 	ldap_pvt_thread_start_t *start_routine, void *arg )
173 {
174 	return(0);
175 }
176 
177 int
ldap_pvt_thread_pool_maxthreads(ldap_pvt_thread_pool_t * tpool,int max_threads)178 ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t *tpool, int max_threads )
179 {
180 	return(0);
181 }
182 
183 int
ldap_pvt_thread_pool_query(ldap_pvt_thread_pool_t * tpool,ldap_pvt_thread_pool_param_t param,void * value)184 ldap_pvt_thread_pool_query( ldap_pvt_thread_pool_t *tpool,
185 	ldap_pvt_thread_pool_param_t param, void *value )
186 {
187 	*(int *)value = -1;
188 	return(-1);
189 }
190 
191 int
ldap_pvt_thread_pool_backload(ldap_pvt_thread_pool_t * pool)192 ldap_pvt_thread_pool_backload (
193 	ldap_pvt_thread_pool_t *pool )
194 {
195 	return(0);
196 }
197 
198 int
ldap_pvt_thread_pool_destroy(ldap_pvt_thread_pool_t * pool,int run_pending)199 ldap_pvt_thread_pool_destroy (
200 	ldap_pvt_thread_pool_t *pool, int run_pending )
201 {
202 	return(0);
203 }
204 
205 void
ldap_pvt_thread_pool_idle(ldap_pvt_thread_pool_t * pool)206 ldap_pvt_thread_pool_idle ( ldap_pvt_thread_pool_t *pool )
207 {
208 	return;
209 }
210 
211 void
ldap_pvt_thread_pool_unidle(ldap_pvt_thread_pool_t * pool)212 ldap_pvt_thread_pool_unidle ( ldap_pvt_thread_pool_t *pool )
213 {
214 	return;
215 }
216 
ldap_pvt_thread_pool_getkey(void * ctx,void * key,void ** data,ldap_pvt_thread_pool_keyfree_t ** kfree)217 int ldap_pvt_thread_pool_getkey (
218 	void *ctx, void *key, void **data, ldap_pvt_thread_pool_keyfree_t **kfree )
219 {
220 	return(0);
221 }
222 
ldap_pvt_thread_pool_setkey(void * ctx,void * key,void * data,ldap_pvt_thread_pool_keyfree_t * kfree,void ** olddatap,ldap_pvt_thread_pool_keyfree_t ** oldkfreep)223 int ldap_pvt_thread_pool_setkey (
224 	void *ctx, void *key,
225 	void *data, ldap_pvt_thread_pool_keyfree_t *kfree,
226 	void **olddatap, ldap_pvt_thread_pool_keyfree_t **oldkfreep )
227 {
228 	if ( olddatap ) *olddatap = NULL;
229 	if ( oldkfreep ) *oldkfreep = 0;
230 	return(0);
231 }
232 
ldap_pvt_thread_pool_purgekey(void * key)233 void ldap_pvt_thread_pool_purgekey( void *key )
234 {
235 }
236 
ldap_pvt_thread_pool_pause(ldap_pvt_thread_pool_t * tpool)237 int ldap_pvt_thread_pool_pause (
238 	ldap_pvt_thread_pool_t *tpool )
239 {
240 	return(0);
241 }
242 
ldap_pvt_thread_pool_resume(ldap_pvt_thread_pool_t * tpool)243 int ldap_pvt_thread_pool_resume (
244 	ldap_pvt_thread_pool_t *tpool )
245 {
246 	return(0);
247 }
248 
ldap_pvt_thread_pool_pausing(ldap_pvt_thread_pool_t * tpool)249 int ldap_pvt_thread_pool_pausing( ldap_pvt_thread_pool_t *tpool )
250 {
251 	return(0);
252 }
253 
ldap_pvt_thread_pool_pausecheck(ldap_pvt_thread_pool_t * tpool)254 ldap_pvt_thread_pool_pausecheck( ldap_pvt_thread_pool_t *tpool )
255 {
256 	return(0);
257 }
258 
ldap_pvt_thread_pool_context()259 void *ldap_pvt_thread_pool_context( )
260 {
261 	return(NULL);
262 }
263 
ldap_pvt_thread_pool_context_reset(void * vctx)264 void ldap_pvt_thread_pool_context_reset( void *vctx )
265 {
266 }
267 
268 ldap_pvt_thread_t
ldap_pvt_thread_self(void)269 ldap_pvt_thread_self( void )
270 {
271 	return(0);
272 }
273 
274 int
ldap_pvt_thread_key_create(ldap_pvt_thread_key_t * key)275 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t *key )
276 {
277 	return(0);
278 }
279 
280 int
ldap_pvt_thread_key_destroy(ldap_pvt_thread_key_t key)281 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key )
282 {
283 	return(0);
284 }
285 
286 int
ldap_pvt_thread_key_setdata(ldap_pvt_thread_key_t key,void * data)287 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key, void *data )
288 {
289 	return(0);
290 }
291 
292 int
ldap_pvt_thread_key_getdata(ldap_pvt_thread_key_t key,void ** data)293 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key, void **data )
294 {
295 	return(0);
296 }
297 
298 ldap_pvt_thread_t
ldap_pvt_thread_pool_tid(void * vctx)299 ldap_pvt_thread_pool_tid( void *vctx )
300 {
301 
302 	return(0);
303 }
304 
305 #endif /* NO_THREADS */
306