Commit | Line | Data |
---|---|---|
07739b57 JA |
1 | #ifndef FIO_MUTEX_H |
2 | #define FIO_MUTEX_H | |
3 | ||
4 | #include <pthread.h> | |
66608372 | 5 | #include "lib/types.h" |
07739b57 | 6 | |
8b4e954c | 7 | #define FIO_MUTEX_MAGIC 0x4d555445U |
8b4e954c | 8 | |
cdd18ad8 | 9 | struct fio_mutex { |
07739b57 JA |
10 | pthread_mutex_t lock; |
11 | pthread_cond_t cond; | |
64d4d313 | 12 | int value; |
4d4e80f2 | 13 | int waiters; |
8b4e954c | 14 | int magic; |
07739b57 JA |
15 | }; |
16 | ||
521da527 JA |
17 | enum { |
18 | FIO_MUTEX_LOCKED = 0, | |
19 | FIO_MUTEX_UNLOCKED = 1, | |
20 | }; | |
21 | ||
72242057 | 22 | extern int __fio_mutex_init(struct fio_mutex *, int); |
cdd18ad8 | 23 | extern struct fio_mutex *fio_mutex_init(int); |
f5a42524 | 24 | extern void __fio_mutex_remove(struct fio_mutex *); |
cdd18ad8 | 25 | extern void fio_mutex_remove(struct fio_mutex *); |
d7df1d13 | 26 | extern void fio_mutex_up(struct fio_mutex *); |
af4bab56 | 27 | extern void fio_mutex_down(struct fio_mutex *); |
66608372 | 28 | extern bool fio_mutex_down_trylock(struct fio_mutex *); |
656b1393 | 29 | extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int); |
9c5b5290 | 30 | |
07739b57 | 31 | #endif |