51
extern int my_pthread_getprio(pthread_t thread_id);
53
43
#define pthread_key(T,V) pthread_key_t V
54
44
#define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
55
45
#define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
69
59
#define USE_ALARM_THREAD
70
60
#endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
72
#if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
73
int sigwait(sigset_t *set, int *sig);
76
62
#ifndef HAVE_NONPOSIX_SIGWAIT
77
63
#define my_sigwait(A,B) sigwait((A),(B))
82
68
#ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
84
69
#define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
85
70
extern int my_pthread_mutex_init(pthread_mutex_t *mp,
86
71
const pthread_mutexattr_t *attr);
87
#endif /* SAFE_MUTEX */
88
72
#define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
89
73
extern int my_pthread_cond_init(pthread_cond_t *mp,
90
74
const pthread_condattr_t *attr);
143
127
#define pthread_attr_setscope(A,B)
146
#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT) && !defined(SAFE_MUTEX)
130
#if defined(HAVE_BROKEN_PTHREAD_COND_TIMEDWAIT)
147
131
extern int my_pthread_cond_timedwait(pthread_cond_t *cond,
148
132
pthread_mutex_t *mutex,
149
133
struct timespec *abstime);
266
250
const char *file;
268
252
pthread_t thread;
269
#ifdef SAFE_MUTEX_DETECT_DESTROY
270
struct st_safe_mutex_info_t *info; /* to track destroying of mutexes */
274
#ifdef SAFE_MUTEX_DETECT_DESTROY
276
Used to track the destroying of mutexes. This needs to be a seperate
277
structure because the safe_mutex_t structure could be freed before
278
the mutexes are destroyed.
281
typedef struct st_safe_mutex_info_t
283
struct st_safe_mutex_info_t *next;
284
struct st_safe_mutex_info_t *prev;
285
const char *init_file;
288
#endif /* SAFE_MUTEX_DETECT_DESTROY */
290
255
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
291
256
const char *file, uint line);
292
257
int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line);
300
265
void safe_mutex_end(FILE *file);
302
267
/* Wrappers if safe mutex is actually used */
304
#undef pthread_mutex_init
305
#undef pthread_mutex_lock
306
#undef pthread_mutex_unlock
307
#undef pthread_mutex_destroy
308
#undef pthread_mutex_wait
309
#undef pthread_mutex_timedwait
310
#undef pthread_mutex_t
311
#undef pthread_cond_wait
312
#undef pthread_cond_timedwait
313
#undef pthread_mutex_trylock
314
#define pthread_mutex_init(A,B) safe_mutex_init((A),(B),__FILE__,__LINE__)
315
#define pthread_mutex_lock(A) safe_mutex_lock((A), FALSE, __FILE__, __LINE__)
316
#define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
317
#define pthread_mutex_destroy(A) safe_mutex_destroy((A),__FILE__,__LINE__)
318
#define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
319
#define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
320
#define pthread_mutex_trylock(A) safe_mutex_lock((A), TRUE, __FILE__, __LINE__)
321
#define pthread_mutex_t safe_mutex_t
322
#define safe_mutex_assert_owner(mp) \
323
DBUG_ASSERT((mp)->count > 0 && \
324
pthread_equal(pthread_self(), (mp)->thread))
325
#define safe_mutex_assert_not_owner(mp) \
326
DBUG_ASSERT(! (mp)->count || \
327
! pthread_equal(pthread_self(), (mp)->thread))
329
268
#define safe_mutex_assert_owner(mp)
330
269
#define safe_mutex_assert_not_owner(mp)
331
#endif /* SAFE_MUTEX */
333
#if defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX)
271
#if defined(MY_PTHREAD_FASTMUTEX)
334
272
typedef struct st_my_pthread_fastmutex_t
336
274
pthread_mutex_t mutex;
360
298
#define pthread_cond_timedwait(A,B,C) pthread_cond_timedwait((A),&(B)->mutex,(C))
361
299
#define pthread_mutex_trylock(A) pthread_mutex_trylock(&(A)->mutex)
362
300
#define pthread_mutex_t my_pthread_fastmutex_t
363
#endif /* defined(MY_PTHREAD_FASTMUTEX) && !defined(SAFE_MUTEX) */
301
#endif /* defined(MY_PTHREAD_FASTMUTEX) */
365
303
/* READ-WRITE thread locking */
545
483
statistics_xxx functions are for non critical statistic,
546
484
maintained in global variables.
547
When compiling with SAFE_STATISTICS:
548
- race conditions can not occur.
549
- some locking occurs, which may cause performance degradation.
551
When compiling without SAFE_STATISTICS:
552
485
- race conditions can occur, making the result slightly inaccurate.
553
486
- the lock given is not honored.
555
#ifdef SAFE_STATISTICS
556
#define statistic_increment(V,L) thread_safe_increment((V),(L))
557
#define statistic_decrement(V,L) thread_safe_decrement((V),(L))
558
#define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
559
#define statistic_sub(V,C,L) thread_safe_sub((V),(C),(L))
561
488
#define statistic_decrement(V,L) (V)--
562
489
#define statistic_increment(V,L) (V)++
563
490
#define statistic_add(V,C,L) (V)+=(C)
564
491
#define statistic_sub(V,C,L) (V)-=(C)
565
#endif /* SAFE_STATISTICS */
568
494
No locking needed, the counter is owned by the thread