~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to include/my_pthread.h

  • Committer: Monty Taylor
  • Date: 2008-07-22 05:48:51 UTC
  • mto: (202.1.3 toru)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: monty@inaugust.com-20080722054851-airxt73370725p7x
Re-enabled optimizations for the normal build, and added back the --with-debug option to turn them off. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
#define my_sigset(A,B) signal((A),(B))
106
106
#endif
107
107
 
 
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))
 
113
#else
 
114
extern void my_pthread_setprio(pthread_t thread_id,int prior);
 
115
#endif
 
116
#endif
 
117
 
108
118
#ifndef my_pthread_attr_setprio
109
119
#ifdef HAVE_PTHREAD_ATTR_SETPRIO
110
120
#define my_pthread_attr_setprio(A,B) pthread_attr_setprio((A),(B))
208
218
#define set_timespec_nsec(ABSTIME,NSEC) \
209
219
{ \
210
220
  uint64_t now= my_getsystime() + (NSEC/100); \
211
 
  (ABSTIME).ts_sec=  (now / 10000000UL); \
212
 
  (ABSTIME).ts_nsec= (now % 10000000UL * 100 + ((NSEC) % 100)); \
 
221
  (ABSTIME).ts_sec=  (now / 10000000ULL); \
 
222
  (ABSTIME).ts_nsec= (now % 10000000ULL * 100 + ((NSEC) % 100)); \
213
223
}
214
224
#endif /* !set_timespec_nsec */
215
225
#else
226
236
#define set_timespec_nsec(ABSTIME,NSEC) \
227
237
{\
228
238
  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)); \
 
239
  (ABSTIME).tv_sec=  (time_t) (now / 10000000ULL);                  \
 
240
  (ABSTIME).tv_nsec= (long) (now % 10000000ULL * 100 + ((NSEC) % 100)); \
231
241
}
232
242
#endif /* !set_timespec_nsec */
233
243
#endif /* HAVE_TIMESPEC_TS_SEC */
238
248
{
239
249
  pthread_mutex_t global,mutex;
240
250
  const char *file;
241
 
  uint32_t line,count;
 
251
  uint line,count;
242
252
  pthread_t thread;
243
253
} safe_mutex_t;
244
254
 
245
255
int safe_mutex_init(safe_mutex_t *mp, const pthread_mutexattr_t *attr,
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);
 
256
                    const char *file, uint line);
 
257
int safe_mutex_lock(safe_mutex_t *mp, 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);
250
260
int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp,const char *file,
251
 
                   uint32_t line);
 
261
                   uint line);
252
262
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
253
 
                        struct timespec *abstime, const char *file, uint32_t line);
 
263
                        struct timespec *abstime, const char *file, uint line);
254
264
void safe_mutex_global_init(void);
255
265
void safe_mutex_end(FILE *file);
256
266
 
262
272
typedef struct st_my_pthread_fastmutex_t
263
273
{
264
274
  pthread_mutex_t mutex;
265
 
  uint32_t spins;
 
275
  uint spins;
266
276
} my_pthread_fastmutex_t;
267
277
void fastmutex_global_init(void);
268
278
 
388
398
/* All thread specific variables are in the following struct */
389
399
 
390
400
#define THREAD_NAME_SIZE 10
 
401
#ifndef DEFAULT_THREAD_STACK
 
402
#if SIZEOF_CHARP > 4
391
403
/*
392
 
  Drizzle can survive with 32K, but some glibc libraries require > 128K stack
393
 
  to resolve hostnames. Also recursive stored procedures needs stack.
 
404
  MySQL can survive with 32K, but some glibc libraries require > 128K stack
 
405
  To resolve hostnames. Also recursive stored procedures needs stack.
394
406
*/
395
 
#define DEFAULT_THREAD_STACK    (256*INT32_C(1024))
 
407
#define DEFAULT_THREAD_STACK    (256*1024L)
 
408
#else
 
409
#define DEFAULT_THREAD_STACK    (192*1024)
 
410
#endif
 
411
#endif
396
412
 
397
413
struct st_my_thread_var
398
414
{
410
426
};
411
427
 
412
428
extern struct st_my_thread_var *_my_thread_var(void) __attribute__ ((const));
413
 
extern uint32_t my_thread_end_wait_time;
 
429
extern uint my_thread_end_wait_time;
414
430
#define my_thread_var (_my_thread_var())
415
431
/*
416
432
  Keep track of shutdown,signal, and main threads so that my_end() will not
423
439
#define THD_LIB_NPTL  2
424
440
#define THD_LIB_LT    4
425
441
 
426
 
extern uint32_t thd_lib_detected;
 
442
extern uint thd_lib_detected;
427
443
 
428
444
/*
429
445
  thread_safe_xxx functions are for critical statistic or counters.