1 /* ldap_thr_debug.h - preprocessor magic for LDAP_THREAD_DEBUG */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2005-2006 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 the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
17 #ifdef LDAP_THREAD_DEBUG
20 * libldap_r .c files should include this file after ldap_pvt_thread.h,
21 * with the appropriate LDAP_THREAD*_IMPLEMENTATION macro defined.
24 #ifndef _LDAP_PVT_THREAD_H
25 #error "ldap_pvt_thread.h" must be included before "ldap_thr_debug.h"
29 * Support for thr_debug.c:
31 * thr_debug.c defines the ldap_pvt_*() as wrappers around
32 * ldap_int_*(), and ldap_debug_*() around ldap_int_*().
34 * Renames ldap_pvt_thread_* names to ldap_int_thread_*, and a few
35 * ldap_int_*() names to ldap_debug_*(). Includes "ldap_pvt_thread.h"
36 * to declare these renamed functions, and undefines the macros
37 * afterwards when included from thr_debug.c. So,
39 * libldap_r/<not thr_debug.c> define ldap_int_* instead of ldap_pvt_*.
40 * In thread.c, ldap_pvt_thread_<initialize/destroy>() will call
41 * ldap_debug_*() instead of ldap_int_*().
42 * In tpool.c, ldap_int_thread_pool_shutdown() has thr_debug support
43 * which treats ldap_pvt_thread_pool_destroy() the same way.
46 #ifndef LDAP_THREAD_IMPLEMENTATION /* for first part of threads.c */
47 #define ldap_int_thread_initialize ldap_debug_thread_initialize
48 #define ldap_int_thread_destroy ldap_debug_thread_destroy
49 #else /* LDAP_THREAD_IMPLEMENTATION -- for thr_*.c and end of threads.c */
50 #undef ldap_int_thread_initialize
51 #undef ldap_int_thread_destroy
52 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */
53 #define ldap_pvt_thread_mutex_t ldap_int_thread_mutex_t
54 #define ldap_pvt_thread_cond_t ldap_int_thread_cond_t
56 #define ldap_pvt_thread_sleep ldap_int_thread_sleep
57 #define ldap_pvt_thread_get_concurrency ldap_int_thread_get_concurrency
58 #define ldap_pvt_thread_set_concurrency ldap_int_thread_set_concurrency
59 #define ldap_pvt_thread_create ldap_int_thread_create
60 #define ldap_pvt_thread_exit ldap_int_thread_exit
61 #define ldap_pvt_thread_join ldap_int_thread_join
62 #define ldap_pvt_thread_kill ldap_int_thread_kill
63 #define ldap_pvt_thread_yield ldap_int_thread_yield
64 #define ldap_pvt_thread_cond_init ldap_int_thread_cond_init
65 #define ldap_pvt_thread_cond_destroy ldap_int_thread_cond_destroy
66 #define ldap_pvt_thread_cond_signal ldap_int_thread_cond_signal
67 #define ldap_pvt_thread_cond_broadcast ldap_int_thread_cond_broadcast
68 #define ldap_pvt_thread_cond_wait ldap_int_thread_cond_wait
69 #define ldap_pvt_thread_mutex_init ldap_int_thread_mutex_init
70 #define ldap_pvt_thread_mutex_destroy ldap_int_thread_mutex_destroy
71 #define ldap_pvt_thread_mutex_lock ldap_int_thread_mutex_lock
72 #define ldap_pvt_thread_mutex_trylock ldap_int_thread_mutex_trylock
73 #define ldap_pvt_thread_mutex_unlock ldap_int_thread_mutex_unlock
74 #define ldap_pvt_thread_self ldap_int_thread_self
75 #endif /* LDAP_THREAD_IMPLEMENTATION */
77 #ifdef LDAP_THREAD_RDWR_IMPLEMENTATION /* rdwr.c, thr_debug.c */
78 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */
79 #define ldap_pvt_thread_rdwr_t ldap_int_thread_rdwr_t
81 #define ldap_pvt_thread_rdwr_init ldap_int_thread_rdwr_init
82 #define ldap_pvt_thread_rdwr_destroy ldap_int_thread_rdwr_destroy
83 #define ldap_pvt_thread_rdwr_rlock ldap_int_thread_rdwr_rlock
84 #define ldap_pvt_thread_rdwr_rtrylock ldap_int_thread_rdwr_rtrylock
85 #define ldap_pvt_thread_rdwr_runlock ldap_int_thread_rdwr_runlock
86 #define ldap_pvt_thread_rdwr_wlock ldap_int_thread_rdwr_wlock
87 #define ldap_pvt_thread_rdwr_wtrylock ldap_int_thread_rdwr_wtrylock
88 #define ldap_pvt_thread_rdwr_wunlock ldap_int_thread_rdwr_wunlock
89 #define ldap_pvt_thread_rdwr_readers ldap_int_thread_rdwr_readers
90 #define ldap_pvt_thread_rdwr_writers ldap_int_thread_rdwr_writers
91 #define ldap_pvt_thread_rdwr_active ldap_int_thread_rdwr_active
92 #endif /* LDAP_THREAD_RDWR_IMPLEMENTATION */
94 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c, thr_stub.c, thr_debug.c */
95 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */
96 #define ldap_pvt_thread_pool_t ldap_int_thread_pool_t
98 #define ldap_pvt_thread_pool_init ldap_int_thread_pool_init
99 #define ldap_pvt_thread_pool_submit ldap_int_thread_pool_submit
100 #define ldap_pvt_thread_pool_maxthreads ldap_int_thread_pool_maxthreads
101 #define ldap_pvt_thread_pool_backload ldap_int_thread_pool_backload
102 #define ldap_pvt_thread_pool_pause ldap_int_thread_pool_pause
103 #define ldap_pvt_thread_pool_resume ldap_int_thread_pool_resume
104 #define ldap_pvt_thread_pool_destroy ldap_int_thread_pool_destroy
105 #define ldap_pvt_thread_pool_getkey ldap_int_thread_pool_getkey
106 #define ldap_pvt_thread_pool_setkey ldap_int_thread_pool_setkey
107 #define ldap_pvt_thread_pool_purgekey ldap_int_thread_pool_purgekey
108 #define ldap_pvt_thread_pool_context ldap_int_thread_pool_context
109 #define ldap_pvt_thread_pool_context_reset ldap_int_thread_pool_context_reset
110 #endif /* LDAP_THREAD_POOL_IMPLEMENTATION */
112 #undef _LDAP_PVT_THREAD_H
113 #include "ldap_pvt_thread.h"
115 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c */
117 * tpool.c:ldap_int_thread_pool_shutdown() needs this. Could not
118 * use it for ldap_pvt_thread.h above because of its use of LDAP_P().
120 #undef ldap_pvt_thread_pool_destroy
121 #define ldap_pvt_thread_pool_destroy(p,r) ldap_int_thread_pool_destroy(p,r)
124 #ifdef LDAP_THREAD_DEBUG_IMPLEMENTATION /* thr_debug.c */
125 #undef ldap_pvt_thread_mutex_t
126 #undef ldap_pvt_thread_cond_t
127 #undef ldap_pvt_thread_sleep
128 #undef ldap_pvt_thread_get_concurrency
129 #undef ldap_pvt_thread_set_concurrency
130 #undef ldap_pvt_thread_create
131 #undef ldap_pvt_thread_exit
132 #undef ldap_pvt_thread_join
133 #undef ldap_pvt_thread_kill
134 #undef ldap_pvt_thread_yield
135 #undef ldap_pvt_thread_cond_init
136 #undef ldap_pvt_thread_cond_destroy
137 #undef ldap_pvt_thread_cond_signal
138 #undef ldap_pvt_thread_cond_broadcast
139 #undef ldap_pvt_thread_cond_wait
140 #undef ldap_pvt_thread_mutex_init
141 #undef ldap_pvt_thread_mutex_destroy
142 #undef ldap_pvt_thread_mutex_lock
143 #undef ldap_pvt_thread_mutex_trylock
144 #undef ldap_pvt_thread_mutex_unlock
145 #undef ldap_pvt_thread_self
146 /* LDAP_THREAD_RDWR_IMPLEMENTATION: */
147 #undef ldap_pvt_thread_rdwr_t
148 #undef ldap_pvt_thread_rdwr_init
149 #undef ldap_pvt_thread_rdwr_destroy
150 #undef ldap_pvt_thread_rdwr_rlock
151 #undef ldap_pvt_thread_rdwr_rtrylock
152 #undef ldap_pvt_thread_rdwr_runlock
153 #undef ldap_pvt_thread_rdwr_wlock
154 #undef ldap_pvt_thread_rdwr_wtrylock
155 #undef ldap_pvt_thread_rdwr_wunlock
156 #undef ldap_pvt_thread_rdwr_readers
157 #undef ldap_pvt_thread_rdwr_writers
158 #undef ldap_pvt_thread_rdwr_active
159 /* LDAP_THREAD_POOL_IMPLEMENTATION: */
160 #undef ldap_pvt_thread_pool_t
161 #undef ldap_pvt_thread_pool_init
162 #undef ldap_pvt_thread_pool_submit
163 #undef ldap_pvt_thread_pool_maxthreads
164 #undef ldap_pvt_thread_pool_backload
165 #undef ldap_pvt_thread_pool_pause
166 #undef ldap_pvt_thread_pool_resume
167 #undef ldap_pvt_thread_pool_destroy
168 #undef ldap_pvt_thread_pool_getkey
169 #undef ldap_pvt_thread_pool_setkey
170 #undef ldap_pvt_thread_pool_purgekey
171 #undef ldap_pvt_thread_pool_context
172 #undef ldap_pvt_thread_pool_context_reset
173 #endif /* LDAP_THREAD_DEBUG_IMPLEMENTATION */
175 #endif /* LDAP_THREAD_DEBUG */