92
92
#if defined(HAVE_SIGACTION) && !defined(my_sigset)
93
93
#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \
94
DBUG_ASSERT((A) != 0); \
95
95
sigemptyset(&l_set); \
96
96
l_s.sa_handler = (B); \
97
97
l_s.sa_mask = l_set; \
98
98
l_s.sa_flags = 0; \
99
99
l_rc= sigaction((A), &l_s, (struct sigaction *) NULL);\
100
DBUG_ASSERT(l_rc == 0); \
102
102
#elif defined(HAVE_SIGSET) && !defined(my_sigset)
103
103
#define my_sigset(A,B) sigset((A),(B))
105
105
#define my_sigset(A,B) signal((A),(B))
108
#ifndef my_pthread_setprio
109
#if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
110
#define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
111
#elif defined(HAVE_PTHREAD_SETPRIO)
112
#define my_pthread_setprio(A,B) pthread_setprio((A),(B))
114
extern void my_pthread_setprio(pthread_t thread_id,int prior);
118
108
#ifndef my_pthread_attr_setprio
119
109
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
120
110
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
217
207
#ifndef set_timespec_nsec
218
208
#define set_timespec_nsec(ABSTIME,NSEC) \
220
ulonglong now= my_getsystime() + (NSEC/100); \
221
(ABSTIME).ts_sec= (now / ULL(10000000)); \
222
(ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
210
uint64_t now= my_getsystime() + (NSEC/100); \
211
(ABSTIME).ts_sec= (now / 10000000UL); \
212
(ABSTIME).ts_nsec= (now % 10000000UL * 100 + ((NSEC) % 100)); \
224
214
#endif /* !set_timespec_nsec */
235
225
#ifndef set_timespec_nsec
236
226
#define set_timespec_nsec(ABSTIME,NSEC) \
238
ulonglong now= my_getsystime() + (NSEC/100); \
239
(ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \
240
(ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \
228
uint64_t now= my_getsystime() + (NSEC/100); \
229
(ABSTIME).tv_sec= (time_t) (now / 10000000UL); \
230
(ABSTIME).tv_nsec= (long) (now % 10000000UL * 100 + ((NSEC) % 100)); \
242
232
#endif /* !set_timespec_nsec */
243
233
#endif /* HAVE_TIMESPEC_TS_SEC */
249
239
pthread_mutex_t global,mutex;
250
240
const char *file;
252
242
pthread_t thread;
255
245
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
256
const char *file, uint line);
257
int safe_mutex_lock(safe_mutex_t *mp, my_bool try_lock, const char *file, uint line);
258
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
259
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint line);
246
const char *file, uint32_t line);
247
int safe_mutex_lock(safe_mutex_t *mp, bool try_lock, const char *file, uint32_t line);
248
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint32_t line);
249
int safe_mutex_destroy(safe_mutex_t *mp,const char *file, uint32_t line);
260
250
int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
262
252
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
263
struct timespec *abstime, const char *file, uint line);
253
struct timespec *abstime, const char *file, uint32_t line);
264
254
void safe_mutex_global_init(void);
265
255
void safe_mutex_end(FILE *file);
389
379
typedef ulong my_thread_id;
391
extern my_bool my_thread_global_init(void);
381
extern bool my_thread_global_init(void);
392
382
extern void my_thread_global_end(void);
393
extern my_bool my_thread_init(void);
383
extern bool my_thread_init(void);
394
384
extern void my_thread_end(void);
395
385
extern const char *my_thread_name(void);
396
386
extern my_thread_id my_thread_dbug_id(void);
398
388
/* All thread specific variables are in the following struct */
400
390
#define THREAD_NAME_SIZE 10
401
#ifndef DEFAULT_THREAD_STACK
404
MySQL can survive with 32K, but some glibc libraries require > 128K stack
405
To resolve hostnames. Also recursive stored procedures needs stack.
392
Drizzle can survive with 32K, but some glibc libraries require > 128K stack
393
to resolve hostnames. Also recursive stored procedures needs stack.
407
#define DEFAULT_THREAD_STACK (256*1024L)
409
#define DEFAULT_THREAD_STACK (192*1024)
395
#define DEFAULT_THREAD_STACK (256*INT32_C(1024))
413
397
struct st_my_thread_var
422
406
int volatile abort;
424
408
struct st_my_thread_var *next,**prev;
428
char name[THREAD_NAME_SIZE+1];
432
412
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
433
extern uint my_thread_end_wait_time;
413
extern uint32_t my_thread_end_wait_time;
434
414
#define my_thread_var (_my_thread_var())
436
416
Keep track of shutdown,signal, and main threads so that my_end() will not
453
433
to use my_atomic operations instead.
458
When compiling without threads, this file is not included.
459
See the *other* declarations of thread_safe_xxx in include/my_global.h
462
See include/config-win.h, for yet another implementation.
465
436
#ifndef thread_safe_increment
466
437
#define thread_safe_increment(V,L) \
467
438
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
475
446
#define thread_safe_sub(V,C,L) \
476
447
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
481
451
statistics_xxx functions are for non critical statistic,