From 8da9ee1ec328b96c28d262694d7f85d3332ab1f8 Mon Sep 17 00:00:00 2001 From: Clint Byrum Date: Sun, 8 Oct 2017 19:40:26 -0700 Subject: [PATCH] Switch to named semaphores for compatability Mac OS X has deprecated unnamed semaphores. This solves the problem and maintains compatibility with all other POSIX implementations. --- libtest/signal.cc | 6 +++--- libtest/signal.h | 3 ++- util/signal.cc | 6 ++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/libtest/signal.cc b/libtest/signal.cc index 24a40b1b6..93176da8d 100644 --- a/libtest/signal.cc +++ b/libtest/signal.cc @@ -87,7 +87,7 @@ shutdown_t SignalThread::get_shutdown() void SignalThread::post() { - sem_post(&lock); + sem_post(lock); } void SignalThread::test() @@ -131,7 +131,7 @@ SignalThread::~SignalThread() pthread_join(thread, &retval); } #endif - sem_destroy(&lock); + sem_close(lock); unblock(); } @@ -265,7 +265,7 @@ bool SignalThread::setup() return false; } - sem_wait(&lock); + sem_wait(lock); return true; } diff --git a/libtest/signal.h b/libtest/signal.h index 6e68bb387..47390eb4e 100644 --- a/libtest/signal.h +++ b/libtest/signal.h @@ -50,7 +50,8 @@ namespace libtest { class SignalThread { sigset_t set; - sem_t lock; + char lock_name[10]; + sem_t *lock; uint64_t magic_memory; volatile shutdown_t __shutdown; pthread_mutex_t shutdown_mutex; diff --git a/util/signal.cc b/util/signal.cc index 922671067..adf78b7a3 100644 --- a/util/signal.cc +++ b/util/signal.cc @@ -35,6 +35,8 @@ */ #include "gear_config.h" +#include +#include #include #include @@ -88,7 +90,7 @@ shutdown_t SignalThread::get_shutdown() void SignalThread::post() { - sem_post(&lock); + sem_post(lock); } void SignalThread::test() @@ -129,7 +131,7 @@ SignalThread::~SignalThread() pthread_join(thread, &retval); } #endif - sem_destroy(&lock); + sem_close(lock); } extern "C" {