From ccab6aa73733d5d6bfdf44e4fbc2d1a56037bad3 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sat, 8 Sep 2018 23:47:15 -0700 Subject: [PATCH] pm: Support for 6.0.0 --- include/stratosphere/hossynch.hpp | 40 ++++++++----------------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/include/stratosphere/hossynch.hpp b/include/stratosphere/hossynch.hpp index 0d2b8e8f..56facd13 100644 --- a/include/stratosphere/hossynch.hpp +++ b/include/stratosphere/hossynch.hpp @@ -66,15 +66,15 @@ class HosCondVar { public: HosCondVar() { mutexInit(&m); - condvarInit(&cv, &m); + condvarInit(&cv); } Result WaitTimeout(u64 timeout) { - return condvarWaitTimeout(&cv, timeout); + return condvarWaitTimeout(&cv, &m, timeout); } Result Wait() { - return condvarWait(&cv); + return condvarWait(&cv, &m); } Result Wake(int num) { @@ -92,45 +92,25 @@ class HosCondVar { class HosSemaphore { private: - CondVar cv; - Mutex m; - u64 count; + Semaphore s; public: HosSemaphore() { - count = 0; - mutexInit(&m); - condvarInit(&cv, &m); + semaphoreInit(&s, 0); } - HosSemaphore(u64 c) : count(c) { - mutexInit(&m); - condvarInit(&cv, &m); + HosSemaphore(u64 c) { + semaphoreInit(&s, c); } void Signal() { - mutexLock(&this->m); - count++; - condvarWakeOne(&cv); - mutexUnlock(&this->m); + semaphoreSignal(&s); } void Wait() { - mutexLock(&this->m); - while (!count) { - condvarWait(&cv); - } - count--; - mutexUnlock(&this->m); + semaphoreWait(&s); } bool TryWait() { - mutexLock(&this->m); - bool success = false; - if (count) { - count--; - success = true; - } - mutexUnlock(&this->m); - return success; + return semaphoreTryWait(&s); } };