Skip to content

Commit c52e5ef

Browse files
committed
Fix preprocessor evaluation when __GLIBC_PREFREQ is not defined
1 parent 3e72a15 commit c52e5ef

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

lightweightsemaphore.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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

3137
namespace 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);

0 commit comments

Comments
 (0)