mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
30 lines
488 B
C
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);
|
|
}
|