From 1a4e50c88cfd2816b2addd9b135e27b20fc2e162 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 8 Dec 2016 19:00:10 +0100 Subject: Revert to using sem_* function family for FreeBSD. --- src/semaphore.cc | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/src/semaphore.cc b/src/semaphore.cc index 77bce9a..42c9aec 100644 --- a/src/semaphore.cc +++ b/src/semaphore.cc @@ -33,16 +33,7 @@ #include "platform.h" -#if DG_PLATFORM == DG_PLATFORM_OSX -//#include -#include - -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD -#include -#include -#include - -#elif DG_PLATFORM != DG_PLATFORM_WINDOWS +#if DG_PLATFORM != DG_PLATFORM_WINDOWS // Make sure we don't include /this/ file's header... #include <../include/semaphore.h> #include @@ -50,13 +41,16 @@ #include #endif +#if DG_PLATFORM == DG_PLATFORM_OSX +//#include +#include +#endif + struct semaphore_private_t { #if DG_PLATFORM == DG_PLATFORM_WINDOWS HANDLE semaphore; #elif DG_PLATFORM == DG_PLATFORM_OSX MPSemaphoreID semaphore; -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD - struct sema *semaphore; #else sem_t semaphore; #endif @@ -75,8 +69,6 @@ Semaphore::Semaphore(std::size_t initial_count) MPCreateSemaphore(std::numeric_limits::max(), initial_count, &prv->semaphore); -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD - sema_init(prv->semaphore, initial_count, ""); #else const int pshared = 0; memset(&prv->semaphore, 0, sizeof(sem_t)); @@ -90,7 +82,6 @@ Semaphore::~Semaphore() CloseHandle(prv->semaphore); #elif DG_PLATFORM == DG_PLATFORM_OSX MPDeleteSemaphore(prv->semaphore); -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD #else sem_destroy(&prv->semaphore); #endif @@ -104,8 +95,6 @@ void Semaphore::post() ReleaseSemaphore(prv->semaphore, 1, nullptr); #elif DG_PLATFORM == DG_PLATFORM_OSX MPSignalSemaphore(prv->semaphore); -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD - sema_destroy(prv->semaphore) #else sem_post(&prv->semaphore); #endif @@ -128,12 +117,6 @@ bool Semaphore::wait(const std::chrono::milliseconds& timeout) { return false; } -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD - auto ret = sema_timedwait(prv->semaphore, timeout.count()); - if(ret != 0) - { - return false; - } #else struct timespec ts; @@ -179,8 +162,6 @@ void Semaphore::wait() WaitForSingleObject(prv->semaphore, INFINITE); #elif DG_PLATFORM == DG_PLATFORM_OSX MPWaitOnSemaphore(prv->semaphore, kDurationForever); -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD - sema_wait(prv->semaphore); #else sem_wait(&prv->semaphore); #endif -- cgit v1.2.3