linux/tools/perf/util/rwsem.c
<<
>>
Prefs
   1#include "util.h"
   2#include "rwsem.h"
   3
   4int init_rwsem(struct rw_semaphore *sem)
   5{
   6        return pthread_rwlock_init(&sem->lock, NULL);
   7}
   8
   9int exit_rwsem(struct rw_semaphore *sem)
  10{
  11        return pthread_rwlock_destroy(&sem->lock);
  12}
  13
  14int down_read(struct rw_semaphore *sem)
  15{
  16        return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock);
  17}
  18
  19int up_read(struct rw_semaphore *sem)
  20{
  21        return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
  22}
  23
  24int down_write(struct rw_semaphore *sem)
  25{
  26        return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock);
  27}
  28
  29int up_write(struct rw_semaphore *sem)
  30{
  31        return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
  32}
  33