The CDSSpec checker's benchmarks
[model-checker-benchmarks.git] / linuxrwlocks / linuxrwlocks.h
1 #ifndef _LINUXRWLOCKS_H
2 #define _LINUXRWLOCKS_H
3
4 #include <stdio.h>
5 #include <threads.h>
6 #include <stdatomic.h>
7
8 #include "librace.h"
9
10 #define RW_LOCK_BIAS            0x00100000
11 #define WRITE_LOCK_CMP          RW_LOCK_BIAS
12
13 typedef union {
14         atomic_int lock;
15 } rwlock_t;
16
17
18 int read_can_lock(rwlock_t *lock);
19
20 int write_can_lock(rwlock_t *lock);
21
22 void read_lock(rwlock_t *rw);
23
24 void write_lock(rwlock_t *rw);
25
26 int read_trylock(rwlock_t *rw);
27
28 int write_trylock(rwlock_t *rw);
29
30 void read_unlock(rwlock_t *rw);
31
32 void write_unlock(rwlock_t *rw);
33
34 #endif