File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ extern "C" {
2626#include < mach/mach.h>
2727#elif defined(__unix__)
2828#include < semaphore.h>
29+
30+ #if defined(__GLIBC_PREREQ) && defined(_GNU_SOURCE)
31+ #if __GLIBC_PREREQ(2,30)
32+ #define MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
33+ #endif
34+ #endif
2935#endif
3036
3137namespace moodycamel
@@ -209,7 +215,7 @@ class Semaphore
209215 struct timespec ts;
210216 const int usecs_in_1_sec = 1000000 ;
211217 const int nsecs_in_1_sec = 1000000000 ;
212- #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,30) && defined(_GNU_SOURCE)
218+ #ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
213219 clock_gettime (CLOCK_MONOTONIC , &ts);
214220#else
215221 clock_gettime (CLOCK_REALTIME , &ts);
@@ -225,7 +231,7 @@ class Semaphore
225231
226232 int rc;
227233 do {
228- #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,30) && defined(_GNU_SOURCE)
234+ #ifdef MOODYCAMEL_LIGHTWEIGHTSEMAPHORE_MONOTONIC
229235 rc = sem_clockwait (&m_sema, CLOCK_MONOTONIC , &ts);
230236#else
231237 rc = sem_timedwait (&m_sema, &ts);
You can’t perform that action at this time.
0 commit comments