~vkolesnikov/pbxt/pbxt-preload-test-bug

« back to all changes in this revision

Viewing changes to src/pthread_xt.h

  • Committer: Vladimir Kolesnikov
  • Date: 2009-01-21 13:55:57 UTC
  • mto: This revision was merged to the branch mainline in revision 533.
  • Revision ID: vladimir@primebase.org-20090121135557-gyzk4wo3kj126jda
added thread lock lists

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <pthread.h>
34
34
#endif
35
35
 
 
36
#include "locklist_xt.h"
 
37
 
36
38
#ifdef DEBUG
37
39
//#define DEBUG_LOCKING
38
40
#endif
64
66
 
65
67
typedef struct xt_mutex_struct {
66
68
        CRITICAL_SECTION        mt_cs;
 
69
#ifdef XT_THREAD_LOCK_INFO
 
70
        const char                 *mt_name;
 
71
        XTThreadLockInfoRec mt_lock_info;
 
72
#endif
67
73
} xt_mutex_type;
68
74
 
69
75
typedef struct xt_rwlock_struct {
74
80
  int                                   rw_ex_count;
75
81
  int                                   rw_sh_complete_count;
76
82
  int                                   rw_magic;
 
83
#ifdef XT_THREAD_LOCK_INFO
 
84
        const char                 *rw_name;
 
85
        XTThreadLockInfoRec rw_lock_info;
 
86
#endif
77
87
} xt_rwlock_type;
78
88
 
 
89
#ifdef XT_THREAD_LOCK_INFO
 
90
int xt_p_mutex_init(xt_mutex_type *mutex, const pthread_mutexattr_t *attr, const char *name);
 
91
#else
79
92
int xt_p_mutex_init(xt_mutex_type *mutex, const pthread_mutexattr_t *attr);
 
93
#endif
80
94
int xt_p_mutex_destroy(xt_mutex_type *mutex);
81
95
int xt_p_mutex_lock(xt_mutex_type *mx);
82
96
int xt_p_mutex_unlock(xt_mutex_type *mx);
83
97
int xt_p_mutex_trylock(xt_mutex_type *mutex);
84
98
 
 
99
#ifdef XT_THREAD_LOCK_INFO
 
100
int xt_p_rwlock_init(xt_rwlock_type *rwlock, const pthread_condattr_t *attr, const char *name);
 
101
#else
85
102
int xt_p_rwlock_init(xt_rwlock_type *rwlock, const pthread_condattr_t *attr);
 
103
#endif
86
104
int xt_p_rwlock_destroy(xt_rwlock_type *rwlock);
87
105
int xt_p_rwlock_rdlock(xt_rwlock_type *mx);
88
106
int xt_p_rwlock_wrlock(xt_rwlock_type *mx);
97
115
}
98
116
#endif
99
117
 
 
118
#ifdef XT_THREAD_LOCK_INFO
 
119
#define xt_p_rwlock_init_with_name(a,b,c)   xt_p_rwlock_init(a,b,c)
 
120
#define xt_p_rwlock_init_with_autoname(a,b) xt_p_rwlock_init_with_name(a,b, LOCKLIST_ARG_SUFFIX(a))
 
121
#else
 
122
#define xt_p_rwlock_init_with_name(a,b,c)   xt_p_rwlock_init(a,b,c)
 
123
#define xt_p_rwlock_init_with_autoname(a,b) xt_p_rwlock_init(a,b)
 
124
#endif
 
125
 
100
126
#define xt_slock_rwlock_ns              xt_p_rwlock_rdlock
101
127
#define xt_xlock_rwlock_ns              xt_p_rwlock_wrlock
102
128
#define xt_unlock_rwlock_ns             xt_p_rwlock_unlock
103
129
 
 
130
#ifdef XT_THREAD_LOCK_INFO
 
131
#define xt_p_mutex_init_with_name(a,b,c)   xt_p_mutex_init(a,b,c)
 
132
#define xt_p_mutex_init_with_autoname(a,b) xt_p_mutex_init_with_name(a,b, LOCKLIST_ARG_SUFFIX(a))
 
133
#else
 
134
#define xt_p_mutex_init_with_name(a,b,c)   xt_p_mutex_init(a,b)
 
135
#define xt_p_mutex_init_with_autoname(a,b) xt_p_mutex_init(a,b)
 
136
 
 
137
#endif
104
138
#define xt_lock_mutex_ns                xt_p_mutex_lock
105
139
#define xt_unlock_mutex_ns              xt_p_mutex_unlock
106
140
#define xt_mutex_trylock                xt_p_mutex_trylock