0002-configure.ac-Fix-check-for-CLOCK_MONOTONIC.patch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. Discover monotonic clock using compile-time check
  2. monotonic clock check does not work when cross-compiling.
  3. Upstream-Status: Denied [Does not work on OpenBSD]
  4. Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
  5. Original patch follows:
  6. When xorg-xserver is being cross-compiled, there is currently no way
  7. for us to detect whether the monotonic clock is available on the
  8. target system, because we aren't able to run a test program on the host
  9. system. Currently, in this situation, we default to not use the
  10. monotonic clock. One problem with this situation is that the user will
  11. be treated as idle when the date is updated.
  12. To fix this situation, we now use a compile-time check to detect whether the
  13. monotonic clock is available. This check can run just fine when we are
  14. cross-compiling.
  15. Signed-off-by: David James <davidjames at google.com>
  16. Downloaded from
  17. https://github.com/openembedded/openembedded-core/blob/master/meta/recipes-graphics/xorg-xserver/xserver-xorg/0001-configure.ac-Fix-check-for-CLOCK_MONOTONIC.patch
  18. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  19. ---
  20. configure.ac | 17 +++++++----------
  21. 1 file changed, 7 insertions(+), 10 deletions(-)
  22. diff --git a/configure.ac b/configure.ac
  23. index f7ab48c..26e85cd 100644
  24. --- a/configure.ac
  25. +++ b/configure.ac
  26. @@ -1048,19 +1048,16 @@ if ! test "x$have_clock_gettime" = xno; then
  27. CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
  28. fi
  29. - AC_RUN_IFELSE([AC_LANG_SOURCE([
  30. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
  31. #include <time.h>
  32. -
  33. -int main(int argc, char *argv[[]]) {
  34. - struct timespec tp;
  35. -
  36. - if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
  37. +#include <unistd.h>
  38. +int main() {
  39. +#if !(defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 && defined(CLOCK_MONOTONIC))
  40. + #error No monotonic clock
  41. +#endif
  42. return 0;
  43. - else
  44. - return 1;
  45. }
  46. - ])], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
  47. - [MONOTONIC_CLOCK="cross compiling"])
  48. +]])],[MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no])
  49. LIBS="$LIBS_SAVE"
  50. CPPFLAGS="$CPPFLAGS_SAVE"
  51. --
  52. 2.1.4