[PATCH] Enable configuration of the MONOTONIC_CLOCK when cross-compiling.

David James davidjames at google.com
Tue May 18 15:17:33 PDT 2010


When xorg-xserver is being cross-compiled, there is currently no way
for us to detect whether the monotonic clock is available on the
target system. Currently, in this situation, we default to not use the
monotonic clock. One problem with this situation is that the user will
be treated as idle when the date is updated.

To fix this situation, this patch creates a new variable called
xorg_cv_MONOTONIC_CLOCK. If packagers who cross-compile setup this
variable appropriately, then we can enable usage of the
MONOTONIC_CLOCK when cross-compiling.

Cheers,

David

P.S. In my patch, I looked at just fixing configure.ac to properly
allow packages to configure whether they use the monotonic clock. An
alternative solution, which would have deeper implications, would be
to instead just do a compile check, like liboil does. (Search for
MONOTONIC in http://cgit.freedesktop.org/liboil/tree/configure.ac ).
Since compile checks don't require us to run the program, it works
when cross-compiling. But I wasn't sure if the compile check used by
liboil would be good enough for xorg-server, so I just enabled a
configuration variable.
-------------- next part --------------
From 6d363cc4a9f4985cab1d05ad9830d762a7174423 Mon Sep 17 00:00:00 2001
From: David James <davidjames at google.com>
Date: Tue, 18 May 2010 14:04:11 -0700
Subject: [PATCH] Enable configuration of the MONOTONIC_CLOCK when cross-compiling.

When xorg-xserver is being cross-compiled, there is no way for us to detect
whether the monotonic clock is available on the target system. Currently, in
this situation, we default to not use the monotonic clock. One problem with
this situation is that the user may be treated as idle when the date is
updated.

To fix this situation, this patch creates a new variable called
xorg_cv_MONOTONIC_CLOCK. If packagers who cross-compile setup this variable
appropriately, then we can enable usage of the MONOTONIC_CLOCK when
cross-compiling.

Signed-off-by: David James <davidjames at google.com>
---
 configure.ac |   38 +++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1c7875e..0a54c3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -891,24 +891,25 @@ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
                [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
                              [have_clock_gettime=no])])
 
-AC_MSG_CHECKING([for a useful monotonic clock ...])
-
 if ! test "x$have_clock_gettime" = xno; then
     if ! test "x$have_clock_gettime" = xyes; then
         CLOCK_LIBS="$have_clock_gettime"
     else
         CLOCK_LIBS=""
     fi
+fi
 
-    LIBS_SAVE="$LIBS"
-    LIBS="$CLOCK_LIBS"
-    CPPFLAGS_SAVE="$CPPFLAGS"
+AC_CACHE_CHECK([for a useful monotonic clock ...], xorg_cv_MONOTONIC_CLOCK, [
+    if ! test "x$have_clock_gettime" = xno; then
+        LIBS_SAVE="$LIBS"
+        LIBS="$CLOCK_LIBS"
+        CPPFLAGS_SAVE="$CPPFLAGS"
 
-    if test x"$glibc" = xyes; then
-        CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
-    fi
+        if test x"$glibc" = xyes; then
+            CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
+        fi
 
-    AC_RUN_IFELSE([
+        AC_RUN_IFELSE([
 #include <time.h>
 
 int main(int argc, char *argv[[]]) {
@@ -919,18 +920,17 @@ int main(int argc, char *argv[[]]) {
     else
         return 1;
 }
-    ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
-       [MONOTONIC_CLOCK="cross compiling"])
-
-    LIBS="$LIBS_SAVE"
-    CPPFLAGS="$CPPFLAGS_SAVE"
-else
-    MONOTONIC_CLOCK=no
-fi
+        ], [xorg_cv_MONOTONIC_CLOCK=yes], [xorg_cv_MONOTONIC_CLOCK=no],
+           [xorg_cv_MONOTONIC_CLOCK="cross compiling"])
 
-AC_MSG_RESULT([$MONOTONIC_CLOCK])
+        LIBS="$LIBS_SAVE"
+        CPPFLAGS="$CPPFLAGS_SAVE"
+    else
+        xorg_cv_MONOTONIC_CLOCK=no
+    fi
+])
 
-if test "x$MONOTONIC_CLOCK" = xyes; then
+if test "x$xorg_cv_MONOTONIC_CLOCK" = xyes; then
     AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
     LIBS="$LIBS $CLOCK_LIBS"
 fi
-- 
1.7.0.1


More information about the xorg-devel mailing list