From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 10 Nov 2005 20:19:37 +0000 (+0000)
Subject: * modules/gethrxtime (Depends-on): Add gettime.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6512f0a46a6ced0d865faae14f0506278a39d819;p=pspp

* modules/gethrxtime (Depends-on): Add gettime.
* 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.
---

diff --git a/ChangeLog b/ChangeLog
index 5818d60807..9df774ad60 100644
--- 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.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index a84cf13103..ec1a367497 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
diff --git a/lib/gethrxtime.c b/lib/gethrxtime.c
index 2c985789dc..6ece8ae189 100644
--- a/lib/gethrxtime.c
+++ b/lib/gethrxtime.c
@@ -24,20 +24,12 @@
 
 #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
 }
diff --git a/lib/gethrxtime.h b/lib/gethrxtime.h
index ecbd505d50..2247f968d3 100644
--- a/lib/gethrxtime.h
+++ b/lib/gethrxtime.h
@@ -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>
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 471f2fd874..b797738de5 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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
diff --git a/m4/gethrxtime.m4 b/m4/gethrxtime.m4
index 82ca6280ee..2b6fe367c4 100644
--- a/m4/gethrxtime.m4
+++ b/m4/gethrxtime.m4
@@ -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=
diff --git a/modules/gethrxtime b/modules/gethrxtime
index b09ec2c334..8c40d28f04 100644
--- a/modules/gethrxtime
+++ b/modules/gethrxtime
@@ -10,6 +10,7 @@ m4/clock_time.m4
 m4/longlong.m4
 
 Depends-on:
+gettime
 extensions
 
 configure.ac: