Annotation of win32/sql/mysql/include/my_pthread.h, revision 1.1.1.1
1.1 parser 1: /* Copyright Abandoned 1999 TCX DataKonsult AB & Monty Program KB & Detron HB
2: This file is public domain and comes with NO WARRANTY of any kind */
3:
4: /* Defines to make different thread packages compatible */
5:
6: #ifndef _my_pthread_h
7: #define _my_pthread_h
8:
9: #include <errno.h>
10: #ifndef ETIME
11: #define ETIME ETIMEDOUT // For FreeBSD
12: #endif
13:
14: #if defined(__WIN32__)
15:
16: typedef CRITICAL_SECTION pthread_mutex_t;
17: typedef HANDLE pthread_t;
18: typedef struct thread_attr {
19: DWORD dwStackSize ;
20: DWORD dwCreatingFlag ;
21: int priority ;
22: } pthread_attr_t ;
23:
24: typedef struct { int dummy; } pthread_condattr_t;
25:
26: /* Implementation of posix conditions */
27:
28: typedef struct st_pthread_link {
29: DWORD thread_id;
30: struct st_pthread_link *next;
31: } pthread_link;
32:
33: typedef struct {
34: uint32 waiting;
35: HANDLE semaphore;
36: } pthread_cond_t;
37:
38:
39: struct timespec { /* For pthread_cond_timedwait() */
40: time_t tv_sec;
41: long tv_nsec;
42: };
43:
44: #define win_pthread_self my_thread_var->pthread_self
45: #define pthread_handler_decl(A,B) unsigned __cdecl A(void *B)
46: typedef unsigned (__cdecl *pthread_handler)(void *);
47:
48: int win_pthread_setspecific(void *A,void *B,uint length);
49: int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *);
50: int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
51: int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
52: int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
53: struct timespec *abstime);
54: int pthread_cond_signal(pthread_cond_t *cond);
55: int pthread_cond_broadcast(pthread_cond_t *cond);
56: int pthread_cond_destroy(pthread_cond_t *cond);
57: int pthread_attr_init(pthread_attr_t *connect_att);
58: int pthread_attr_setstacksize(pthread_attr_t *connect_att,DWORD stack);
59: int pthread_attr_setprio(pthread_attr_t *connect_att,int priority);
60: int pthread_attr_destroy(pthread_attr_t *connect_att);
61: struct tm *localtime_r(const time_t *timep,struct tm *tmp);
62:
63: void pthread_exit(unsigned A); /* was #define pthread_exit(A) ExitThread(A)*/
64:
65: #define ETIMEDOUT 145 /* Win32 doesn't have this */
66: #define getpid() GetCurrentThreadId()
67: #define pthread_self() win_pthread_self
68: #define HAVE_LOCALTIME_R
69: #define _REENTRANT
70: #define HAVE_PTHREAD_ATTR_SETSTACKSIZE
71:
72: #ifdef USE_TLS /* For LIBMYSQL.DLL */
73: #define pthread_key(T,V) DWORD V
74: #define pthread_key_create(A,B) ((*A=TlsAlloc())==0xFFFFFFFF)
75: #define pthread_getspecific(A) (TlsGetValue(A))
76: #define my_pthread_getspecific(T,A) ((T) TlsGetValue(A))
77: #define my_pthread_getspecific_ptr(T,V) ((T) TlsGetValue(A))
78: #define my_pthread_setspecific_ptr(T,V) TlsSetValue(T,V)
79: #define pthread_setspecific(A,B) TlsSetValue(A,B)
80: #else
81: #define pthread_key(T,V) __declspec(thread) T V
82: #define pthread_key_create(A,B) pthread_dummy(0)
83: #define pthread_getspecific(A) (&(A))
84: #define my_pthread_getspecific(T,A) (&(A))
85: #define my_pthread_getspecific_ptr(T,V) (V)
86: #define my_pthread_setspecific_ptr(T,V) ((T)=(V),0)
87: #define pthread_setspecific(A,B) win_pthread_setspecific(&(A),(B),sizeof(A))
88: #endif /* USE_TLS */
89:
90: #define pthread_equal(A,B) ((A) == (B))
91: #define pthread_mutex_init(A,B) InitializeCriticalSection(A)
92: #define pthread_mutex_lock(A) (EnterCriticalSection(A),0)
93: #define pthread_mutex_unlock(A) LeaveCriticalSection(A)
94: #define pthread_mutex_destroy(A) DeleteCriticalSection(A)
95: #define my_pthread_setprio(A,B) SetThreadPriority(GetCurrentThread(), (B))
96: /* Dummy defines for easier code */
97: #define pthread_kill(A,B) pthread_dummy(0)
98: #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
99: #define my_pthread_attr_setprio(A,B) pthread_attr_setprio(A,B)
100: #define pthread_attr_setscope(A,B)
101: #define pthread_detach_this_thread()
102: #define pthread_condattr_init(A)
103: #define pthread_condattr_destroy(A)
104:
105: //Irena: compiler does not like this:
106: //#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0)
107: #define my_pthread_getprio(thread_id) pthread_dummy(0)
108:
109: #elif defined(HAVE_UNIXWARE7_THREADS)
110:
111: #include <thread.h>
112: #include <synch.h>
113:
114: #ifndef _REENTRANT
115: #define _REENTRANT
116: #endif
117:
118: #define HAVE_NONPOSIX_SIGWAIT
119: #define pthread_t thread_t
120: #define pthread_cond_t cond_t
121: #define pthread_mutex_t mutex_t
122: #define pthread_key_t thread_key_t
123: typedef int pthread_attr_t; /* Needed by Unixware 7.0.0 */
124:
125: #define pthread_key_create(A,B) thr_keycreate((A),(B))
126:
127: #define pthread_handler_decl(A,B) void *A(void *B)
128: #define pthread_key(T,V) pthread_key_t V
129:
130: void * my_pthread_getspecific_imp(pthread_key_t key);
131: #define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
132: #define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,V)
133:
134: #define pthread_setspecific(A,B) thr_setspecific(A,B)
135: #define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,V)
136:
137: #define pthread_create(A,B,C,D) thr_create(NULL,65536L,(C),(D),THR_DETACHED,(A))
138: #define pthread_cond_init(a,b) cond_init((a),USYNC_THREAD,NULL)
139: #define pthread_cond_destroy(a) cond_destroy(a)
140: #define pthread_cond_signal(a) cond_signal(a)
141: #define pthread_cond_wait(a,b) cond_wait((a),(b))
142: #define pthread_cond_timedwait(a,b,c) cond_timedwait((a),(b),(c))
143: #define pthread_cond_broadcast(a) cond_broadcast(a)
144:
145: #define pthread_mutex_init(a,b) mutex_init((a),USYNC_THREAD,NULL)
146: #define pthread_mutex_lock(a) mutex_lock(a)
147: #define pthread_mutex_unlock(a) mutex_unlock(a)
148: #define pthread_mutex_destroy(a) mutex_destroy(a)
149:
150: #define pthread_self() thr_self()
151: #define pthread_exit(A) thr_exit(A)
152: #define pthread_equal(A,B) (((A) == (B)) ? 1 : 0)
153: #define pthread_kill(A,B) thr_kill((A),(B))
154: #define HAVE_PTHREAD_KILL
155:
156: #define pthread_sigmask(A,B,C) thr_sigsetmask((A),(B),(C))
157:
158: extern int my_sigwait(sigset_t *set,int *sig);
159:
160: #define pthread_detach_this_thread() pthread_dummy(0)
161:
162: #define pthread_attr_init(A) pthread_dummy(0)
163: #define pthread_attr_destroy(A) pthread_dummy(0)
164: #define pthread_attr_setscope(A,B) pthread_dummy(0)
165: #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
166: #define my_pthread_setprio(A,B) pthread_dummy (0)
167: #define my_pthread_getprio(A) pthread_dummy (0)
168: #define my_pthread_attr_setprio(A,B) pthread_dummy(0)
169:
170: #else /* Normal threads */
171:
172: #ifdef HAVE_rts_threads
173: #define sigwait org_sigwait
174: #include <signal.h>
175: #undef sigwait
176: #endif
177: #undef _REENTRANT /* Fix if _REENTRANT is in pthread.h */
178: #include <pthread.h>
179: #ifndef _REENTRANT
180: #define _REENTRANT
181: #endif
182: #ifdef HAVE_THR_SETCONCURRENCY
183: #include <thread.h> /* Probably solaris */
184: #endif
185: #ifdef HAVE_SCHED_H
186: #include <sched.h>
187: #endif
188: #ifdef HAVE_SYNCH_H
189: #include <synch.h>
190: #endif
191: #if defined(__EMX__) && (!defined(EMX_PTHREAD_REV) || (EMX_PTHREAD_REV < 2))
192: #error Requires at least rev 2 of EMX pthreads library.
193: #endif
194:
195: extern int my_pthread_getprio(pthread_t thread_id);
196:
197: #define pthread_key(T,V) pthread_key_t V
198: #define my_pthread_getspecific_ptr(T,V) my_pthread_getspecific(T,(V))
199: #define my_pthread_setspecific_ptr(T,V) pthread_setspecific(T,(void*) (V))
200: #define pthread_detach_this_thread()
201: #define pthread_handler_decl(A,B) void *A(void *B)
202: typedef void *(* pthread_handler)(void *);
203:
204: /* safe mutex for debugging */
205:
206: typedef struct st_safe_mutex_t
207: {
208: pthread_mutex_t global,mutex;
209: char *file;
210: uint line,count;
211: pthread_t thread;
212: } safe_mutex_t;
213:
214: int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr);
215: int safe_mutex_lock(safe_mutex_t *mp,const char *file, uint line);
216: int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line);
217: int safe_mutex_destroy(safe_mutex_t *mp);
218: int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file, uint line);
219: int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
220: struct timespec *abstime, const char *file, uint line);
221:
222: #ifdef SAFE_MUTEX
223: #undef pthread_mutex_init
224: #undef pthread_mutex_lock
225: #undef pthread_mutex_unlock
226: #undef pthread_mutex_destroy
227: #undef pthread_mutex_wait
228: #undef pthread_mutex_timedwait
229: #undef pthread_mutex_t
230: #define pthread_mutex_init(A,B) safe_mutex_init((A),(B))
231: #define pthread_mutex_lock(A) safe_mutex_lock((A),__FILE__,__LINE__)
232: #define pthread_mutex_unlock(A) safe_mutex_unlock((A),__FILE__,__LINE__)
233: #define pthread_mutex_destroy(A) safe_mutex_destroy((A))
234: #define pthread_cond_wait(A,B) safe_cond_wait((A),(B),__FILE__,__LINE__)
235: #define pthread_cond_timedwait(A,B,C) safe_cond_timedwait((A),(B),(C),__FILE__,__LINE__)
236: #define pthread_mutex_t safe_mutex_t
237: #endif
238:
239: /* Test first for RTS or FSU threads */
240:
241: #if defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM)
242: #define HAVE_rts_threads
243: extern int my_pthread_create_detached;
244: #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
245: #define PTHREAD_CREATE_DETACHED &my_pthread_create_detached
246: #define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_GLOBAL
247: #define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_LOCAL
248: #define USE_ALARM_THREAD
249: #elif defined(HAVE_mit_thread)
250: #define USE_ALARM_THREAD
251: #undef HAVE_LOCALTIME_R
252: #define HAVE_LOCALTIME_R
253: #undef HAVE_PTHREAD_ATTR_SETSCOPE
254: #define HAVE_PTHREAD_ATTR_SETSCOPE
255: #undef HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R /* If we are running linux */
256: #undef HAVE_RWLOCK_T
257: #undef HAVE_RWLOCK_INIT
258: #undef HAVE_SNPRINTF
259:
260: #define sigset(A,B) pthread_signal((A),(void (*)(int)) (B))
261: #define signal(A,B) pthread_signal((A),(void (*)(int)) (B))
262: #define my_pthread_attr_setprio(A,B)
263: #endif /* defined(PTHREAD_SCOPE_GLOBAL) && !defined(PTHREAD_SCOPE_SYSTEM) */
264:
265: #if defined(_BSDI_VERSION) && _BSDI_VERSION < 199910
266: int sigwait(const sigset_t *set, int *sig);
267: #endif
268:
269: #if defined(HAVE_UNIXWARE7_POSIX)
270: #undef HAVE_NONPOSIX_SIGWAIT
271: #define HAVE_NONPOSIX_SIGWAIT /* sigwait takes only 1 argument */
272: #endif
273:
274: #ifndef HAVE_NONPOSIX_SIGWAIT
275: #define my_sigwait(A,B) sigwait((A),(B))
276: #else
277: int my_sigwait(sigset_t *set,int *sig);
278: #endif
279:
280: #ifdef HAVE_NONPOSIX_PTHREAD_MUTEX_INIT
281: #ifndef SAFE_MUTEX
282: #define pthread_mutex_init(a,b) my_pthread_mutex_init((a),(b))
283: extern int my_pthread_mutex_init(pthread_mutex_t *mp,
284: const pthread_mutexattr_t *attr);
285: #endif /* SAFE_MUTEX */
286: #define pthread_cond_init(a,b) my_pthread_cond_init((a),(b))
287: extern int my_pthread_cond_init(pthread_cond_t *mp,
288: const pthread_condattr_t *attr);
289: #endif /* HAVE_NONPOSIX_PTHREAD_MUTEX_INIT */
290:
291: #if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
292: #define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
293: #endif
294:
295: #if !defined(HAVE_SIGWAIT) && !defined(HAVE_mit_thread) && !defined(HAVE_rts_threads) && !defined(sigwait) && !defined(alpha_linux_port) && !defined(HAVE_NONPOSIX_SIGWAIT) && !defined(HAVE_DEC_3_2_THREADS) && !defined(_AIX)
296: int sigwait(sigset_t *setp, int *sigp); /* Use our implemention */
297: #endif
298: #if !defined(HAVE_SIGSET) && !defined(HAVE_mit_thread) && !defined(sigset)
299: #define sigset(A,B) signal((A),(B))
300: #endif
301:
302: #ifndef my_pthread_setprio
303: #if defined(HAVE_PTHREAD_SETPRIO_NP) /* FSU threads */
304: #define my_pthread_setprio(A,B) pthread_setprio_np((A),(B))
305: #elif defined(HAVE_PTHREAD_SETPRIO)
306: #define my_pthread_setprio(A,B) pthread_setprio((A),(B))
307: #else
308: extern void my_pthread_setprio(pthread_t thread_id,int prior);
309: #endif
310: #endif
311:
312: #ifndef my_pthread_attr_setprio
313: #ifdef HAVE_PTHREAD_ATTR_SETPRIO
314: #define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
315: #else
316: extern void my_pthread_attr_setprio(pthread_attr_t *attr, int priority);
317: #endif
318: #endif
319:
320: #if !defined(HAVE_PTHREAD_ATTR_SETSCOPE) || defined(HAVE_DEC_3_2_THREADS)
321: #define pthread_attr_setscope(A,B)
322: #undef HAVE_GETHOSTBYADDR_R /* No definition */
323: #endif
324:
325: #ifndef HAVE_NONPOSIX_PTHREAD_GETSPECIFIC
326: #define my_pthread_getspecific(A,B) ((A) pthread_getspecific(B))
327: #else
328: #define my_pthread_getspecific(A,B) ((A) my_pthread_getspecific_imp(B))
329: void *my_pthread_getspecific_imp(pthread_key_t key);
330: #endif
331:
332: #ifndef HAVE_LOCALTIME_R
333: struct tm *localtime_r(const time_t *clock, struct tm *res);
334: #endif
335:
336: #ifdef HAVE_PTHREAD_CONDATTR_CREATE
337: /* DCE threads on HPUX 10.20 */
338: #define pthread_condattr_init pthread_condattr_create
339: #define pthread_condattr_destroy pthread_condattr_delete
340: #endif
341:
342: #ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
343: #define pthread_cond_destroy(A) pthread_dummy(0)
344: #define pthread_mutex_destroy(A) pthread_dummy(0)
345: #define pthread_attr_delete(A) pthread_dummy(0)
346: #define pthread_condattr_delete(A) pthread_dummy(0)
347: #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
348: #define pthread_equal(A,B) ((A) == (B))
349: #define pthread_cond_timedwait(a,b,c) pthread_cond_wait((a),(b))
350: #define pthread_attr_init(A) pthread_attr_create(A)
351: #define pthread_attr_destroy(A) pthread_attr_delete(A)
352: #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
353: #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
354: #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
355: #define pthread_kill(A,B) pthread_dummy(0)
356: #undef pthread_detach_this_thread
357: #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
358: #endif
359:
360: #if ((defined(HAVE_PTHREAD_ATTR_CREATE) && !defined(HAVE_SIGWAIT)) || defined(HAVE_DEC_3_2_THREADS)) && !defined(HAVE_CTHREADS_WRAPPER)
361: /* This is set on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too) */
362: #define pthread_key_create(A,B) \
363: pthread_keycreate(A,(B) ?\
364: (pthread_destructor_t) (B) :\
365: (pthread_destructor_t) pthread_dummy)
366: #define pthread_attr_init(A) pthread_attr_create(A)
367: #define pthread_attr_destroy(A) pthread_attr_delete(A)
368: #define pthread_attr_setdetachstate(A,B) pthread_dummy(0)
369: #define pthread_create(A,B,C,D) pthread_create((A),*(B),(C),(D))
370: #ifndef pthread_sigmask
371: #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
372: #endif
373: #define pthread_kill(A,B) pthread_dummy(0)
374: #undef pthread_detach_this_thread
375: #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ; pthread_detach(&tmp); }
376: #else /* HAVE_PTHREAD_ATTR_CREATE && !HAVE_SIGWAIT */
377: #define HAVE_PTHREAD_KILL
378: #endif
379:
380: #if defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R)
381: #if !defined(HPUX)
382: struct hostent;
383: #endif /* HPUX */
384: struct hostent *my_gethostbyname_r(const char *name,
385: struct hostent *result, char *buffer,
386: int buflen, int *h_errnop);
387: #if defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R)
388: #define GETHOSTBYNAME_BUFF_SIZE 2048
389: #else
390: #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
391: #endif /* defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
392:
393: #else
394: #define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
395: #define GETHOSTBYNAME_BUFF_SIZE 2048
396: #endif /* defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GLIBC2_STYLE_GETHOSTBYNAME_R) */
397:
398: #endif /* defined(__WIN32__) */
399:
400: /* READ-WRITE thread locking */
401:
402: #if defined(USE_MUTEX_INSTEAD_OF_RW_LOCKS)
403: /* use these defs for simple mutex locking */
404: #define rw_lock_t pthread_mutex_t
405: #define my_rwlock_init(A,B) pthread_mutex_init((A),(B))
406: #define rw_rdlock(A) pthread_mutex_lock((A))
407: #define rw_wrlock(A) pthread_mutex_lock((A))
408: #define rw_unlock(A) pthread_mutex_unlock((A))
409: #define rwlock_destroy(A) pthread_mutex_destroy((A))
410: #elif defined(HAVE_PTHREAD_RWLOCK_RDLOCK)
411: #define rw_lock_t pthread_rwlock_t
412: #define my_rwlock_init(A,B) pthread_rwlock_init((A),(B))
413: #define rw_rdlock(A) pthread_rwlock_rdlock(A)
414: #define rw_wrlock(A) pthread_rwlock_wrlock(A)
415: #define rw_unlock(A) pthread_rwlock_unlock(A)
416: #define rwlock_destroy(A) pthread_rwlock_destroy(A)
417: #elif defined(HAVE_RWLOCK_INIT)
418: #ifdef HAVE_RWLOCK_T /* For example Solaris 2.6-> */
419: #define rw_lock_t rwlock_t
420: #endif
421: #define my_rwlock_init(A,B) rwlock_init((A),USYNC_THREAD,0)
422: #else
423: /* Use our own version of read/write locks */
424: typedef struct _my_rw_lock_t {
425: pthread_mutex_t lock; /* lock for structure */
426: pthread_cond_t readers; /* waiting readers */
427: pthread_cond_t writers; /* waiting writers */
428: int state; /* -1:writer,0:free,>0:readers */
429: int waiters; /* number of waiting writers */
430: } my_rw_lock_t;
431:
432: #define rw_lock_t my_rw_lock_t
433: #define rw_rdlock(A) my_rw_rdlock((A))
434: #define rw_wrlock(A) my_rw_wrlock((A))
435: #define rw_unlock(A) my_rw_unlock((A))
436: #define rwlock_destroy(A) my_rwlock_destroy((A))
437:
438: extern int my_rwlock_init( my_rw_lock_t *, void * );
439: extern int my_rwlock_destroy( my_rw_lock_t * );
440: extern int my_rw_rdlock( my_rw_lock_t * );
441: extern int my_rw_wrlock( my_rw_lock_t * );
442: extern int my_rw_unlock( my_rw_lock_t * );
443: #endif /* USE_MUTEX_INSTEAD_OF_RW_LOCKS */
444:
445: #define GETHOSTBYADDR_BUFF_SIZE 2048
446:
447: #ifndef HAVE_THR_SETCONCURRENCY
448: #define thr_setconcurrency(A) pthread_dummy(0)
449: #endif
450: #if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
451: #define pthread_attr_setstacksize(A,B) pthread_dummy(0)
452: #endif
453:
454: extern my_bool my_thread_global_init(void);
455: extern void my_thread_global_end(void);
456: extern my_bool my_thread_init(void);
457: extern void my_thread_end(void);
458: extern char *my_thread_name(void);
459: extern long my_thread_id(void);
460: extern int pthread_no_free(void *);
461: extern int pthread_dummy(int);
462:
463: /* All thread specific variables are in the following struct */
464:
465: #define THREAD_NAME_SIZE 10
466:
467: struct st_my_thread_var
468: {
469: int thr_errno;
470: int cmp_length;
471: volatile int abort;
472: long id;
473: pthread_cond_t suspend, *current_cond;
474: pthread_mutex_t mutex, *current_mutex;
475: pthread_t pthread_self;
476: #ifndef DBUG_OFF
477: char name[THREAD_NAME_SIZE+1];
478: gptr dbug;
479: #endif
480: };
481:
482: extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
483: #define my_thread_var (_my_thread_var())
484: #define my_errno my_thread_var->thr_errno
485:
486: /* This is only used for not essential statistic */
487:
488: #ifndef thread_safe_increment
489: #ifdef SAFE_STATISTICS
490: #define thread_safe_increment(V,L) \
491: pthread_mutex_lock((L)); (V)++; pthread_mutex_unlock((L));
492: #define thread_safe_add(V,C,L) \
493: pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
494: #else
495: #define thread_safe_increment(V,L) (V)++
496: #define thread_safe_add(V,C,L) (V)+=(C)
497: #endif
498: #endif /* thread_safe_increment */
499:
500: #endif /* _my_ptread_h */
E-mail: