1 // SPDX-License-Identifier: GPL-2.0
9 int init_rwsem(struct rw_semaphore
*sem
)
12 mutex_init(&sem
->mtx
);
15 return pthread_rwlock_init(&sem
->lock
, NULL
);
19 int exit_rwsem(struct rw_semaphore
*sem
)
22 mutex_destroy(&sem
->mtx
);
25 return pthread_rwlock_destroy(&sem
->lock
);
29 int down_read(struct rw_semaphore
*sem
)
32 mutex_lock(&sem
->mtx
);
35 return perf_singlethreaded
? 0 : pthread_rwlock_rdlock(&sem
->lock
);
39 int up_read(struct rw_semaphore
*sem
)
42 mutex_unlock(&sem
->mtx
);
45 return perf_singlethreaded
? 0 : pthread_rwlock_unlock(&sem
->lock
);
49 int down_write(struct rw_semaphore
*sem
)
52 mutex_lock(&sem
->mtx
);
55 return perf_singlethreaded
? 0 : pthread_rwlock_wrlock(&sem
->lock
);
59 int up_write(struct rw_semaphore
*sem
)
62 mutex_unlock(&sem
->mtx
);
65 return perf_singlethreaded
? 0 : pthread_rwlock_unlock(&sem
->lock
);