Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 1 | From e6fbad0c122ba8e87b67a9e2447505adcaafe204 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Wed, 29 Mar 2017 16:31:38 -0700 |
| 4 | Subject: [PATCH] Remove runtime check for CLOCK_MONOTONIC |
| 5 | |
| 6 | Does not work during cross compile |
| 7 | |
| 8 | use a compile-time check to detect whether the |
| 9 | monotonic clock is available. This check can run just fine when we are |
| 10 | cross-compiling. |
| 11 | |
| 12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 13 | --- |
| 14 | configure.ac | 12 ++++++++++-- |
| 15 | 1 file changed, 10 insertions(+), 2 deletions(-) |
| 16 | |
| 17 | diff --git a/configure.ac b/configure.ac |
| 18 | index fa13ae6..f4f0f46 100644 |
| 19 | --- a/configure.ac |
| 20 | +++ b/configure.ac |
| 21 | @@ -175,9 +175,17 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 22 | ) |
| 23 | |
| 24 | AC_MSG_CHECKING(for a working clock_getres(CLOCK_MONOTONIC, &ts)) |
| 25 | -AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 26 | +AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 27 | [[#include <time.h>]], |
| 28 | -[[struct timespec ts; if(clock_getres(CLOCK_MONOTONIC, &ts)) return -1;]])], |
| 29 | +[[ |
| 30 | +#include <unistd.h> |
| 31 | +int main() { |
| 32 | +#if !(defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 && defined(CLOCK_MONOTONIC)) |
| 33 | + #error No monotonic clock |
| 34 | +#endif |
| 35 | + return 0; |
| 36 | + |
| 37 | +]])], |
| 38 | [ |
| 39 | AC_MSG_RESULT([yes]) |
| 40 | AC_DEFINE_UNQUOTED([HAVE_CLOCK_GETRES_MONOTONIC], 1, [Define to 1 if clock_getres(CLOCK_MONOTONIC, &ts) works]) |
| 41 | -- |
| 42 | 2.12.1 |
| 43 | |