]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(gl_PREREQ_GETHRXTIME): Require gl_CLOCK_TIME,
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Feb 2005 07:09:13 +0000 (07:09 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 22 Feb 2005 07:09:13 +0000 (07:09 +0000)
gl_USE_SYSTEM_EXTENSIONS.  Check whether CLOCK_MONOTONIC is
defined, and set LIB_GETHRXTIME accordingly.  This is needed
for newer GNU/Linux systems that have clock_gettime, so that they
link in the appropriate library for it when needed.

m4/gethrxtime.m4

index 89c6a21e7d17c0e59ccc673a43b8f553a12268f4..82ca6280ee8727d8bd224eb4d3fb8eba3be1b651 100644 (file)
@@ -1,9 +1,11 @@
-# gethrxtime.m4 serial 1
+# gethrxtime.m4 serial 2
 dnl Copyright (C) 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
+dnl Written by Paul Eggert.
+
 AC_DEFUN([gl_GETHRXTIME],
 [
   AC_LIBSOURCES([gethrxtime.c, gethrxtime.h, xtime.h])
@@ -48,10 +50,27 @@ AC_DEFUN([gl_XTIME],
 # Prerequisites of lib/gethrxtime.c.
 AC_DEFUN([gl_PREREQ_GETHRXTIME],
 [
-  dnl Do not AC_REQUIRE([gl_CLOCK_TIME]), since that would unnecessarily
-  dnl require -lrt on Solaris.  Invocations of clock_gettime should be
-  dnl safe in gethrxtime.c since Solaris has native gethrtime.
   AC_REQUIRE([AC_HEADER_TIME])
+  AC_REQUIRE([gl_CLOCK_TIME])
+  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
   AC_CHECK_FUNCS_ONCE(gettimeofday microuptime nanouptime)
-  :
+
+  if test $ac_cv_func_nanouptime != yes; then
+    LIB_GETHRXTIME=
+    AC_CACHE_CHECK([whether CLOCK_MONOTONIC is defined],
+      gl_cv_have_CLOCK_MONOTONIC,
+      [AC_EGREP_CPP([have_CLOCK_MONOTONIC],
+       [
+#        include <time.h>
+#        ifdef CLOCK_MONOTONIC
+         have_CLOCK_MONOTONIC
+#        endif
+       ],
+       gl_cv_have_CLOCK_MONOTONIC=yes,
+       gl_cv_have_CLOCK_MONOTONIC=no)])
+    if test $gl_cv_have_CLOCK_MONOTONIC = yes; then
+      LIB_GETHRXTIME=$LIB_CLOCK_GETTIME
+    fi
+    AC_SUBST([LIB_GETHRXTIME])
+  fi
 ])