1 /* thr_stub.c - stubs for the threads */
2 /* $OpenLDAP: pkg/ldap/libraries/libldap_r/thr_stub.c,v 1.27.2.8 2008/05/27 20:07:31 quanah Exp $ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2008 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
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>.
19 #if defined( NO_THREADS )
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 */
26 /***********************************************************************
28 * no threads package defined for this system - fake ok returns from *
29 * all threads routines (making it single-threaded). *
31 ***********************************************************************/
34 ldap_int_thread_initialize( void )
40 ldap_int_thread_destroy( void )
45 static void* ldap_int_status
= NULL
;
48 ldap_pvt_thread_create( ldap_pvt_thread_t
* thread
,
50 void *(*start_routine
)(void *),
53 if( ! detach
) ldap_int_status
= NULL
;
59 ldap_pvt_thread_exit( void *retval
)
61 if( retval
!= NULL
) {
62 ldap_int_status
= retval
;
68 ldap_pvt_thread_join( ldap_pvt_thread_t thread
, void **status
)
70 if(status
!= NULL
) *status
= ldap_int_status
;
75 ldap_pvt_thread_kill( ldap_pvt_thread_t thread
, int signo
)
81 ldap_pvt_thread_yield( void )
87 ldap_pvt_thread_cond_init( ldap_pvt_thread_cond_t
*cond
)
93 ldap_pvt_thread_cond_destroy( ldap_pvt_thread_cond_t
*cond
)
99 ldap_pvt_thread_cond_signal( ldap_pvt_thread_cond_t
*cond
)
105 ldap_pvt_thread_cond_broadcast( ldap_pvt_thread_cond_t
*cond
)
111 ldap_pvt_thread_cond_wait( ldap_pvt_thread_cond_t
*cond
,
112 ldap_pvt_thread_mutex_t
*mutex
)
118 ldap_pvt_thread_mutex_init( ldap_pvt_thread_mutex_t
*mutex
)
124 ldap_pvt_thread_mutex_destroy( ldap_pvt_thread_mutex_t
*mutex
)
130 ldap_pvt_thread_mutex_lock( ldap_pvt_thread_mutex_t
*mutex
)
136 ldap_pvt_thread_mutex_trylock( ldap_pvt_thread_mutex_t
*mutex
)
142 ldap_pvt_thread_mutex_unlock( ldap_pvt_thread_mutex_t
*mutex
)
148 * NO_THREADS requires a separate tpool implementation since
149 * generic ldap_pvt_thread_pool_wrapper loops forever.
152 ldap_pvt_thread_pool_init (
153 ldap_pvt_thread_pool_t
*pool_out
,
154 int max_concurrency
, int max_pending
)
156 *pool_out
= (ldap_pvt_thread_pool_t
) 0;
161 ldap_pvt_thread_pool_submit (
162 ldap_pvt_thread_pool_t
*pool
,
163 ldap_pvt_thread_start_t
*start_routine
, void *arg
)
165 (start_routine
)(NULL
, arg
);
170 ldap_pvt_thread_pool_maxthreads ( ldap_pvt_thread_pool_t
*tpool
, int max_threads
)
176 ldap_pvt_thread_pool_query( ldap_pvt_thread_pool_t
*tpool
,
177 ldap_pvt_thread_pool_param_t param
, void *value
)
184 ldap_pvt_thread_pool_backload (
185 ldap_pvt_thread_pool_t
*pool
)
191 ldap_pvt_thread_pool_destroy (
192 ldap_pvt_thread_pool_t
*pool
, int run_pending
)
197 int ldap_pvt_thread_pool_getkey (
198 void *ctx
, void *key
, void **data
, ldap_pvt_thread_pool_keyfree_t
**kfree
)
203 int ldap_pvt_thread_pool_setkey (
204 void *ctx
, void *key
,
205 void *data
, ldap_pvt_thread_pool_keyfree_t
*kfree
,
206 void **olddatap
, ldap_pvt_thread_pool_keyfree_t
**oldkfreep
)
208 if ( olddatap
) *olddatap
= NULL
;
209 if ( oldkfreep
) *oldkfreep
= 0;
213 void ldap_pvt_thread_pool_purgekey( void *key
)
217 int ldap_pvt_thread_pool_pause (
218 ldap_pvt_thread_pool_t
*tpool
)
223 int ldap_pvt_thread_pool_resume (
224 ldap_pvt_thread_pool_t
*tpool
)
229 int ldap_pvt_thread_pool_pausing( ldap_pvt_thread_pool_t
*tpool
)
234 ldap_pvt_thread_pool_pausecheck( ldap_pvt_thread_pool_t
*tpool
)
239 void *ldap_pvt_thread_pool_context( )
244 void ldap_pvt_thread_pool_context_reset( void *vctx
)
249 ldap_pvt_thread_self( void )
255 ldap_pvt_thread_key_create( ldap_pvt_thread_key_t
*key
)
261 ldap_pvt_thread_key_destroy( ldap_pvt_thread_key_t key
)
267 ldap_pvt_thread_key_setdata( ldap_pvt_thread_key_t key
, void *data
)
273 ldap_pvt_thread_key_getdata( ldap_pvt_thread_key_t key
, void **data
)
279 ldap_pvt_thread_pool_tid( void *vctx
)
285 #endif /* NO_THREADS */