* modules/gethrxtime (Depends-on): Add gettime.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Nov 2005 20:19:37 +0000 (20:19 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 10 Nov 2005 20:19:37 +0000 (20:19 +0000)
* lib/gethrxtime.c: Include "timespec.h" rather than the sys/time / time
business.
(gethrxtime) [! (HAVE_NANOUPTIME
|| (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
|| HAVE_MICROUPTIME)]: Fall back on gettime rather than rolling
our own approximation.
* m4/gethrxtime.m4 (gl_PREREQ_GETHRXTIME): Don't require AC_HEADER_TIME
or gettimeofday; no longer needed.

ChangeLog
lib/ChangeLog
lib/gethrxtime.c
lib/gethrxtime.h
m4/ChangeLog
m4/gethrxtime.m4
modules/gethrxtime

index 5818d60..9df774a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-11-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * modules/gethrxtime (Depends-on): Add gettime.
+
 2005-11-04  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool: Implement --update mode.
index a84cf13..ec1a367 100644 (file)
@@ -1,3 +1,12 @@
+2005-11-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * gethrxtime.c: Include "timespec.h" rather than the sys/time / time
+       business.
+       (gethrxtime) [! (HAVE_NANOUPTIME
+       || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
+       || HAVE_MICROUPTIME)]: Fall back on gettime rather than rolling
+       our own approximation.
+
 2005-11-10  Simon Josefsson  <jas@extundo.com>
 
        * readline.c: Remove EOL.
index 2c98578..6ece8ae 100644 (file)
 
 #include "gethrxtime.h"
 
-#include <sys/types.h>
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
+#include "timespec.h"
 
-/* Get the time of a high-resolution clock, preferably one that is not
-   subject to resetting or drifting.  */
+/* Get the current time, as a count of the number of nanoseconds since
+   an arbitrary epoch (e.g., the system boot time).  Prefer a
+   high-resolution clock that is not subject to resetting or
+   drifting.  */
 
 xtime_t
 gethrxtime (void)
@@ -65,16 +57,14 @@ gethrxtime (void)
     return xtime_make (tv.tv_sec, 1000 * tv.tv_usec);
   }
 
+# else
   /* No monotonically increasing clocks are available; fall back on a
      clock that might jump backwards, since it's the best we can do.  */
-# elif HAVE_GETTIMEOFDAY && XTIME_PRECISION != 1
   {
-    struct timeval tv;
-    gettimeofday (&tv, NULL);
-    return xtime_make (tv.tv_sec, 1000 * tv.tv_usec);
+    struct timespec ts;
+    gettime (&ts);
+    return xtime_make (ts.tv_sec, ts.tv_nsec);
   }
-# else
-  return xtime_make (time (NULL), 0);
 # endif
 #endif
 }
index ecbd505..2247f96 100644 (file)
@@ -24,8 +24,9 @@
 # include "xtime.h"
 
 /* Get the current time, as a count of the number of nanoseconds since
-   an arbitrary epoch (e.g., the system boot time).  This clock can't
-   be set, is always increasing, and is nearly linear.  */
+   an arbitrary epoch (e.g., the system boot time).  Prefer a
+   high-resolution clock that is not subject to resetting or
+   drifting.  */
 
 # if HAVE_ARITHMETIC_HRTIME_T && HAVE_DECL_GETHRTIME
 #  include <time.h>
index 471f2fd..b797738 100644 (file)
@@ -1,3 +1,8 @@
+2005-11-10  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * gethrxtime.m4 (gl_PREREQ_GETHRXTIME): Don't require AC_HEADER_TIME
+       or gettimeofday; no longer needed.
+
 2005-10-30  Paul Eggert  <eggert@cs.ucla.edu>
 
        * chdir-long.m4 (gl_FUNC_CHDIR_LONG): Revamp wording and local
index 82ca628..2b6fe36 100644 (file)
@@ -1,4 +1,4 @@
-# gethrxtime.m4 serial 2
+# gethrxtime.m4 serial 3
 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,
@@ -50,10 +50,9 @@ AC_DEFUN([gl_XTIME],
 # Prerequisites of lib/gethrxtime.c.
 AC_DEFUN([gl_PREREQ_GETHRXTIME],
 [
-  AC_REQUIRE([AC_HEADER_TIME])
   AC_REQUIRE([gl_CLOCK_TIME])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  AC_CHECK_FUNCS_ONCE(gettimeofday microuptime nanouptime)
+  AC_CHECK_FUNCS_ONCE(microuptime nanouptime)
 
   if test $ac_cv_func_nanouptime != yes; then
     LIB_GETHRXTIME=
index b09ec2c..8c40d28 100644 (file)
@@ -10,6 +10,7 @@ m4/clock_time.m4
 m4/longlong.m4
 
 Depends-on:
+gettime
 extensions
 
 configure.ac: