From cd17a3156c6e75243352dc9a78b08e722152ab12 Mon Sep 17 00:00:00 2001 From: falkTX Date: Fri, 24 Nov 2023 11:58:45 +0100 Subject: [PATCH] Fixup Semaphore.hpp for macOS Signed-off-by: falkTX --- src/Semaphore.hpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Semaphore.hpp b/src/Semaphore.hpp index 44d3bdd..10333a6 100644 --- a/src/Semaphore.hpp +++ b/src/Semaphore.hpp @@ -33,22 +33,20 @@ class Semaphore Semaphore(const int initialValue = 0) { #if defined(DISTRHO_OS_MAC) - DISTRHO_SAFE_ASSERT_RETURN(semaphore_create(mach_task_self(), - &sem, - SYNC_POLICY_FIFO, - initialValue) == KERN_SUCCESS,); + task = mach_task_self(); + DISTRHO_SAFE_ASSERT_RETURN(semaphore_create(task, &sem, SYNC_POLICY_FIFO, initialValue) == KERN_SUCCESS,); #elif defined(DISTRHO_OS_WINDOWS) handle = ::CreateSemaphoreA(nullptr, initialValue, std::max(initialValue, 1), nullptr); DISTRHO_SAFE_ASSERT_RETURN(handle != INVALID_HANDLE_VALUE,); #else - ::sem_init(&sem, 0, initialValue); + DISTRHO_SAFE_ASSERT_RETURN(::sem_init(&sem, 0, initialValue) == 0,); #endif } ~Semaphore() { #if defined(DISTRHO_OS_MAC) - ::semaphore_destroy(mach_task_self(), sem); + ::semaphore_destroy(task, sem); #elif defined(DISTRHO_OS_WINDOWS) ::CloseHandle(handle); #else @@ -95,6 +93,7 @@ class Semaphore private: #if defined(DISTRHO_OS_MAC) + ::mach_port_t task; ::semaphore_t sem; #elif defined(DISTRHO_OS_WINDOWS) ::HANDLE handle;