• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0
2 #include "util.h"
3 #include "rwsem.h"
4 
init_rwsem(struct rw_semaphore * sem)5 int init_rwsem(struct rw_semaphore *sem)
6 {
7 	return pthread_rwlock_init(&sem->lock, NULL);
8 }
9 
exit_rwsem(struct rw_semaphore * sem)10 int exit_rwsem(struct rw_semaphore *sem)
11 {
12 	return pthread_rwlock_destroy(&sem->lock);
13 }
14 
down_read(struct rw_semaphore * sem)15 int down_read(struct rw_semaphore *sem)
16 {
17 	return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock);
18 }
19 
up_read(struct rw_semaphore * sem)20 int up_read(struct rw_semaphore *sem)
21 {
22 	return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
23 }
24 
down_write(struct rw_semaphore * sem)25 int down_write(struct rw_semaphore *sem)
26 {
27 	return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock);
28 }
29 
up_write(struct rw_semaphore * sem)30 int up_write(struct rw_semaphore *sem)
31 {
32 	return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
33 }
34