Commit 896daf27 authored by Bruno Haible's avatar Bruno Haible
Browse files

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.
parent 3a5d13f4
2019-12-22 Bruno Haible <bruno@clisp.org>
 
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.
......@@ -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 <limits.h>
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));
}
......
# 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])
:
])
......@@ -7,7 +7,6 @@ lib/xtime.c
lib/gethrxtime.c
lib/gethrxtime.h
m4/gethrxtime.m4
m4/longlong.m4
Depends-on:
clock-time
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment