mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-11 09:20:51 +00:00
5d89a9c284
This incorporates: 2020-07-30 work around some Oracle Studio attribute bugs 2020-07-29 fsusage, regex, stat-size: remove Cray support 2020-07-26 inttypes: remove support for AIX 4 2020-07-26 gettimeofday: remove workaround for Mac OS X 10.0 2020-07-26 don't require gl_LOCALTIME_BUFFER_DEFAULTS 2020-07-26 alloca: remove Cray-2 and Cray Y-MP support 2020-07-26 libgmp: remove dependency on havelib 2020-07-26 libgmp: remove HAVE_GMP, LIB_GMP 2020-07-25 multiarch: prepare for x86_64+arm64 universal in macOS 11 2020-07-25 sigprocmask: small autoconf macro improvement 2020-07-25 small autoconf macro improvements 2020-07-24 timespec: remove dependence on ‘verify’ 2020-07-24 optimize a few more three-valued comparisons 2020-07-24 fix _GL_CMP parenthesization typo 2020-07-23 optimize three-valued comparison between integers 2020-07-24 doc: update for Mac OS X 10.13 2020-07-23 fchmodat, lchmod: use /proc on Cygwin 2020-07-21 inttypes: fix PRI*PTR and SCN*PTR on 64-bit native Windows 2020-07-12 libgmp: avoid warning when --without-libgmp is used 2020-07-12 libgmp: link to the correct shared library * lib/mini-gmp-gnulib.c: Ignore -Wsuggest-attribute=malloc only for * build-aux/config.guess, build-aux/config.sub: * build-aux/install-sh, doc/misc/texinfo.tex, lib/c-strcasecmp.c: * lib/c-strncasecmp.c, lib/fchmodat.c, lib/fsusage.c: * lib/gettimeofday.c, lib/inttypes.in.h, lib/lchmod.c: * lib/mini-gmp-gnulib.c, lib/nstrftime.c, lib/regex.h, lib/timespec.h: * m4/alloca.m4, m4/getgroups.m4, m4/gettimeofday.m4: * m4/gnulib-common.m4, m4/inttypes.m4, m4/libgmp.m4, m4/mktime.m4: * m4/multiarch.m4: Copy from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * src/Makefile.in, test/Makefile.in (LIBGMP): Rename from LIB_GMP for compatibility with Gnulib. All uses changed.
102 lines
2.7 KiB
C
102 lines
2.7 KiB
C
/* timespec -- System time interface
|
|
|
|
Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2020 Free Software
|
|
Foundation, Inc.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
#if ! defined TIMESPEC_H
|
|
#define TIMESPEC_H
|
|
|
|
#include <time.h>
|
|
|
|
#ifndef _GL_INLINE_HEADER_BEGIN
|
|
#error "Please include config.h first."
|
|
#endif
|
|
_GL_INLINE_HEADER_BEGIN
|
|
#ifndef _GL_TIMESPEC_INLINE
|
|
# define _GL_TIMESPEC_INLINE _GL_INLINE
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "arg-nonnull.h"
|
|
|
|
/* Inverse resolution of timespec timestamps (in units per second),
|
|
and log base 10 of the inverse resolution. */
|
|
|
|
enum { TIMESPEC_HZ = 1000000000 };
|
|
enum { LOG10_TIMESPEC_HZ = 9 };
|
|
|
|
/* Obsolescent names for backward compatibility.
|
|
They are misnomers, because TIMESPEC_RESOLUTION is not a resolution. */
|
|
|
|
enum { TIMESPEC_RESOLUTION = TIMESPEC_HZ };
|
|
enum { LOG10_TIMESPEC_RESOLUTION = LOG10_TIMESPEC_HZ };
|
|
|
|
/* Return a timespec with seconds S and nanoseconds NS. */
|
|
|
|
_GL_TIMESPEC_INLINE struct timespec
|
|
make_timespec (time_t s, long int ns)
|
|
{
|
|
struct timespec r;
|
|
r.tv_sec = s;
|
|
r.tv_nsec = ns;
|
|
return r;
|
|
}
|
|
|
|
/* Return negative, zero, positive if A < B, A == B, A > B, respectively. */
|
|
|
|
_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE
|
|
timespec_cmp (struct timespec a, struct timespec b)
|
|
{
|
|
return 2 * _GL_CMP (a.tv_sec, b.tv_sec) + _GL_CMP (a.tv_nsec, b.tv_nsec);
|
|
}
|
|
|
|
/* Return -1, 0, 1, depending on the sign of A. A.tv_nsec must be
|
|
nonnegative. */
|
|
_GL_TIMESPEC_INLINE int _GL_ATTRIBUTE_PURE
|
|
timespec_sign (struct timespec a)
|
|
{
|
|
return _GL_CMP (a.tv_sec, 0) + (!a.tv_sec & !!a.tv_nsec);
|
|
}
|
|
|
|
struct timespec timespec_add (struct timespec, struct timespec)
|
|
_GL_ATTRIBUTE_CONST;
|
|
struct timespec timespec_sub (struct timespec, struct timespec)
|
|
_GL_ATTRIBUTE_CONST;
|
|
struct timespec dtotimespec (double)
|
|
_GL_ATTRIBUTE_CONST;
|
|
|
|
/* Return an approximation to A, of type 'double'. */
|
|
_GL_TIMESPEC_INLINE double
|
|
timespectod (struct timespec a)
|
|
{
|
|
return a.tv_sec + a.tv_nsec / 1e9;
|
|
}
|
|
|
|
struct timespec current_timespec (void);
|
|
void gettime (struct timespec *) _GL_ARG_NONNULL ((1));
|
|
int settime (struct timespec const *) _GL_ARG_NONNULL ((1));
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
_GL_INLINE_HEADER_END
|
|
|
|
#endif
|