diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-12-08 19:00:10 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-12-08 19:00:10 +0100 |
commit | 1a4e50c88cfd2816b2addd9b135e27b20fc2e162 (patch) | |
tree | 43c1270d309a73c646d4f7028cc6af796d8911fb /src/semaphore.cc | |
parent | 6796cfa72452552cc4d0f6bcfdbecace682ea1f6 (diff) |
Revert to using sem_* function family for FreeBSD.
Diffstat (limited to 'src/semaphore.cc')
-rw-r--r-- | src/semaphore.cc | 31 |
1 files 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 <Multiprocessing.h> -#include <CoreServices/CoreServices.h> - -#elif DG_PLATFORM == DG_PLATFORM_FREEBSD -#include <sys/types.h> -#include <sys/lock.h> -#include <sys/sema.h> - -#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 <errno.h> @@ -50,13 +41,16 @@ #include <sys/time.h> #endif +#if DG_PLATFORM == DG_PLATFORM_OSX +//#include <Multiprocessing.h> +#include <CoreServices/CoreServices.h> +#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<std::uint32_t>::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 |