| 1 | #ifndef FIO_SEM_H |
| 2 | #define FIO_SEM_H |
| 3 | |
| 4 | #include <pthread.h> |
| 5 | #include "lib/types.h" |
| 6 | |
| 7 | #define FIO_SEM_MAGIC 0x4d555445U |
| 8 | |
| 9 | struct fio_sem { |
| 10 | pthread_mutex_t lock; |
| 11 | pthread_cond_t cond; |
| 12 | int value; |
| 13 | int waiters; |
| 14 | int magic; |
| 15 | }; |
| 16 | |
| 17 | enum { |
| 18 | FIO_SEM_LOCKED = 0, |
| 19 | FIO_SEM_UNLOCKED = 1, |
| 20 | }; |
| 21 | |
| 22 | extern int __fio_sem_init(struct fio_sem *, int); |
| 23 | extern struct fio_sem *fio_sem_init(int); |
| 24 | extern void __fio_sem_remove(struct fio_sem *); |
| 25 | extern void fio_sem_remove(struct fio_sem *); |
| 26 | extern void fio_sem_up(struct fio_sem *); |
| 27 | extern void fio_sem_down(struct fio_sem *); |
| 28 | extern bool fio_sem_down_trylock(struct fio_sem *); |
| 29 | extern int fio_sem_down_timeout(struct fio_sem *, unsigned int); |
| 30 | |
| 31 | #endif |