Back to index

openldap  2.4.31
ldap_thr_debug.h
Go to the documentation of this file.
00001 /* ldap_thr_debug.h - preprocessor magic for LDAP_THREAD_DEBUG */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 2005-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 
00017 #ifdef LDAP_THREAD_DEBUG
00018 
00019 /*
00020  * libldap_r .c files should include this file after ldap_pvt_thread.h,
00021  * with the appropriate LDAP_THREAD*_IMPLEMENTATION macro(s) defined.
00022  */
00023 
00024 #ifndef _LDAP_PVT_THREAD_H
00025 #error "ldap_pvt_thread.h" must be included before "ldap_thr_debug.h"
00026 #endif
00027 
00028 /*
00029  * Support for thr_debug.c:
00030  *
00031  * thr_debug.c defines ldap_pvt_thread_* as wrappers around the real
00032  * ldap_pvt_thread_* implementation, which this file renames to
00033  * ldap_int_thread_*.
00034  *
00035  * Implementation:
00036  *
00037  * This file re#defines selected ldap_pvt_thread_* names to
00038  * ldap_int_thread_*, which will be used from wrappers in thr_debug.c.
00039  * Two ldap_int_*() calls are redirected to call ldap_debug_*(): These
00040  * are wrappers around the originals, whose definitions are not renamed.
00041  * This file then #includes ldap_pvt_thread.h to declare the renamed
00042  * functions/types.  If #included from thr_debug.c it finally #undefines
00043  * the macros again.
00044  *
00045  * include/ldap_pvt_thread.h declares the typedefs ldap_pvt_thread*_t as
00046  * either wrapper types ldap_debug_thread*_t or their usual definitions
00047  * ldap_int_thread*_t, depending on the LDAP_THREAD_DEBUG_WRAP option.
00048  * When defining the underlying implementation, this file then redirects
00049  * the type names back to the original ldap_int_thread*_t types.
00050  * include/ldap_<int,pvt>_thread.h also do some thr_debug magic.
00051  *
00052  * So,
00053  * libldap_r/<not thr_debug.c> thus define ldap_int_thread_*() instead
00054  * of ldap_pvt_thread_*().
00055  * thr_debug.c defines the ldap_pvt_*() and ldap_debug_*() functions.
00056  * In thread.c, ldap_pvt_thread_<initialize/destroy>() will call
00057  * ldap_debug_thread_*() instead of ldap_int_thread_*().
00058  * In tpool.c, ldap_int_thread_pool_shutdown() has explicit thr_debug.c
00059  * support which treats ldap_pvt_thread_pool_destroy() the same way.
00060  */
00061 
00062 #ifndef LDAP_THREAD_IMPLEMENTATION        /* for first part of threads.c */
00063 #define       ldap_int_thread_initialize         ldap_debug_thread_initialize
00064 #define       ldap_int_thread_destroy                   ldap_debug_thread_destroy
00065 #else /* LDAP_THREAD_IMPLEMENTATION       -- for thr_*.c and end of threads.c */
00066 #undef ldap_int_thread_initialize
00067 #undef ldap_int_thread_destroy
00068 #ifdef LDAP_THREAD_DEBUG_WRAP                    /* see ldap_pvt_thread.h */
00069 #define       ldap_pvt_thread_mutex_t                   ldap_int_thread_mutex_t
00070 #define       ldap_pvt_thread_cond_t                    ldap_int_thread_cond_t
00071 #endif
00072 #define       ldap_pvt_thread_sleep                     ldap_int_thread_sleep
00073 #define       ldap_pvt_thread_get_concurrency    ldap_int_thread_get_concurrency
00074 #define       ldap_pvt_thread_set_concurrency    ldap_int_thread_set_concurrency
00075 #define       ldap_pvt_thread_create                    ldap_int_thread_create
00076 #define       ldap_pvt_thread_exit               ldap_int_thread_exit
00077 #define       ldap_pvt_thread_join               ldap_int_thread_join
00078 #define       ldap_pvt_thread_kill               ldap_int_thread_kill
00079 #define       ldap_pvt_thread_yield                     ldap_int_thread_yield
00080 #define       ldap_pvt_thread_cond_init          ldap_int_thread_cond_init
00081 #define       ldap_pvt_thread_cond_destroy       ldap_int_thread_cond_destroy
00082 #define       ldap_pvt_thread_cond_signal        ldap_int_thread_cond_signal
00083 #define       ldap_pvt_thread_cond_broadcast     ldap_int_thread_cond_broadcast
00084 #define       ldap_pvt_thread_cond_wait          ldap_int_thread_cond_wait
00085 #define       ldap_pvt_thread_mutex_init         ldap_int_thread_mutex_init
00086 #define       ldap_pvt_thread_mutex_destroy      ldap_int_thread_mutex_destroy
00087 #define       ldap_pvt_thread_mutex_lock         ldap_int_thread_mutex_lock
00088 #define       ldap_pvt_thread_mutex_trylock      ldap_int_thread_mutex_trylock
00089 #define       ldap_pvt_thread_mutex_unlock       ldap_int_thread_mutex_unlock
00090 #define       ldap_pvt_thread_self               ldap_int_thread_self
00091 #endif /* LDAP_THREAD_IMPLEMENTATION */
00092 
00093 #ifdef LDAP_THREAD_RDWR_IMPLEMENTATION    /* rdwr.c, thr_debug.c */
00094 #ifdef LDAP_THREAD_DEBUG_WRAP                    /* see ldap_pvt_thread.h */
00095 #define       ldap_pvt_thread_rdwr_t                    ldap_int_thread_rdwr_t
00096 #endif
00097 #define       ldap_pvt_thread_rdwr_init          ldap_int_thread_rdwr_init
00098 #define       ldap_pvt_thread_rdwr_destroy       ldap_int_thread_rdwr_destroy
00099 #define       ldap_pvt_thread_rdwr_rlock         ldap_int_thread_rdwr_rlock
00100 #define       ldap_pvt_thread_rdwr_rtrylock      ldap_int_thread_rdwr_rtrylock
00101 #define       ldap_pvt_thread_rdwr_runlock       ldap_int_thread_rdwr_runlock
00102 #define       ldap_pvt_thread_rdwr_wlock         ldap_int_thread_rdwr_wlock
00103 #define       ldap_pvt_thread_rdwr_wtrylock      ldap_int_thread_rdwr_wtrylock
00104 #define       ldap_pvt_thread_rdwr_wunlock       ldap_int_thread_rdwr_wunlock
00105 #define       ldap_pvt_thread_rdwr_readers       ldap_int_thread_rdwr_readers
00106 #define       ldap_pvt_thread_rdwr_writers       ldap_int_thread_rdwr_writers
00107 #define       ldap_pvt_thread_rdwr_active        ldap_int_thread_rdwr_active
00108 #endif /* LDAP_THREAD_RDWR_IMPLEMENTATION */
00109 
00110 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION    /* tpool.c, thr_stub.c, thr_debug.c */
00111 #ifdef LDAP_THREAD_DEBUG_WRAP                    /* see ldap_pvt_thread.h */
00112 #define       ldap_pvt_thread_pool_t                    ldap_int_thread_pool_t
00113 #endif
00114 #define       ldap_pvt_thread_pool_init          ldap_int_thread_pool_init
00115 #define       ldap_pvt_thread_pool_submit        ldap_int_thread_pool_submit
00116 #define       ldap_pvt_thread_pool_maxthreads    ldap_int_thread_pool_maxthreads
00117 #define       ldap_pvt_thread_pool_backload      ldap_int_thread_pool_backload
00118 #define       ldap_pvt_thread_pool_pause         ldap_int_thread_pool_pause
00119 #define       ldap_pvt_thread_pool_resume        ldap_int_thread_pool_resume
00120 #define       ldap_pvt_thread_pool_destroy       ldap_int_thread_pool_destroy
00121 #define       ldap_pvt_thread_pool_getkey        ldap_int_thread_pool_getkey
00122 #define       ldap_pvt_thread_pool_setkey ldap_int_thread_pool_setkey
00123 #define       ldap_pvt_thread_pool_purgekey      ldap_int_thread_pool_purgekey
00124 #define       ldap_pvt_thread_pool_context       ldap_int_thread_pool_context
00125 #define       ldap_pvt_thread_pool_context_reset ldap_int_thread_pool_context_reset
00126 #endif /* LDAP_THREAD_POOL_IMPLEMENTATION */
00127 
00128 #undef _LDAP_PVT_THREAD_H
00129 #include "ldap_pvt_thread.h"
00130 
00131 #ifdef LDAP_THREAD_POOL_IMPLEMENTATION    /* tpool.c */
00132 /*
00133  * tpool.c:ldap_int_thread_pool_shutdown() needs this.  Could not
00134  * use it for ldap_pvt_thread.h above because of its use of LDAP_P().
00135  */
00136 #undef ldap_pvt_thread_pool_destroy
00137 #define       ldap_pvt_thread_pool_destroy(p,r) ldap_int_thread_pool_destroy(p,r)
00138 #endif
00139 
00140 #ifdef LDAP_THREAD_DEBUG_IMPLEMENTATION   /* thr_debug.c */
00141 #undef ldap_pvt_thread_mutex_t
00142 #undef ldap_pvt_thread_cond_t
00143 #undef ldap_pvt_thread_sleep
00144 #undef ldap_pvt_thread_get_concurrency
00145 #undef ldap_pvt_thread_set_concurrency
00146 #undef ldap_pvt_thread_create
00147 #undef ldap_pvt_thread_exit
00148 #undef ldap_pvt_thread_join
00149 #undef ldap_pvt_thread_kill
00150 #undef ldap_pvt_thread_yield
00151 #undef ldap_pvt_thread_cond_init
00152 #undef ldap_pvt_thread_cond_destroy
00153 #undef ldap_pvt_thread_cond_signal
00154 #undef ldap_pvt_thread_cond_broadcast
00155 #undef ldap_pvt_thread_cond_wait
00156 #undef ldap_pvt_thread_mutex_init
00157 #undef ldap_pvt_thread_mutex_destroy
00158 #undef ldap_pvt_thread_mutex_lock
00159 #undef ldap_pvt_thread_mutex_trylock
00160 #undef ldap_pvt_thread_mutex_unlock
00161 #undef ldap_pvt_thread_self
00162 /* LDAP_THREAD_RDWR_IMPLEMENTATION: */
00163 #undef ldap_pvt_thread_rdwr_t
00164 #undef ldap_pvt_thread_rdwr_init
00165 #undef ldap_pvt_thread_rdwr_destroy
00166 #undef ldap_pvt_thread_rdwr_rlock
00167 #undef ldap_pvt_thread_rdwr_rtrylock
00168 #undef ldap_pvt_thread_rdwr_runlock
00169 #undef ldap_pvt_thread_rdwr_wlock
00170 #undef ldap_pvt_thread_rdwr_wtrylock
00171 #undef ldap_pvt_thread_rdwr_wunlock
00172 #undef ldap_pvt_thread_rdwr_readers
00173 #undef ldap_pvt_thread_rdwr_writers
00174 #undef ldap_pvt_thread_rdwr_active
00175 /* LDAP_THREAD_POOL_IMPLEMENTATION: */
00176 #undef ldap_pvt_thread_pool_t
00177 #undef ldap_pvt_thread_pool_init
00178 #undef ldap_pvt_thread_pool_submit
00179 #undef ldap_pvt_thread_pool_maxthreads
00180 #undef ldap_pvt_thread_pool_backload
00181 #undef ldap_pvt_thread_pool_pause
00182 #undef ldap_pvt_thread_pool_resume
00183 #undef ldap_pvt_thread_pool_destroy
00184 #undef ldap_pvt_thread_pool_getkey
00185 #undef ldap_pvt_thread_pool_setkey
00186 #undef ldap_pvt_thread_pool_purgekey
00187 #undef ldap_pvt_thread_pool_context
00188 #undef ldap_pvt_thread_pool_context_reset
00189 #endif /* LDAP_THREAD_DEBUG_IMPLEMENTATION */
00190 
00191 #endif /* LDAP_THREAD_DEBUG */