]> code.ossystems Code Review - openembedded-core.git/blob
020a1cf37ce332334fbbbd29ede7e9b4b2cb5545
[openembedded-core.git] /
1 From 8a91316c4a38f20e7866289f3d779a037d27a129 Mon Sep 17 00:00:00 2001
2 From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3 Date: Mon, 12 Dec 2016 12:11:39 +0200
4 Subject: [PATCH] Discover monotonic clock using compile-time check
5
6 monotonic clock check does not work when cross-compiling.
7
8 Upstream-Status: Denied [Does not work on OpenBSD]
9 Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
10
11 Original patch follows:
12
13 When xorg-xserver is being cross-compiled, there is currently no way
14 for us to detect whether the monotonic clock is available on the
15 target system, because we aren't able to run a test program on the host
16 system. Currently, in this situation, we default to not use the
17 monotonic clock. One problem with this situation is that the user will
18 be treated as idle when the date is updated.
19
20 To fix this situation, we now use a compile-time check to detect whether the
21 monotonic clock is available. This check can run just fine when we are
22 cross-compiling.
23
24 Signed-off-by: David James <davidjames at google.com>
25
26 ---
27  configure.ac | 17 +++++++----------
28  1 file changed, 7 insertions(+), 10 deletions(-)
29
30 diff --git a/configure.ac b/configure.ac
31 index 2b21667..786e002 100644
32 --- a/configure.ac
33 +++ b/configure.ac
34 @@ -984,19 +984,16 @@ if ! test "x$have_clock_gettime" = xno; then
35          CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
36      fi
37  
38 -    AC_RUN_IFELSE([AC_LANG_SOURCE([
39 +    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
40  #include <time.h>
41 -
42 -int main(int argc, char *argv[[]]) {
43 -    struct timespec tp;
44 -
45 -    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
46 +#include <unistd.h>
47 +int main() {
48 +#if !(defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 && defined(CLOCK_MONOTONIC))
49 +        #error No monotonic clock
50 +#endif
51          return 0;
52 -    else
53 -        return 1;
54  }
55 -    ])], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
56 -       [MONOTONIC_CLOCK="cross compiling"])
57 +]])],[MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no])
58  
59      if test "$MONOTONIC_CLOCK" = "cross compiling"; then
60          AC_CHECK_DECL([CLOCK_MONOTONIC],[MONOTONIC_CLOCK="guessing yes"],[MONOTONIC_CLOCK=no],[#include <time.h>])