diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-08 00:13:18 -0900 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-20 09:07:08 -0900 |
commit | b33fc8298f7e13226b9895abc57c9bfce5e3fa2d (patch) | |
tree | a3d2a5a909b6372f7777c1c5c18cef5f81d123a9 /include/linux/rwsem.h | |
parent | 7f4191a202ea4558ca2d5eb8a47daea33c9999c7 (diff) |
bcache in userspace; userspace fsck
Diffstat (limited to 'include/linux/rwsem.h')
-rw-r--r-- | include/linux/rwsem.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h new file mode 100644 index 00000000..9d70e6e2 --- /dev/null +++ b/include/linux/rwsem.h @@ -0,0 +1,28 @@ +#ifndef __TOOLS_LINUX_RWSEM_H +#define __TOOLS_LINUX_RWSEM_H + +#include <pthread.h> + +struct rw_semaphore { + pthread_rwlock_t lock; +}; + +#define __RWSEM_INITIALIZER(name) \ + { .lock = PTHREAD_RWLOCK_INITIALIZER } + +#define DECLARE_RWSEM(name) \ + struct rw_semaphore name = __RWSEM_INITIALIZER(name) + +static inline void init_rwsem(struct rw_semaphore *lock) +{ + pthread_rwlock_init(&lock->lock, NULL); +} + +#define down_read(l) pthread_rwlock_rdlock(&(l)->lock) +#define down_read_trylock(l) (!pthread_rwlock_tryrdlock(&(l)->lock)) +#define up_read(l) pthread_rwlock_unlock(&(l)->lock) + +#define down_write(l) pthread_rwlock_wrlock(&(l)->lock) +#define up_write(l) pthread_rwlock_unlock(&(l)->lock) + +#endif /* __TOOLS_LINUX_RWSEM_H */ |