mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-18 03:30:43 +00:00
CLEANUP: time: refine the test on _POSIX_TIMERS
The clock_gettime() man page says we must check that _POSIX_TIMERS is defined to a value greater than zero, not just that it's simply defined so let's fix this right now.
This commit is contained in:
parent
aacc405c1f
commit
f61782418c
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user