~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/thr_mutex.c

  • Committer: Monty Taylor
  • Date: 2008-10-16 06:32:30 UTC
  • mto: (511.1.5 codestyle)
  • mto: This revision was merged to the branch mainline in revision 521.
  • Revision ID: monty@inaugust.com-20081016063230-4brxsra0qsmsg84q
Added -Wunused-macros.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* This makes a wrapper for mutex handling to make it easier to debug mutex */
17
17
 
18
 
#include <my_global.h>
 
18
#include "mysys_priv.h"
 
19
 
19
20
#if defined(TARGET_OS_LINUX) && !defined (__USE_UNIX98)
20
21
#define __USE_UNIX98                    /* To get rw locks under Linux */
21
22
#endif
40
41
#endif /* DO_NOT_REMOVE_THREAD_WRAPPERS */
41
42
 
42
43
static pthread_mutex_t THR_LOCK_mutex;
43
 
static ulong safe_mutex_count= 0;               /* Number of mutexes created */
 
44
static uint32_t safe_mutex_count= 0;            /* Number of mutexes created */
44
45
#ifdef SAFE_MUTEX_DETECT_DESTROY
45
46
static struct st_safe_mutex_info_t *safe_mutex_root= NULL;
46
47
#endif
54
55
int safe_mutex_init(safe_mutex_t *mp,
55
56
                    const pthread_mutexattr_t *attr __attribute__((unused)),
56
57
                    const char *file,
57
 
                    uint line)
 
58
                    uint32_t line)
58
59
{
59
 
  bzero((char*) mp,sizeof(*mp));
 
60
  memset(mp, 0, sizeof(*mp));
60
61
  pthread_mutex_init(&mp->global,MY_MUTEX_INIT_ERRCHK);
61
62
  pthread_mutex_init(&mp->mutex,attr);
62
63
  /* Mark that mutex is initialized */
91
92
}
92
93
 
93
94
 
94
 
int safe_mutex_lock(safe_mutex_t *mp, bool try_lock, const char *file, uint line)
 
95
int safe_mutex_lock(safe_mutex_t *mp, bool try_lock, const char *file, uint32_t line)
95
96
{
96
97
  int error;
97
98
  if (!mp->file)
170
171
}
171
172
 
172
173
 
173
 
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint line)
 
174
int safe_mutex_unlock(safe_mutex_t *mp,const char *file, uint32_t line)
174
175
{
175
176
  int error;
176
177
  pthread_mutex_lock(&mp->global);
203
204
 
204
205
 
205
206
int safe_cond_wait(pthread_cond_t *cond, safe_mutex_t *mp, const char *file,
206
 
                   uint line)
 
207
                   uint32_t line)
207
208
{
208
209
  int error;
209
210
  pthread_mutex_lock(&mp->global);
255
256
 
256
257
int safe_cond_timedwait(pthread_cond_t *cond, safe_mutex_t *mp,
257
258
                        struct timespec *abstime,
258
 
                        const char *file, uint line)
 
259
                        const char *file, uint32_t line)
259
260
{
260
261
  int error;
261
262
  pthread_mutex_lock(&mp->global);
291
292
}
292
293
 
293
294
 
294
 
int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint line)
 
295
int safe_mutex_destroy(safe_mutex_t *mp, const char *file, uint32_t line)
295
296
{
296
297
  int error=0;
297
298
  if (!mp->file)
348
349
    file                Print errors on this file
349
350
 
350
351
  NOTES
351
 
    We can't use DBUG_PRINT() here as we have in my_end() disabled
352
 
    DBUG handling before calling this function.
353
352
 
354
353
   In MySQL one may get one warning for a mutex created in my_thr_init.c
355
354
   This is ok, as this thread may not yet have been exited.
403
402
#undef pthread_cond_wait
404
403
#undef pthread_cond_timedwait
405
404
 
406
 
ulong mutex_delay(ulong delayloops)
 
405
uint32_t mutex_delay(uint32_t delayloops)
407
406
{
408
 
  ulong i;
409
 
  volatile ulong j;
 
407
  uint32_t      i;
 
408
  volatile uint32_t j;
410
409
 
411
410
  j = 0;
412
411
 
434
433
int my_pthread_fastmutex_lock(my_pthread_fastmutex_t *mp)
435
434
{
436
435
  int   res;
437
 
  uint  i;
438
 
  uint  maxdelay= MY_PTHREAD_FASTMUTEX_DELAY;
 
436
  uint32_t  i;
 
437
  uint32_t  maxdelay= MY_PTHREAD_FASTMUTEX_DELAY;
439
438
 
440
439
  for (i= 0; i < mp->spins; i++)
441
440
  {