1 /* $NetBSD: ldap_thr_debug.h,v 1.2 2021/08/14 16:14:56 christos Exp $ */ 2 3 /* ldap_thr_debug.h - preprocessor magic for LDAP_THREAD_DEBUG */ 4 /* $OpenLDAP$ */ 5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 2005-2021 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18 19 #ifdef LDAP_THREAD_DEBUG 20 21 /* 22 * libldap .c files should include this file after ldap_pvt_thread.h, 23 * with the appropriate LDAP_THREAD*_IMPLEMENTATION macro(s) defined. 24 */ 25 26 #ifndef _LDAP_PVT_THREAD_H 27 #error "ldap_pvt_thread.h" must be included before "ldap_thr_debug.h" 28 #endif 29 30 /* 31 * Support for thr_debug.c: 32 * 33 * thr_debug.c defines ldap_pvt_thread_* as wrappers around the real 34 * ldap_pvt_thread_* implementation, which this file renames to 35 * ldap_int_thread_*. 36 * 37 * Implementation: 38 * 39 * This file re#defines selected ldap_pvt_thread_* names to 40 * ldap_int_thread_*, which will be used from wrappers in thr_debug.c. 41 * Two ldap_int_*() calls are redirected to call ldap_debug_*(): These 42 * are wrappers around the originals, whose definitions are not renamed. 43 * This file then #includes ldap_pvt_thread.h to declare the renamed 44 * functions/types. If #included from thr_debug.c it finally #undefines 45 * the macros again. 46 * 47 * include/ldap_pvt_thread.h declares the typedefs ldap_pvt_thread*_t as 48 * either wrapper types ldap_debug_thread*_t or their usual definitions 49 * ldap_int_thread*_t, depending on the LDAP_THREAD_DEBUG_WRAP option. 50 * When defining the underlying implementation, this file then redirects 51 * the type names back to the original ldap_int_thread*_t types. 52 * include/ldap_<int,pvt>_thread.h also do some thr_debug magic. 53 * 54 * So, 55 * libldap/<not thr_debug.c> thus define ldap_int_thread_*() instead 56 * of ldap_pvt_thread_*(). 57 * thr_debug.c defines the ldap_pvt_*() and ldap_debug_*() functions. 58 * In thread.c, ldap_pvt_thread_<initialize/destroy>() will call 59 * ldap_debug_thread_*() instead of ldap_int_thread_*(). 60 * In tpool.c, ldap_int_thread_pool_shutdown() has explicit thr_debug.c 61 * support which treats ldap_pvt_thread_pool_destroy() the same way. 62 */ 63 64 #ifndef LDAP_THREAD_IMPLEMENTATION /* for first part of threads.c */ 65 #define ldap_int_thread_initialize ldap_debug_thread_initialize 66 #define ldap_int_thread_destroy ldap_debug_thread_destroy 67 #else /* LDAP_THREAD_IMPLEMENTATION -- for thr_*.c and end of threads.c */ 68 #undef ldap_int_thread_initialize 69 #undef ldap_int_thread_destroy 70 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */ 71 #define ldap_pvt_thread_mutex_t ldap_int_thread_mutex_t 72 #define ldap_pvt_thread_cond_t ldap_int_thread_cond_t 73 #endif 74 #define ldap_pvt_thread_sleep ldap_int_thread_sleep 75 #define ldap_pvt_thread_get_concurrency ldap_int_thread_get_concurrency 76 #define ldap_pvt_thread_set_concurrency ldap_int_thread_set_concurrency 77 #define ldap_pvt_thread_create ldap_int_thread_create 78 #define ldap_pvt_thread_exit ldap_int_thread_exit 79 #define ldap_pvt_thread_join ldap_int_thread_join 80 #define ldap_pvt_thread_kill ldap_int_thread_kill 81 #define ldap_pvt_thread_yield ldap_int_thread_yield 82 #define ldap_pvt_thread_cond_init ldap_int_thread_cond_init 83 #define ldap_pvt_thread_cond_destroy ldap_int_thread_cond_destroy 84 #define ldap_pvt_thread_cond_signal ldap_int_thread_cond_signal 85 #define ldap_pvt_thread_cond_broadcast ldap_int_thread_cond_broadcast 86 #define ldap_pvt_thread_cond_wait ldap_int_thread_cond_wait 87 #define ldap_pvt_thread_mutex_init ldap_int_thread_mutex_init 88 #define ldap_pvt_thread_mutex_recursive_init ldap_int_thread_mutex_recursive_init 89 #define ldap_pvt_thread_mutex_destroy ldap_int_thread_mutex_destroy 90 #define ldap_pvt_thread_mutex_lock ldap_int_thread_mutex_lock 91 #define ldap_pvt_thread_mutex_trylock ldap_int_thread_mutex_trylock 92 #define ldap_pvt_thread_mutex_unlock ldap_int_thread_mutex_unlock 93 #define ldap_pvt_thread_self ldap_int_thread_self 94 #endif /* LDAP_THREAD_IMPLEMENTATION */ 95 96 #ifdef LDAP_THREAD_RDWR_IMPLEMENTATION /* rdwr.c, thr_debug.c */ 97 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */ 98 #define ldap_pvt_thread_rdwr_t ldap_int_thread_rdwr_t 99 #endif 100 #define ldap_pvt_thread_rdwr_init ldap_int_thread_rdwr_init 101 #define ldap_pvt_thread_rdwr_destroy ldap_int_thread_rdwr_destroy 102 #define ldap_pvt_thread_rdwr_rlock ldap_int_thread_rdwr_rlock 103 #define ldap_pvt_thread_rdwr_rtrylock ldap_int_thread_rdwr_rtrylock 104 #define ldap_pvt_thread_rdwr_runlock ldap_int_thread_rdwr_runlock 105 #define ldap_pvt_thread_rdwr_wlock ldap_int_thread_rdwr_wlock 106 #define ldap_pvt_thread_rdwr_wtrylock ldap_int_thread_rdwr_wtrylock 107 #define ldap_pvt_thread_rdwr_wunlock ldap_int_thread_rdwr_wunlock 108 #define ldap_pvt_thread_rdwr_readers ldap_int_thread_rdwr_readers 109 #define ldap_pvt_thread_rdwr_writers ldap_int_thread_rdwr_writers 110 #define ldap_pvt_thread_rdwr_active ldap_int_thread_rdwr_active 111 #endif /* LDAP_THREAD_RDWR_IMPLEMENTATION */ 112 113 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c, thr_debug.c */ 114 #ifdef LDAP_THREAD_DEBUG_WRAP /* see ldap_pvt_thread.h */ 115 #define ldap_pvt_thread_pool_t ldap_int_thread_pool_t 116 #endif 117 #define ldap_pvt_thread_pool_init ldap_int_thread_pool_init 118 #define ldap_pvt_thread_pool_submit ldap_int_thread_pool_submit 119 #define ldap_pvt_thread_pool_maxthreads ldap_int_thread_pool_maxthreads 120 #define ldap_pvt_thread_pool_backload ldap_int_thread_pool_backload 121 #define ldap_pvt_thread_pool_pause ldap_int_thread_pool_pause 122 #define ldap_pvt_thread_pool_resume ldap_int_thread_pool_resume 123 #define ldap_pvt_thread_pool_destroy ldap_int_thread_pool_destroy 124 #define ldap_pvt_thread_pool_close ldap_int_thread_pool_close 125 #define ldap_pvt_thread_pool_free ldap_int_thread_pool_free 126 #define ldap_pvt_thread_pool_getkey ldap_int_thread_pool_getkey 127 #define ldap_pvt_thread_pool_setkey ldap_int_thread_pool_setkey 128 #define ldap_pvt_thread_pool_purgekey ldap_int_thread_pool_purgekey 129 #define ldap_pvt_thread_pool_context ldap_int_thread_pool_context 130 #define ldap_pvt_thread_pool_context_reset ldap_int_thread_pool_context_reset 131 #endif /* LDAP_THREAD_POOL_IMPLEMENTATION */ 132 133 #undef _LDAP_PVT_THREAD_H 134 #include "ldap_pvt_thread.h" 135 136 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION /* tpool.c */ 137 /* 138 * tpool.c:ldap_int_thread_pool_shutdown() needs this. Could not 139 * use it for ldap_pvt_thread.h above because of its use of LDAP_P(). 140 */ 141 #undef ldap_pvt_thread_pool_destroy 142 #define ldap_pvt_thread_pool_destroy(p,r) ldap_int_thread_pool_destroy(p,r) 143 #endif 144 145 #ifdef LDAP_THREAD_DEBUG_IMPLEMENTATION /* thr_debug.c */ 146 #undef ldap_pvt_thread_mutex_t 147 #undef ldap_pvt_thread_cond_t 148 #undef ldap_pvt_thread_sleep 149 #undef ldap_pvt_thread_get_concurrency 150 #undef ldap_pvt_thread_set_concurrency 151 #undef ldap_pvt_thread_create 152 #undef ldap_pvt_thread_exit 153 #undef ldap_pvt_thread_join 154 #undef ldap_pvt_thread_kill 155 #undef ldap_pvt_thread_yield 156 #undef ldap_pvt_thread_cond_init 157 #undef ldap_pvt_thread_cond_destroy 158 #undef ldap_pvt_thread_cond_signal 159 #undef ldap_pvt_thread_cond_broadcast 160 #undef ldap_pvt_thread_cond_wait 161 #undef ldap_pvt_thread_mutex_init 162 #undef ldap_pvt_thread_mutex_recursive_init 163 #undef ldap_pvt_thread_mutex_destroy 164 #undef ldap_pvt_thread_mutex_lock 165 #undef ldap_pvt_thread_mutex_trylock 166 #undef ldap_pvt_thread_mutex_unlock 167 #undef ldap_pvt_thread_self 168 /* LDAP_THREAD_RDWR_IMPLEMENTATION: */ 169 #undef ldap_pvt_thread_rdwr_t 170 #undef ldap_pvt_thread_rdwr_init 171 #undef ldap_pvt_thread_rdwr_destroy 172 #undef ldap_pvt_thread_rdwr_rlock 173 #undef ldap_pvt_thread_rdwr_rtrylock 174 #undef ldap_pvt_thread_rdwr_runlock 175 #undef ldap_pvt_thread_rdwr_wlock 176 #undef ldap_pvt_thread_rdwr_wtrylock 177 #undef ldap_pvt_thread_rdwr_wunlock 178 #undef ldap_pvt_thread_rdwr_readers 179 #undef ldap_pvt_thread_rdwr_writers 180 #undef ldap_pvt_thread_rdwr_active 181 /* LDAP_THREAD_POOL_IMPLEMENTATION: */ 182 #undef ldap_pvt_thread_pool_t 183 #undef ldap_pvt_thread_pool_init 184 #undef ldap_pvt_thread_pool_submit 185 #undef ldap_pvt_thread_pool_maxthreads 186 #undef ldap_pvt_thread_pool_backload 187 #undef ldap_pvt_thread_pool_pause 188 #undef ldap_pvt_thread_pool_resume 189 #undef ldap_pvt_thread_pool_destroy 190 #undef ldap_pvt_thread_pool_close 191 #undef ldap_pvt_thread_pool_free 192 #undef ldap_pvt_thread_pool_getkey 193 #undef ldap_pvt_thread_pool_setkey 194 #undef ldap_pvt_thread_pool_purgekey 195 #undef ldap_pvt_thread_pool_context 196 #undef ldap_pvt_thread_pool_context_reset 197 #endif /* LDAP_THREAD_DEBUG_IMPLEMENTATION */ 198 199 #endif /* LDAP_THREAD_DEBUG */ 200