Avoid repeated ifdef checks in code by adding a project specific
preprocessor definition.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
#ifndef UTIL_LINUX_MONOTONIC_H
#define UTIL_LINUX_MONOTONIC_H
+# ifdef CLOCK_MONOTONIC_RAW
+# define UL_CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW
+# else
+# define UL_CLOCK_MONOTONIC CLOCK_MONOTONIC
+# endif
+
#include <sys/time.h>
extern int get_boot_time(struct timeval *boot_time);
int ret;
struct timespec ts;
-# ifdef CLOCK_MONOTONIC_RAW
/* Linux specific, can't slew */
- if (!(ret = clock_gettime(CLOCK_MONOTONIC_RAW, &ts))) {
-# else
- if (!(ret = clock_gettime(CLOCK_MONOTONIC, &ts))) {
-# endif
+ if (!(ret = clock_gettime(UL_CLOCK_MONOTONIC, &ts))) {
tv->tv_sec = ts.tv_sec;
tv->tv_usec = ts.tv_nsec / 1000;
}