Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / include / linux / rwsem.h
blobf8bffd4a987cc35243a80a7a20c04d5ce5bdec62
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #ifndef _TOOLS__RWSEM_H
3 #define _TOOLS__RWSEM_H
5 #include <pthread.h>
7 struct rw_semaphore {
8 pthread_rwlock_t lock;
9 };
11 static inline int init_rwsem(struct rw_semaphore *sem)
13 return pthread_rwlock_init(&sem->lock, NULL);
16 static inline int exit_rwsem(struct rw_semaphore *sem)
18 return pthread_rwlock_destroy(&sem->lock);
21 static inline int down_read(struct rw_semaphore *sem)
23 return pthread_rwlock_rdlock(&sem->lock);
26 static inline int up_read(struct rw_semaphore *sem)
28 return pthread_rwlock_unlock(&sem->lock);
31 static inline int down_write(struct rw_semaphore *sem)
33 return pthread_rwlock_wrlock(&sem->lock);
36 static inline int up_write(struct rw_semaphore *sem)
38 return pthread_rwlock_unlock(&sem->lock);
41 #define down_read_nested(sem, subclass) down_read(sem)
42 #define down_write_nested(sem, subclass) down_write(sem)
44 #endif /* _TOOLS_RWSEM_H */