Commit | Line | Data |
---|---|---|
07739b57 JA |
1 | #ifndef FIO_MUTEX_H |
2 | #define FIO_MUTEX_H | |
3 | ||
4 | #include <pthread.h> | |
5 | ||
8b4e954c JA |
6 | #define FIO_MUTEX_MAGIC 0x4d555445U |
7 | #define FIO_RWLOCK_MAGIC 0x52574c4fU | |
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 | ||
d7df1d13 JA |
17 | struct fio_rwlock { |
18 | pthread_rwlock_t lock; | |
8b4e954c | 19 | int magic; |
d7df1d13 JA |
20 | }; |
21 | ||
521da527 JA |
22 | enum { |
23 | FIO_MUTEX_LOCKED = 0, | |
24 | FIO_MUTEX_UNLOCKED = 1, | |
25 | }; | |
26 | ||
72242057 | 27 | extern int __fio_mutex_init(struct fio_mutex *, int); |
cdd18ad8 | 28 | extern struct fio_mutex *fio_mutex_init(int); |
f5a42524 | 29 | extern void __fio_mutex_remove(struct fio_mutex *); |
cdd18ad8 | 30 | extern void fio_mutex_remove(struct fio_mutex *); |
d7df1d13 | 31 | extern void fio_mutex_up(struct fio_mutex *); |
af4bab56 | 32 | extern void fio_mutex_down(struct fio_mutex *); |
72242057 | 33 | extern int fio_mutex_down_trylock(struct fio_mutex *); |
656b1393 | 34 | extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int); |
9c5b5290 | 35 | |
d7df1d13 JA |
36 | extern void fio_rwlock_read(struct fio_rwlock *); |
37 | extern void fio_rwlock_write(struct fio_rwlock *); | |
38 | extern void fio_rwlock_unlock(struct fio_rwlock *); | |
39 | extern struct fio_rwlock *fio_rwlock_init(void); | |
40 | extern void fio_rwlock_remove(struct fio_rwlock *); | |
4d4e80f2 | 41 | |
07739b57 | 42 | #endif |