engines/net: turn off UDP package dropping if buf size doesn't match
[fio.git] / mutex.h
... / ...
CommitLineData
1#ifndef FIO_MUTEX_H
2#define FIO_MUTEX_H
3
4#include <pthread.h>
5
6#define FIO_MUTEX_MAGIC 0x4d555445U
7#define FIO_RWLOCK_MAGIC 0x52574c4fU
8
9struct fio_mutex {
10 pthread_mutex_t lock;
11 pthread_cond_t cond;
12 int value;
13 int waiters;
14 int magic;
15};
16
17struct fio_rwlock {
18 pthread_rwlock_t lock;
19 int magic;
20};
21
22enum {
23 FIO_MUTEX_LOCKED = 0,
24 FIO_MUTEX_UNLOCKED = 1,
25};
26
27extern int __fio_mutex_init(struct fio_mutex *, int);
28extern struct fio_mutex *fio_mutex_init(int);
29extern void fio_mutex_remove(struct fio_mutex *);
30extern void fio_mutex_up(struct fio_mutex *);
31extern void fio_mutex_down(struct fio_mutex *);
32extern int fio_mutex_down_trylock(struct fio_mutex *);
33extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int);
34
35extern void fio_rwlock_read(struct fio_rwlock *);
36extern void fio_rwlock_write(struct fio_rwlock *);
37extern void fio_rwlock_unlock(struct fio_rwlock *);
38extern struct fio_rwlock *fio_rwlock_init(void);
39extern void fio_rwlock_remove(struct fio_rwlock *);
40
41#endif