Staging
v0.8.1
https://github.com/torvalds/linux
Raw File
Tip revision: 88603b6dc419445847923fcb7fe5080067a30f98 authored by Linus Torvalds on 01 January 2023, 21:53:16 UTC
Linux 6.2-rc2
Tip revision: 88603b6
rwsem.c
// SPDX-License-Identifier: GPL-2.0
#include "util.h"
#include "rwsem.h"

int init_rwsem(struct rw_semaphore *sem)
{
	return pthread_rwlock_init(&sem->lock, NULL);
}

int exit_rwsem(struct rw_semaphore *sem)
{
	return pthread_rwlock_destroy(&sem->lock);
}

int down_read(struct rw_semaphore *sem)
{
	return perf_singlethreaded ? 0 : pthread_rwlock_rdlock(&sem->lock);
}

int up_read(struct rw_semaphore *sem)
{
	return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
}

int down_write(struct rw_semaphore *sem)
{
	return perf_singlethreaded ? 0 : pthread_rwlock_wrlock(&sem->lock);
}

int up_write(struct rw_semaphore *sem)
{
	return perf_singlethreaded ? 0 : pthread_rwlock_unlock(&sem->lock);
}
back to top