From ea1ef4ab8f2c3ba51a574029e8b475d40c9fb9c6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 21 May 2016 19:44:02 +0200 Subject: Use platform in semaphore. --- src/semaphore.cc | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/semaphore.cc b/src/semaphore.cc index 3c321fa..e872ff2 100644 --- a/src/semaphore.cc +++ b/src/semaphore.cc @@ -38,11 +38,7 @@ #include <../include/semaphore.h> #include #include - -#if DG_PLATFORM == DG_PLATFORM_LINUX #include -#else -#include #endif #endif @@ -104,21 +100,12 @@ bool Semaphore::wait(const std::chrono::milliseconds& timeout) #else struct timespec ts; -#if DG_PLATFORM == DG_PLATFORM_LINUX - // Get current time - clock_gettime(CLOCK_REALTIME, &ts); -#elif defined(DG_POSIX) struct timeval now; int rv = gettimeofday(&now, NULL); + assert(rv == 0); - if (rv == 0) - { - ts->tv_sec = now.tv_sec; - ts->tv_nsec = now.tv_usec * 1000; - } -#else - #error "Neither linux nor POSIX!" -#endif + ts->tv_sec = now.tv_sec; + ts->tv_nsec = now.tv_usec * 1000; // Add timeout time_t seconds = (time_t)(timeout.count() / 1000); -- cgit v1.2.3