libnx/nx/source/kernel/rwlock.c
TuxSH 5abc4873d8 Include only what is really necessary...
add pragma once in every header, etc.
2018-01-22 18:42:57 +01:00

30 lines
488 B
C

// Copyright 2018 plutoo
#include <switch/kernel/mutex.h>
#include <switch/kernel/rwlock.h>
void rwlockReadLock(RwLock* r) {
rmutexLock(&r->r);
if (r->b++ == 0)
rmutexLock(&r->g);
rmutexUnlock(&r->r);
}
void rwlockReadUnlock(RwLock* r) {
rmutexLock(&r->r);
if (r->b-- == 1)
rmutexUnlock(&r->g);
rmutexUnlock(&r->r);
}
void rwlockWriteLock(RwLock* r) {
rmutexLock(&r->g);
}
void rwlockWriteUnlock(RwLock* r) {
rmutexUnlock(&r->g);
}