~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_pthread.h

Merge Stewart's dead code removal

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 MYSYS_MY_PTHREAD_H
 
19
#define MYSYS_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);                            \
153
160
#define ESRCH 1
154
161
#endif
155
162
 
 
163
typedef uint64_t my_thread_id;
 
164
 
156
165
extern bool my_thread_global_init(void);
157
166
extern void my_thread_global_end(void);
158
167
extern bool my_thread_init(void);
174
183
  pthread_mutex_t * volatile current_mutex;
175
184
  pthread_cond_t * volatile current_cond;
176
185
  pthread_t pthread_self;
177
 
  uint64_t id;
 
186
  my_thread_id id;
178
187
  int volatile abort;
179
188
  bool init;
180
189
  struct st_my_thread_var *next,**prev;
182
191
};
183
192
 
184
193
extern struct st_my_thread_var *_my_thread_var(void);
185
 
#define my_thread_var (::drizzled::internal::_my_thread_var())
 
194
#define my_thread_var (_my_thread_var())
186
195
/*
187
196
  Keep track of shutdown,signal, and main threads so that my_end() will not
188
197
  report errors with them
237
246
#define status_var_add(V,C)     (V)+=(C)
238
247
#define status_var_sub(V,C)     (V)-=(C)
239
248
 
240
 
} /* namespace internal */
241
 
} /* namespace drizzled */
242
 
 
243
 
#endif /* DRIZZLED_INTERNAL_MY_PTHREAD_H */
 
249
#ifdef  __cplusplus
 
250
}
 
251
#endif
 
252
#endif /* MYSYS_MY_PTHREAD_H */