WIP FPC-III support
[linux/fpc-iii.git] / tools / perf / util / rwsem.c
blobf3d29d8ddc991e14d1bc0c0cbf275ea31927a09c
1 // SPDX-License-Identifier: GPL-2.0
2 #include "util.h"
3 #include "rwsem.h"
5 int init_rwsem(struct rw_semaphore *sem)
7 return pthread_rwlock_init(&sem->lock, NULL);
10 int exit_rwsem(struct rw_semaphore *sem)
12 return pthread_rwlock_destroy(&sem->lock);
15 int down_read(struct rw_semaphore *sem)
17 return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock);
20 int up_read(struct rw_semaphore *sem)
22 return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
25 int down_write(struct rw_semaphore *sem)
27 return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock);
30 int up_write(struct rw_semaphore *sem)
32 return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);