diff --git a/include/common/compat.h b/include/common/compat.h index d43b89dd6..35782dee2 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -99,7 +99,7 @@ #endif /* systems without such defines do not know clockid_t */ -#if !defined(_POSIX_TIMERS) || (_POSIX_C_SOURCE < 199309L) +#if !(_POSIX_TIMERS > 0) || (_POSIX_C_SOURCE < 199309L) #define clockid_t int #undef CLOCK_REALTIME #undef CLOCK_MONOTONIC diff --git a/include/common/time.h b/include/common/time.h index 9920a77ae..2633b1c5e 100644 --- a/include/common/time.h +++ b/include/common/time.h @@ -519,7 +519,7 @@ REGPRM3 static inline struct timeval *__tv_ms_add(struct timeval *tv, const stru /* returns the system's monotonic time in nanoseconds if supported, otherwise zero */ static inline uint64_t now_mono_time() { -#if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK) +#if (_POSIX_TIMERS > 0) && defined(_POSIX_MONOTONIC_CLOCK) struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec * 1000000000ULL + ts.tv_nsec; @@ -531,7 +531,7 @@ static inline uint64_t now_mono_time() /* returns the current thread's cumulated CPU time in nanoseconds if supported, otherwise zero */ static inline uint64_t now_cpu_time() { -#if defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME) +#if (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME) struct timespec ts; clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts); return ts.tv_sec * 1000000000ULL + ts.tv_nsec; @@ -543,7 +543,7 @@ static inline uint64_t now_cpu_time() /* returns another thread's cumulated CPU time in nanoseconds if supported, otherwise zero */ static inline uint64_t now_cpu_time_thread(const struct thread_info *thr) { -#if defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME) +#if (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME) struct timespec ts; clock_gettime(thr->clock_id, &ts); return ts.tv_sec * 1000000000ULL + ts.tv_nsec; diff --git a/src/haproxy.c b/src/haproxy.c index f85f15fb4..f5d72e654 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -2511,7 +2511,7 @@ static void *run_thread_poll_loop(void *data) ha_set_tid((unsigned long)data); -#if defined(_POSIX_TIMERS) && defined(_POSIX_THREAD_CPUTIME) +#if (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME) #ifdef USE_THREAD pthread_getcpuclockid(pthread_self(), &ti->clock_id); #else