21 #include "my_global.h"
24 #define ETIME ETIMEDOUT
28 #define EXTERNC extern "C"
35 typedef CRITICAL_SECTION pthread_mutex_t;
36 typedef DWORD pthread_t;
37 typedef struct thread_attr {
39 DWORD dwCreatingFlag ;
42 typedef struct {
int dummy; } pthread_condattr_t;
46 typedef struct st_pthread_link {
48 struct st_pthread_link *next;
59 CONDITION_VARIABLE native_cond;
65 CRITICAL_SECTION lock_waiting;
72 HANDLE events[MAX_EVENTS];
73 HANDLE broadcast_block_event;
78 typedef int pthread_mutexattr_t;
79 #define pthread_self() GetCurrentThreadId()
80 #define pthread_handler_t EXTERNC void * __cdecl
81 typedef void * (__cdecl *pthread_handler)(
void *);
83 typedef volatile LONG my_pthread_once_t;
84 #define MY_PTHREAD_ONCE_INIT 0
85 #define MY_PTHREAD_ONCE_INPROGRESS 1
86 #define MY_PTHREAD_ONCE_DONE 2
105 long max_timeout_msec;
107 #define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \
108 (ABSTIME).tv.i64= (TIME)+(__int64)(NSEC)/100; \
109 (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \
112 #define set_timespec_nsec(ABSTIME,NSEC) do { \
114 GetSystemTimeAsFileTime(&tv.ft); \
115 set_timespec_time_nsec((ABSTIME), tv.i64, (NSEC)); \
127 #define cmp_timespec(TS1, TS2) \
128 ((TS1.tv.i64 > TS2.tv.i64) ? 1 : \
129 ((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0))
131 #define diff_timespec(TS1, TS2) \
132 ((TS1.tv.i64 - TS2.tv.i64) * 100)
134 int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
135 int pthread_create(pthread_t *,
const pthread_attr_t *, pthread_handler,
void *);
136 int pthread_cond_init(pthread_cond_t *cond,
const pthread_condattr_t *attr);
137 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
138 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
140 int pthread_cond_signal(pthread_cond_t *cond);
141 int pthread_cond_broadcast(pthread_cond_t *cond);
142 int pthread_cond_destroy(pthread_cond_t *cond);
143 int pthread_attr_init(pthread_attr_t *connect_att);
144 int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
145 int pthread_attr_destroy(pthread_attr_t *connect_att);
146 int my_pthread_once(my_pthread_once_t *once_control,
void (*init_routine)(
void));
147 struct tm *localtime_r(
const time_t *timep,
struct tm *tmp);
148 struct tm *gmtime_r(
const time_t *timep,
struct tm *tmp);
150 void pthread_exit(
void *a);
151 int pthread_join(pthread_t thread,
void **value_ptr);
152 int pthread_cancel(pthread_t thread);
155 #define ETIMEDOUT 145
157 #define HAVE_LOCALTIME_R 1
159 #define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
163 #define pthread_key(T,V) DWORD V
164 #define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
165 #define pthread_key_delete(A) TlsFree(A)
166 #define my_pthread_setspecific_ptr(T,V) (!TlsSetValue((T),(V)))
167 #define pthread_setspecific(A,B) (!TlsSetValue((A),(B)))
168 #define pthread_getspecific(A) (TlsGetValue(A))
169 #define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
170 #define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(V))
172 #define pthread_equal(A,B) ((A) == (B))
173 #define pthread_mutex_init(A,B) (InitializeCriticalSection(A),0)
174 #define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
175 #define pthread_mutex_trylock(A) win_pthread_mutex_trylock((A))
176 #define pthread_mutex_unlock(A) (LeaveCriticalSection(A), 0)
177 #define pthread_mutex_destroy(A) (DeleteCriticalSection(A), 0)
178 #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
182 #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
183 #define pthread_attr_setscope(A,B)
184 #define pthread_detach_this_thread()
185 #define pthread_condattr_init(A)
186 #define pthread_condattr_destroy(A)
187 #define pthread_yield() SwitchToThread()
188 #define my_sigset(A,B) signal(A,B)
192 #ifdef HAVE_rts_threads
193 #define sigwait org_sigwait
201 #ifdef HAVE_THR_SETCONCURRENCY
211 #define pthread_key(T,V) pthread_key_t V
212 #define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
213 #define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
214 #define pthread_detach_this_thread()
215 #define pthread_handler_t EXTERNC void *
216 typedef void *(* pthread_handler)(
void *);
218 #define my_pthread_once_t pthread_once_t
219 #if defined(PTHREAD_ONCE_INITIALIZER)
220 #define MY_PTHREAD_ONCE_INIT PTHREAD_ONCE_INITIALIZER
222 #define MY_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT
224 #define my_pthread_once(C,F) pthread_once(C,F)
228 #if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
229 #define HAVE_rts_threads
230 extern int my_pthread_create_detached;
231 #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
232 #define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
233 #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
234 #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
235 #define USE_ALARM_THREAD
238 #if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
239 int sigwait(sigset_t *
set,
int *sig);
242 #ifndef HAVE_NONPOSIX_SIGWAIT
243 #define my_sigwait(A,B) sigwait((A),(B))
245 int my_sigwait(
const sigset_t *
set,
int *sig);
248 #ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
250 #define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
251 extern int my_pthread_mutex_init(pthread_mutex_t *mp,
252 const pthread_mutexattr_t *attr);
254 #define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
255 extern int my_pthread_cond_init(pthread_cond_t *mp,
256 const pthread_condattr_t *attr);
259 #if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
260 #define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
263 #if !defined(HAVE_SIGWAIT) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
264 int sigwait(sigset_t *setp,
int *sigp);
274 #if defined(HAVE_SIGACTION) && !defined(my_sigset)
275 #define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; \
276 DBUG_ASSERT((A) != 0); \
277 sigemptyset(&l_set); \
278 l_s.sa_handler = (B); \
279 l_s.sa_mask = l_set; \
281 sigaction((A), &l_s, NULL); \
283 #elif defined(HAVE_SIGSET) && !defined(my_sigset)
284 #define my_sigset(A,B) sigset((A),(B))
285 #elif !defined(my_sigset)
286 #define my_sigset(A,B) signal((A),(B))
289 #if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
290 #define pthread_attr_setscope(A,B)
291 #undef HAVE_GETHOSTBYADDR_R
294 #if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX)
295 extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
296 pthread_mutex_t *mutex,
298 #define pthread_cond_timedwait(A,B,C) my_pthread_cond_timedwait((A),(B),(C))
301 #if !defined( HAVE_NONPOSIX_PTHREAD_GETSPECIFIC)
302 #define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
304 #define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
305 void *my_pthread_getspecific_imp(pthread_key_t key);
308 #ifndef HAVE_LOCALTIME_R
309 struct tm *localtime_r(
const time_t *clock,
struct tm *res);
312 #ifndef HAVE_GMTIME_R
313 struct tm *gmtime_r(
const time_t *clock,
struct tm *res);
316 #ifdef HAVE_PTHREAD_CONDATTR_CREATE
318 #define pthread_condattr_init pthread_condattr_create
319 #define pthread_condattr_destroy pthread_condattr_delete
323 #if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete)
324 #define pthread_key_delete(A) pthread_dummy(0)
327 #ifdef HAVE_CTHREADS_WRAPPER
328 #define pthread_cond_destroy(A) pthread_dummy(0)
329 #define pthread_mutex_destroy(A) pthread_dummy(0)
330 #define pthread_attr_delete(A) pthread_dummy(0)
331 #define pthread_condattr_delete(A) pthread_dummy(0)
332 #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
333 #define pthread_equal(A,B) ((A) == (B))
334 #define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
335 #define pthread_attr_init(A) pthread_attr_create(A)
336 #define pthread_attr_destroy(A) pthread_attr_delete(A)
337 #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
338 #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
339 #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
340 #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
341 #undef pthread_detach_this_thread
342 #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
345 #ifdef HAVE_DARWIN5_THREADS
346 #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
347 #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
348 #define pthread_condattr_init(A) pthread_dummy(0)
349 #define pthread_condattr_destroy(A) pthread_dummy(0)
350 #undef pthread_detach_this_thread
351 #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(tmp); }
354 #if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
356 #define pthread_key_create(A,B) \
357 pthread_keycreate(A,(B) ?\
358 (pthread_destructor_t) (B) :\
359 (pthread_destructor_t) pthread_dummy)
360 #define pthread_attr_init(A) pthread_attr_create(A)
361 #define pthread_attr_destroy(A) pthread_attr_delete(A)
362 #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
363 #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
364 #ifndef pthread_sigmask
365 #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
367 #define pthread_kill(A,B) pthread_dummy((A) ? 0 : ESRCH)
368 #undef pthread_detach_this_thread
369 #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
371 #define HAVE_PTHREAD_KILL
376 #if defined(HPUX10) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
377 #undef pthread_cond_timedwait
378 #define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
379 int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
384 #define pthread_attr_getstacksize(A,B) my_pthread_attr_getstacksize(A,B)
385 void my_pthread_attr_getstacksize(pthread_attr_t *attrib,
size_t *
size);
388 #if defined(HAVE_POSIX1003_4a_MUTEX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
389 #undef pthread_mutex_trylock
390 #define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
391 int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
394 #if !defined(HAVE_PTHREAD_YIELD_ONE_ARG) && !defined(HAVE_PTHREAD_YIELD_ZERO_ARG)
396 #ifdef HAVE_SCHED_YIELD
397 #define pthread_yield() sched_yield()
398 #elif defined(HAVE_PTHREAD_YIELD_NP)
399 #define pthread_yield() pthread_yield_np()
400 #elif defined(HAVE_THR_YIELD)
401 #define pthread_yield() thr_yield()
410 #define set_timespec(ABSTIME,SEC) set_timespec_nsec((ABSTIME),(SEC)*1000000000ULL)
412 #ifndef set_timespec_nsec
413 #define set_timespec_nsec(ABSTIME,NSEC) \
414 set_timespec_time_nsec((ABSTIME),my_getsystime(),(NSEC))
418 #ifdef HAVE_TIMESPEC_TS_SEC
419 #define MY_tv_sec ts_sec
420 #define MY_tv_nsec ts_nsec
422 #define MY_tv_sec tv_sec
423 #define MY_tv_nsec tv_nsec
426 #ifndef set_timespec_time_nsec
427 #define set_timespec_time_nsec(ABSTIME,TIME,NSEC) do { \
428 ulonglong nsec= (NSEC); \
429 ulonglong now= (TIME) + (nsec/100); \
430 (ABSTIME).MY_tv_sec= (now / 10000000ULL); \
431 (ABSTIME).MY_tv_nsec= (now % 10000000ULL * 100 + (nsec % 100)); \
444 #ifdef HAVE_TIMESPEC_TS_SEC
446 #define cmp_timespec(TS1, TS2) \
447 ((TS1.ts_sec > TS2.ts_sec || \
448 (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec > TS2.ts_nsec)) ? 1 : \
449 ((TS1.ts_sec < TS2.ts_sec || \
450 (TS1.ts_sec == TS2.ts_sec && TS1.ts_nsec < TS2.ts_nsec)) ? -1 : 0))
454 #define cmp_timespec(TS1, TS2) \
455 ((TS1.tv_sec > TS2.tv_sec || \
456 (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec > TS2.tv_nsec)) ? 1 : \
457 ((TS1.tv_sec < TS2.tv_sec || \
458 (TS1.tv_sec == TS2.tv_sec && TS1.tv_nsec < TS2.tv_nsec)) ? -1 : 0))
462 #ifdef HAVE_TIMESPEC_TS_SEC
463 #ifndef diff_timespec
464 #define diff_timespec(TS1, TS2) \
465 ((TS1.ts_sec - TS2.ts_sec) * 1000000000ULL + TS1.ts_nsec - TS2.ts_nsec)
468 #ifndef diff_timespec
469 #define diff_timespec(TS1, TS2) \
470 ((TS1.tv_sec - TS2.tv_sec) * 1000000000ULL + TS1.tv_nsec - TS2.tv_nsec)
478 pthread_mutex_t global,mutex;
482 #ifdef SAFE_MUTEX_DETECT_DESTROY
483 struct st_safe_mutex_info_t *info;
487 #ifdef SAFE_MUTEX_DETECT_DESTROY
494 typedef struct st_safe_mutex_info_t
496 struct st_safe_mutex_info_t *next;
497 struct st_safe_mutex_info_t *prev;
498 const char *init_file;
503 int safe_mutex_init(
safe_mutex_t *mp,
const pthread_mutexattr_t *attr,
504 const char *
file, uint line);
505 int safe_mutex_lock(
safe_mutex_t *mp, my_bool try_lock,
const char *
file, uint line);
510 int safe_cond_timedwait(pthread_cond_t *cond,
safe_mutex_t *mp,
512 const char *
file, uint line);
513 void safe_mutex_global_init(
void);
514 void safe_mutex_end(FILE *
file);
518 #define safe_mutex_assert_owner(mp) \
519 DBUG_ASSERT((mp)->count > 0 && \
520 pthread_equal(pthread_self(), (mp)->thread))
521 #define safe_mutex_assert_not_owner(mp) \
522 DBUG_ASSERT(! (mp)->count || \
523 ! pthread_equal(pthread_self(), (mp)->thread))
525 #define my_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
526 #define my_cond_wait(A,B) safe_cond_wait((A), (B), __FILE__, __LINE__)
528 #elif defined(MY_PTHREAD_FASTMUTEX)
530 #define safe_mutex_assert_owner(mp) do {} while (0)
531 #define safe_mutex_assert_not_owner(mp) do {} while (0)
533 #define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A), &(B)->mutex, (C))
534 #define my_cond_wait(A,B) pthread_cond_wait((A), &(B)->mutex)
538 #define safe_mutex_assert_owner(mp) do {} while (0)
539 #define safe_mutex_assert_not_owner(mp) do {} while (0)
541 #define my_cond_timedwait(A,B,C) pthread_cond_timedwait((A),(B),(C))
542 #define my_cond_wait(A,B) pthread_cond_wait((A), (B))
546 #if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
547 typedef struct st_my_pthread_fastmutex_t
549 pthread_mutex_t mutex;
552 } my_pthread_fastmutex_t;
553 void fastmutex_global_init(
void);
555 int my_pthread_fastmutex_init(my_pthread_fastmutex_t *mp,
556 const pthread_mutexattr_t *attr);
557 int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp);
563 #ifdef HAVE_BROKEN_RWLOCK
564 #undef HAVE_PTHREAD_RWLOCK_RDLOCK
565 #undef HAVE_RWLOCK_INIT
569 #if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
571 #define rw_lock_t pthread_mutex_t
572 #define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
573 #define rw_rdlock(A) pthread_mutex_lock((A))
574 #define rw_wrlock(A) pthread_mutex_lock((A))
575 #define rw_tryrdlock(A) pthread_mutex_trylock((A))
576 #define rw_trywrlock(A) pthread_mutex_trylock((A))
577 #define rw_unlock(A) pthread_mutex_unlock((A))
578 #define rwlock_destroy(A) pthread_mutex_destroy((A))
579 #elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
580 #define rw_lock_t pthread_rwlock_t
581 #define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
582 #define rw_rdlock(A) pthread_rwlock_rdlock(A)
583 #define rw_wrlock(A) pthread_rwlock_wrlock(A)
584 #define rw_tryrdlock(A) pthread_rwlock_tryrdlock((A))
585 #define rw_trywrlock(A) pthread_rwlock_trywrlock((A))
586 #define rw_unlock(A) pthread_rwlock_unlock(A)
587 #define rwlock_destroy(A) pthread_rwlock_destroy(A)
588 #elif defined(HAVE_RWLOCK_INIT)
590 #define rw_lock_t rwlock_t
592 #define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
595 #define NEED_MY_RW_LOCK 1
596 #define rw_lock_t my_rw_lock_t
597 #define my_rwlock_init(A,B) my_rw_init((A))
598 #define rw_rdlock(A) my_rw_rdlock((A))
599 #define rw_wrlock(A) my_rw_wrlock((A))
600 #define rw_tryrdlock(A) my_rw_tryrdlock((A))
601 #define rw_trywrlock(A) my_rw_trywrlock((A))
602 #define rw_unlock(A) my_rw_unlock((A))
603 #define rwlock_destroy(A) my_rw_destroy((A))
604 #define rw_lock_assert_write_owner(A) my_rw_lock_assert_write_owner((A))
605 #define rw_lock_assert_not_write_owner(A) my_rw_lock_assert_not_write_owner((A))
659 pthread_t writer_thread;
669 #define rw_pr_lock_assert_write_owner(A) \
670 DBUG_ASSERT((A)->active_writer && pthread_equal(pthread_self(), \
672 #define rw_pr_lock_assert_not_write_owner(A) \
673 DBUG_ASSERT(! (A)->active_writer || ! pthread_equal(pthread_self(), \
676 #define rw_pr_lock_assert_write_owner(A)
677 #define rw_pr_lock_assert_not_write_owner(A)
681 #ifdef NEED_MY_RW_LOCK
700 BOOL have_exclusive_srwlock;
709 pthread_mutex_t lock;
710 pthread_cond_t readers;
711 pthread_cond_t writers;
715 pthread_t write_thread;
728 pthread_mutex_t lock;
729 pthread_cond_t readers;
730 pthread_cond_t writers;
734 pthread_t write_thread;
740 extern int my_rw_init(my_rw_lock_t *);
748 #define my_rw_lock_assert_write_owner(A) \
749 DBUG_ASSERT((A)->state == -1 && pthread_equal(pthread_self(), \
751 #define my_rw_lock_assert_not_write_owner(A) \
752 DBUG_ASSERT((A)->state >= 0 || ! pthread_equal(pthread_self(), \
755 #define my_rw_lock_assert_write_owner(A)
756 #define my_rw_lock_assert_not_write_owner(A)
761 #define GETHOSTBYADDR_BUFF_SIZE 2048
763 #ifndef HAVE_THR_SETCONCURRENCY
764 #define thr_setconcurrency(A) pthread_dummy(0)
766 #if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
767 #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
771 #define MY_MUTEX_INIT_SLOW NULL
772 #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
773 extern pthread_mutexattr_t my_fast_mutexattr;
774 #define MY_MUTEX_INIT_FAST &my_fast_mutexattr
776 #define MY_MUTEX_INIT_FAST NULL
778 #ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
779 extern pthread_mutexattr_t my_errorcheck_mutexattr;
780 #define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
782 #define MY_MUTEX_INIT_ERRCHK NULL
790 typedef ulong my_thread_id;
792 extern my_bool my_thread_global_init(
void);
793 extern void my_thread_global_reinit(
void);
794 extern void my_thread_global_end(
void);
795 extern my_bool my_thread_init(
void);
796 extern void my_thread_end(
void);
797 extern const char *my_thread_name(
void);
798 extern my_thread_id my_thread_dbug_id(
void);
799 extern int pthread_dummy(
int);
801 #ifndef HAVE_PTHREAD_ATTR_GETGUARDSIZE
802 static inline int pthread_attr_getguardsize(pthread_attr_t *attr,
812 #define THREAD_NAME_SIZE 10
813 #ifndef DEFAULT_THREAD_STACK
819 #define DEFAULT_THREAD_STACK (256*1024L)
821 #define DEFAULT_THREAD_STACK (192*1024)
827 #define INSTRUMENT_ME 0
836 pthread_t pthread_self;
843 void *stack_ends_here;
846 char name[THREAD_NAME_SIZE+1];
850 extern struct st_my_thread_var *_my_thread_var(
void) __attribute__ ((const));
852 extern
void **my_thread_var_dbug();
853 extern uint my_thread_end_wait_time;
854 #define my_thread_var (_my_thread_var())
855 #define my_errno my_thread_var->thr_errno
863 #define THD_LIB_OTHER 1
864 #define THD_LIB_NPTL 2
867 extern uint thd_lib_detected;
877 #ifndef thread_safe_increment
879 #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
880 #define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
882 #define thread_safe_increment(V,L) \
883 (mysql_mutex_lock((L)), (V)++, mysql_mutex_unlock((L)))
884 #define thread_safe_decrement(V,L) \
885 (mysql_mutex_lock((L)), (V)--, mysql_mutex_unlock((L)))
889 #ifndef thread_safe_add
891 #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
892 #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
894 #define thread_safe_add(V,C,L) \
895 (mysql_mutex_lock((L)), (V)+=(C), mysql_mutex_unlock((L)))
896 #define thread_safe_sub(V,C,L) \
897 (mysql_mutex_lock((L)), (V)-=(C), mysql_mutex_unlock((L)))
913 #ifdef SAFE_STATISTICS
914 #define statistic_increment(V,L) thread_safe_increment((V),(L))
915 #define statistic_decrement(V,L) thread_safe_decrement((V),(L))
916 #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
917 #define statistic_sub(V,C,L) thread_safe_sub((V),(C),(L))
919 #define statistic_decrement(V,L) (V)--
920 #define statistic_increment(V,L) (V)++
921 #define statistic_add(V,C,L) (V)+=(C)
922 #define statistic_sub(V,C,L) (V)-=(C)
928 #define status_var_increment(V) (V)++
929 #define status_var_decrement(V) (V)--
930 #define status_var_add(V,C) (V)+=(C)
931 #define status_var_sub(V,C) (V)-=(C)