18 #ifndef LIBCWD_PRIVATE_STRUCT_TSD_H
19 #define LIBCWD_PRIVATE_STRUCT_TSD_H
21 #ifndef LIBCWD_CONFIG_H
24 #ifndef LIBCWD_PRIVATE_ASSERT_H
27 #ifndef LIBCWD_PRIVATE_MUTEX_INSTANCES_H
34 #ifndef LIBCW_LIMITS_H
35 #define LIBCW_LIMITS_H
38 #if LIBCWD_THREAD_SAFE
40 #ifdef LIBCWD_HAVE_PTHREAD
41 #ifndef LIBCW_PTHREAD_H
42 #define LIBCW_PTHREAD_H
58 #if LIBCWD_THREAD_SAFE
60 #define LIBCWD_TSD __libcwd_tsd
61 #define LIBCWD_COMMA_TSD , LIBCWD_TSD
62 #define LIBCWD_TSD_PARAM ::libcwd::_private_::TSD_st& __libcwd_tsd
64 #define LIBCWD_TSD_PARAM_UNUSED ::libcwd::_private_::TSD_st&
66 #define LIBCWD_COMMA_TSD_PARAM , LIBCWD_TSD_PARAM
67 #define LIBCWD_COMMA_TSD_PARAM_UNUSED , LIBCWD_TSD_PARAM_UNUSED
69 #define LIBCWD_TSD_INSTANCE ::libcwd::_private_::TSD_st::instance()
71 #define LIBCWD_COMMA_TSD_INSTANCE , LIBCWD_TSD_INSTANCE
72 #define LIBCWD_TSD_DECLARATION ::libcwd::_private_::TSD_st& __libcwd_tsd(::libcwd::_private_::TSD_st::instance())
74 #define LIBCWD_DO_TSD(debug_object) (*__libcwd_tsd.do_array[(debug_object).WNS_index])
76 #define LIBCWD_TSD_MEMBER_OFF (__libcwd_tsd.do_off_array[WNS_index])
78 #define LIBCWD_DO_TSD_MEMBER_OFF(debug_object) (__libcwd_tsd.do_off_array[(debug_object).WNS_index])
84 #define LIBCWD_COMMA_TSD
85 #define LIBCWD_TSD_PARAM void
86 #define LIBCWD_TSD_PARAM_UNUSED void
87 #define LIBCWD_COMMA_TSD_PARAM
88 #define LIBCWD_COMMA_TSD_PARAM_UNUSED
89 #define LIBCWD_TSD_INSTANCE
90 #define LIBCWD_COMMA_TSD_INSTANCE
91 #define LIBCWD_TSD_DECLARATION
92 #define LIBCWD_DO_TSD(debug_object) ((debug_object).tsd)
93 #define LIBCWD_TSD_MEMBER_OFF (tsd._off)
94 #define LIBCWD_DO_TSD_MEMBER_OFF(debug_object) ((debug_object).tsd._off)
98 #define LIBCWD_DO_TSD_MEMBER(debug_object, m) (LIBCWD_DO_TSD(debug_object).m)
99 #define LIBCWD_TSD_MEMBER(m) LIBCWD_DO_TSD_MEMBER(*this, m)
102 #ifndef LIBCWD_STRUCT_DEBUG_TSD_H
103 #include "struct_debug_tsd.h"
105 #if LIBCWD_THREAD_SAFE
106 #ifndef LIBCWD_PRIVATE_THREAD_H
122 typedef unsigned short int location_format_t;
127 namespace _private_ {
129 extern int WST_initializing_TSD;
138 int volatile internal;
139 int volatile library_call;
140 int inside_malloc_or_free;
141 int volatile invisible;
144 location_format_t format;
146 #if LIBCWD_THREAD_SAFE
147 threadlist_t::iterator thread_iter;
148 bool thread_iter_valid;
149 thread_ct* target_thread;
151 bool pthread_lock_interface_is_locked;
152 bool list_allocations_on_show_allthreads;
161 bool recursive_fatal;
163 bool recursive_assert;
166 int cancel_explicitely_deferred;
167 int cancel_explicitely_disabled;
168 int inside_critical_area;
169 int cleanup_handler_installed;
170 int internal_debugging_code;
171 mutex_ct* waiting_for_mutex;
172 int waiting_for_lock;
173 int waiting_for_rdlock;
174 int instance_rdlocked[instance_rdlocked_size];
175 pthread_t rdlocked_by1[instance_rdlocked_size];
176 pthread_t rdlocked_by2[instance_rdlocked_size];
177 void const* rdlocked_from1[instance_rdlocked_size];
178 void const* rdlocked_from2[instance_rdlocked_size];
180 #if LIBCWD_THREAD_SAFE
183 int do_off_array[LIBCWD_DO_MAX];
184 debug_tsd_st* do_array[LIBCWD_DO_MAX];
185 void cleanup_routine();
186 int off_cnt_array[LIBCWD_DC_MAX];
188 int tsd_destructor_count;
192 void thread_destructed();
194 #if LIBCWD_THREAD_SAFE
198 static TSD_st& S_create(
int from_free);
199 static pthread_key_t S_tsd_key;
200 static pthread_once_t S_tsd_key_once;
201 static void S_tsd_key_alloc();
202 static void S_cleanup_routine(
void* arg);
205 static TSD_st& instance();
206 static TSD_st& instance_free();
207 static void free_instance(TSD_st&);
214 #if !LIBCWD_THREAD_SAFE
218 extern TSD_st __libcwd_tsd;
220 extern bool WST_tsd_key_created;
226 #if !LIBCWD_THREAD_SAFE
229 using ::libcwd::_private_::__libcwd_tsd;
namespace for libcwd.
Definition: debug.cc:87