1 /* SPDX-License-Identifier: GPL-2.0+ */
2 #ifndef _TOOLS__RWSEM_H
3 #define _TOOLS__RWSEM_H
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);
40 #endif /* _TOOLS_RWSEM_H */