Imported Upstream version 0.6.3
[platform/upstream/multipath-tools.git] / libmultipath / lock.h
1 #ifndef _LOCK_H
2 #define _LOCK_H
3
4 #include <pthread.h>
5
6 struct mutex_lock {
7         pthread_mutex_t mutex;
8 };
9
10 static inline void lock(struct mutex_lock *a)
11 {
12         pthread_mutex_lock(&a->mutex);
13 }
14
15 static inline int timedlock(struct mutex_lock *a, struct timespec *tmo)
16 {
17         return pthread_mutex_timedlock(&a->mutex, tmo);
18 }
19
20 static inline void unlock(struct mutex_lock *a)
21 {
22         pthread_mutex_unlock(&a->mutex);
23 }
24
25 #define lock_cleanup_pop(a) pthread_cleanup_pop(1)
26
27 void cleanup_lock (void * data);
28
29 #endif /* _LOCK_H */