From e6d03e05f4c5342eb12eb6249c068b38d8d68c71 Mon Sep 17 00:00:00 2001 From: plutooo Date: Thu, 28 Mar 2019 23:17:50 +0100 Subject: [PATCH] rwlock: Review comments --- nx/include/switch/kernel/rwlock.h | 4 ++-- nx/source/kernel/rwlock.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nx/include/switch/kernel/rwlock.h b/nx/include/switch/kernel/rwlock.h index e100bac4..bf23edaa 100644 --- a/nx/include/switch/kernel/rwlock.h +++ b/nx/include/switch/kernel/rwlock.h @@ -13,8 +13,8 @@ typedef struct { Mutex mutex; CondVar condvar_readers; CondVar condvar_writer; - u64 readers; - bool writer; + u32 readers : 31; + bool writer : 1; } RwLock; /** diff --git a/nx/source/kernel/rwlock.c b/nx/source/kernel/rwlock.c index a39680ef..1da465ad 100644 --- a/nx/source/kernel/rwlock.c +++ b/nx/source/kernel/rwlock.c @@ -26,7 +26,7 @@ void rwlockReadLock(RwLock* r) { void rwlockReadUnlock(RwLock* r) { mutexLock(&r->mutex); - if (r->readers-- == 1) { + if (--r->readers == 0) { condvarWakeAll(&r->condvar_readers); }