Mercurial > hg > octave-lyh > gnulib-hg
changeset 6449:232d8dc8525f
* 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.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Thu, 10 Nov 2005 20:19:37 +0000 |
parents | 22577c85f5af |
children | 494008c595ca |
files | ChangeLog lib/ChangeLog lib/gethrxtime.c lib/gethrxtime.h m4/ChangeLog m4/gethrxtime.m4 modules/gethrxtime |
diffstat | 7 files changed, 33 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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.
--- 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 @@ 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 }
--- 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>
--- 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
--- 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 @@ # 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=