~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_pthread.h

  • Committer: Monty Taylor
  • Date: 2009-04-14 19:16:51 UTC
  • mto: (997.2.5 mordred)
  • mto: This revision was merged to the branch mainline in revision 994.
  • Revision ID: mordred@inaugust.com-20090414191651-ltbww6hpqks8k7qk
Clarified instructions in README.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Defines to make different thread packages compatible */
17
17
 
18
 
#ifndef DRIZZLED_INTERNAL_MY_PTHREAD_H
19
 
#define DRIZZLED_INTERNAL_MY_PTHREAD_H
 
18
#ifndef _my_pthread_h
 
19
#define _my_pthread_h
20
20
 
 
21
#include <stdint.h>
21
22
#include <unistd.h>
22
23
#include <signal.h>
23
24
 
25
26
#define ETIME ETIMEDOUT                         /* For FreeBSD */
26
27
#endif
27
28
 
 
29
#ifdef  __cplusplus
 
30
#define EXTERNC extern "C"
 
31
extern "C" {
 
32
#else
 
33
#define EXTERNC
 
34
#endif /* __cplusplus */
 
35
 
28
36
#include <pthread.h>
29
37
#ifndef _REENTRANT
30
38
#define _REENTRANT
36
44
#include <synch.h>
37
45
#endif
38
46
 
39
 
namespace drizzled
40
 
{
41
 
namespace internal
42
 
{
43
 
 
44
47
#define pthread_key(T,V) pthread_key_t V
45
48
#define pthread_handler_t void *
46
49
typedef void *(* pthread_handler)(void *);
47
50
 
 
51
#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
 
52
#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))
 
53
#endif
 
54
 
48
55
 
49
56
/*
50
57
  We define my_sigset() and use that instead of the system sigset() so that
52
59
  as Mac OS X, sigset() results in flags such as SA_RESTART being set, and
53
60
  we want to make sure that no such flags are set.
54
61
*/
55
 
#if !defined(my_sigset)
 
62
#if defined(HAVE_SIGACTION) && !defined(my_sigset)
56
63
#define my_sigset(A,B) do { struct sigaction l_s; sigset_t l_set; int l_rc; \
57
64
                            assert((A) != 0);                          \
58
65
                            sigemptyset(&l_set);                            \
136
143
 
137
144
        /* READ-WRITE thread locking */
138
145
 
 
146
#ifndef HAVE_THR_SETCONCURRENCY
 
147
#define thr_setconcurrency(A) pthread_dummy(0)
 
148
#endif
139
149
#if !defined(HAVE_PTHREAD_ATTR_SETSTACKSIZE) && ! defined(pthread_attr_setstacksize)
140
150
#define pthread_attr_setstacksize(A,B) pthread_dummy(0)
141
151
#endif
147
157
#else
148
158
#define MY_MUTEX_INIT_FAST   NULL
149
159
#endif
 
160
#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP
 
161
extern pthread_mutexattr_t my_errorcheck_mutexattr;
 
162
#define MY_MUTEX_INIT_ERRCHK &my_errorcheck_mutexattr
 
163
#else
 
164
#define MY_MUTEX_INIT_ERRCHK   NULL
 
165
#endif
150
166
 
151
167
#ifndef ESRCH
152
168
/* Define it to something */
153
169
#define ESRCH 1
154
170
#endif
155
171
 
 
172
typedef uint64_t my_thread_id;
 
173
 
156
174
extern bool my_thread_global_init(void);
157
175
extern void my_thread_global_end(void);
158
176
extern bool my_thread_init(void);
159
177
extern void my_thread_end(void);
160
178
extern const char *my_thread_name(void);
 
179
extern my_thread_id my_thread_dbug_id(void);
161
180
 
162
181
/* All thread specific variables are in the following struct */
163
182
 
 
183
#define THREAD_NAME_SIZE 10
164
184
/*
165
185
  Drizzle can survive with 32K, but some glibc libraries require > 128K stack
166
186
  to resolve hostnames. Also recursive stored procedures needs stack.
174
194
  pthread_mutex_t * volatile current_mutex;
175
195
  pthread_cond_t * volatile current_cond;
176
196
  pthread_t pthread_self;
177
 
  uint64_t id;
 
197
  my_thread_id id;
 
198
  int cmp_length;
178
199
  int volatile abort;
179
200
  bool init;
180
201
  struct st_my_thread_var *next,**prev;
182
203
};
183
204
 
184
205
extern struct st_my_thread_var *_my_thread_var(void);
185
 
#define my_thread_var (::drizzled::internal::_my_thread_var())
 
206
extern uint32_t my_thread_end_wait_time;
 
207
#define my_thread_var (_my_thread_var())
186
208
/*
187
209
  Keep track of shutdown,signal, and main threads so that my_end() will not
188
210
  report errors with them
237
259
#define status_var_add(V,C)     (V)+=(C)
238
260
#define status_var_sub(V,C)     (V)-=(C)
239
261
 
240
 
} /* namespace internal */
241
 
} /* namespace drizzled */
242
 
 
243
 
#endif /* DRIZZLED_INTERNAL_MY_PTHREAD_H */
 
262
#ifdef  __cplusplus
 
263
}
 
264
#endif
 
265
#endif /* _my_ptread_h */