summaryrefslogtreecommitdiff
path: root/src/semaphore.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2016-05-21 19:44:02 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2016-05-21 19:44:02 +0200
commitea1ef4ab8f2c3ba51a574029e8b475d40c9fb9c6 (patch)
tree545aa2f1bcbf59cb44d4019738e61275854aa4ac /src/semaphore.cc
parentbcdb1a5e8caa5dc7254a58b08677b399ac4e6666 (diff)
Use platform in semaphore.
Diffstat (limited to 'src/semaphore.cc')
-rw-r--r--src/semaphore.cc19
1 files changed, 3 insertions, 16 deletions
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 <errno.h>
#include <stdio.h>
-
-#if DG_PLATFORM == DG_PLATFORM_LINUX
#include <time.h>
-#else
-#include <sys/time.h>
#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);