init: fix double free of pid_file
[fio.git] / mutex.h
CommitLineData
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
JA
7#define FIO_MUTEX_MAGIC 0x4d555445U
8#define FIO_RWLOCK_MAGIC 0x52574c4fU
9
cdd18ad8 10struct fio_mutex {
07739b57
JA
11 pthread_mutex_t lock;
12 pthread_cond_t cond;
64d4d313 13 int value;
4d4e80f2 14 int waiters;
8b4e954c 15 int magic;
07739b57
JA
16};
17
d7df1d13
JA
18struct fio_rwlock {
19 pthread_rwlock_t lock;
8b4e954c 20 int magic;
d7df1d13
JA
21};
22
521da527
JA
23enum {
24 FIO_MUTEX_LOCKED = 0,
25 FIO_MUTEX_UNLOCKED = 1,
26};
27
72242057 28extern int __fio_mutex_init(struct fio_mutex *, int);
cdd18ad8 29extern struct fio_mutex *fio_mutex_init(int);
f5a42524 30extern void __fio_mutex_remove(struct fio_mutex *);
cdd18ad8 31extern void fio_mutex_remove(struct fio_mutex *);
d7df1d13 32extern void fio_mutex_up(struct fio_mutex *);
af4bab56 33extern void fio_mutex_down(struct fio_mutex *);
66608372 34extern bool fio_mutex_down_trylock(struct fio_mutex *);
656b1393 35extern int fio_mutex_down_timeout(struct fio_mutex *, unsigned int);
9c5b5290 36
d7df1d13
JA
37extern void fio_rwlock_read(struct fio_rwlock *);
38extern void fio_rwlock_write(struct fio_rwlock *);
39extern void fio_rwlock_unlock(struct fio_rwlock *);
40extern struct fio_rwlock *fio_rwlock_init(void);
41extern void fio_rwlock_remove(struct fio_rwlock *);
4d4e80f2 42
34febb23
JA
43extern int mutex_init_pshared(pthread_mutex_t *);
44extern int cond_init_pshared(pthread_cond_t *);
45extern int mutex_cond_init_pshared(pthread_mutex_t *, pthread_cond_t *);
46
07739b57 47#endif