>From 896daf273035e889c50dc5b33e74b5fb891851bc Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Dec 2019 09:46:46 +0100 Subject: [PATCH 05/15] gethrxtime: Assume that the compiler supports 'long long'. * lib/xtime.h (xtime_t): Define to 'long long int' always. (XTIME_PRECISION): Define to 1000000000 always. (xtime_make, xtime_sec): Optimize accordingly. * m4/gethrxtime.m4 (gl_XTIME): Don't require AC_TYPE_LONG_LONG_INT. * modules/gethrxtime (Files): Remove longlong.m4. --- ChangeLog | 7 +++++++ lib/xtime.h | 25 ++++--------------------- m4/gethrxtime.m4 | 3 +-- modules/gethrxtime | 1 - 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d9c546..57b0036 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2019-12-22 Bruno Haible + gethrxtime: Assume that the compiler supports 'long long'. + * lib/xtime.h (xtime_t): Define to 'long long int' always. + (XTIME_PRECISION): Define to 1000000000 always. + (xtime_make, xtime_sec): Optimize accordingly. + * m4/gethrxtime.m4 (gl_XTIME): Don't require AC_TYPE_LONG_LONG_INT. + * modules/gethrxtime (Files): Remove longlong.m4. + integer_length*: Assume that the compiler supports 'long long'. * lib/integer_length.h (integer_length_ll): Declare unconditionally. * modules/integer_length (Files): Remove longlong.m4. diff --git a/lib/xtime.h b/lib/xtime.h index 9edd123..77f1c30 100644 --- a/lib/xtime.h +++ b/lib/xtime.h @@ -29,21 +29,9 @@ _GL_INLINE_HEADER_BEGIN #endif /* xtime_t is a signed type used for timestamps. It is an integer - type that is a count of nanoseconds -- except for obsolescent hosts - without sufficiently-wide integers, where it is a count of - seconds. */ -#if HAVE_LONG_LONG_INT + type that is a count of nanoseconds. */ typedef long long int xtime_t; -# define XTIME_PRECISION 1000000000 -#else -# include -typedef long int xtime_t; -# if LONG_MAX >> 31 >> 31 == 0 -# define XTIME_PRECISION 1 -# else -# define XTIME_PRECISION 1000000000 -# endif -#endif +#define XTIME_PRECISION 1000000000 #ifdef __cplusplus extern "C" { @@ -57,10 +45,7 @@ xtime_make (xtime_t s, long int ns) const long int giga = 1000 * 1000 * 1000; s += ns / giga; ns %= giga; - if (XTIME_PRECISION == 1) - return s; - else - return XTIME_PRECISION * s + ns; + return XTIME_PRECISION * s + ns; } /* Return the number of seconds in T, which must be nonnegative. */ @@ -74,9 +59,7 @@ xtime_nonnegative_sec (xtime_t t) XTIME_INLINE xtime_t xtime_sec (xtime_t t) { - return (XTIME_PRECISION == 1 - ? t - : t < 0 + return (t < 0 ? (t + XTIME_PRECISION - 1) / XTIME_PRECISION - 1 : xtime_nonnegative_sec (t)); } diff --git a/m4/gethrxtime.m4 b/m4/gethrxtime.m4 index 6444fad..70439d3 100644 --- a/m4/gethrxtime.m4 +++ b/m4/gethrxtime.m4 @@ -1,4 +1,4 @@ -# gethrxtime.m4 serial 12 +# gethrxtime.m4 serial 13 dnl Copyright (C) 2005-2006, 2008-2019 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -62,6 +62,5 @@ AC_DEFUN([gl_ARITHMETIC_HRTIME_T], # Prerequisites of lib/xtime.h. AC_DEFUN([gl_XTIME], [ - AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) : ]) diff --git a/modules/gethrxtime b/modules/gethrxtime index b728003..b4a715f 100644 --- a/modules/gethrxtime +++ b/modules/gethrxtime @@ -7,7 +7,6 @@ lib/xtime.c lib/gethrxtime.c lib/gethrxtime.h m4/gethrxtime.m4 -m4/longlong.m4 Depends-on: clock-time -- 2.7.4