-
Notifications
You must be signed in to change notification settings - Fork 1
/
lock_tracker.h
55 lines (34 loc) · 1.81 KB
/
lock_tracker.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef __LOCK_TRACKER_H__
#define __LOCK_TRACKER_H__
#include <pthread.h>
/* Uncomment to enable mutex debugging */
//#define LOCKTRACKER 1
#ifdef LOCKTRACKER
#ifndef __FILENAME__
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#endif
int _q_thread_mutex_lock(pthread_mutex_t *m, const char *mtex, const char *file, const char *func,
int line);
int _q_thread_mutex_unlock(pthread_mutex_t *m, const char *mtex, const char *file, const char *func,
int line);
int _q_thread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, struct timespec *ts,
const char *mtex, const char *file, const char *func, int line);
int _q_thread_cond_wait(pthread_cond_t *c, pthread_mutex_t *m, const char *mtex, const char *file,
const char *func, int line);
void _q_thread_dump_locks();
#define q_thread_dump_locks() _q_thread_dump_locks()
#define q_thread_mutex_lock(m) _q_thread_mutex_lock(m, #m, __FILENAME__, __FUNCTION__, __LINE__)
#define q_thread_mutex_unlock(m) _q_thread_mutex_unlock(m, #m, __FILENAME__, __FUNCTION__, __LINE__)
#define q_thread_cond_timedwait(c, m, t) \
_q_thread_cond_timedwait(c, m, t, #m, __FILENAME__, __FUNCTION__, __LINE__)
#define q_thread_cond_wait(c, m) _q_thread_cond_wait(c, m, #m, __FILENAME__, __FUNCTION__, __LINE__)
#else
#define q_thread_dump_locks() \
do { \
} while (0)
#define q_thread_mutex_lock(m) pthread_mutex_lock(m)
#define q_thread_mutex_unlock(m) pthread_mutex_unlock(m)
#define q_thread_cond_timedwait(c, m, t) pthread_cond_timedwait(c, m, t)
#define q_thread_cond_wait(c, m) pthread_cond_wait(c, m)
#endif
#endif