From 970afbe1f1ac0a9c153c6c75b433f98b285da3f9 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 18 Feb 2010 10:21:00 +0100 Subject: Update gnulib files. --- gl/Makefile.am | 27 ++++++++- gl/gettime.c | 48 ++++++++++++++++ gl/gettimeofday.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++ gl/m4/clock_time.m4 | 31 +++++++++++ gl/m4/gettime.m4 | 15 +++++ gl/m4/gnulib-cache.m4 | 3 +- gl/m4/gnulib-comp.m4 | 14 ++++- gl/m4/timespec.m4 | 15 +++++ gl/netdb.in.h | 2 +- gl/tests/Makefile.am | 9 --- gl/tests/gettimeofday.c | 144 ------------------------------------------------ gl/timespec.h | 39 +++++++++++++ 12 files changed, 332 insertions(+), 159 deletions(-) create mode 100644 gl/gettime.c create mode 100644 gl/gettimeofday.c create mode 100644 gl/m4/clock_time.m4 create mode 100644 gl/m4/gettime.m4 create mode 100644 gl/m4/timespec.m4 delete mode 100644 gl/tests/gettimeofday.c create mode 100644 gl/timespec.h (limited to 'gl') diff --git a/gl/Makefile.am b/gl/Makefile.am index cdcb1cbd7a..3da19f8001 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat update-copyright version-etc-fsf warnings +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gettime gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat update-copyright version-etc-fsf warnings AUTOMAKE_OPTIONS = 1.5 gnits @@ -303,6 +303,24 @@ libgnu_la_SOURCES += gettext.h ## end gnulib module gettext-h +## begin gnulib module gettime + + +EXTRA_DIST += gettime.c + +EXTRA_libgnu_la_SOURCES += gettime.c + +## end gnulib module gettime + +## begin gnulib module gettimeofday + + +EXTRA_DIST += gettimeofday.c + +EXTRA_libgnu_la_SOURCES += gettimeofday.c + +## end gnulib module gettimeofday + ## begin gnulib module gnumakefile distclean-local: clean-GNUmakefile @@ -1134,6 +1152,13 @@ EXTRA_DIST += time.in.h ## end gnulib module time +## begin gnulib module timespec + + +EXTRA_DIST += timespec.h + +## end gnulib module timespec + ## begin gnulib module unistd BUILT_SOURCES += unistd.h diff --git a/gl/gettime.c b/gl/gettime.c new file mode 100644 index 0000000000..044b26f0f3 --- /dev/null +++ b/gl/gettime.c @@ -0,0 +1,48 @@ +/* gettime -- get the system clock + + Copyright (C) 2002, 2004-2007, 2009-2010 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 . */ + +/* Written by Paul Eggert. */ + +#include + +#include "timespec.h" + +#include + +/* Get the system time into *TS. */ + +void +gettime (struct timespec *ts) +{ +#if HAVE_NANOTIME + nanotime (ts); +#else + +# if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME + if (clock_gettime (CLOCK_REALTIME, ts) == 0) + return; +# endif + + { + struct timeval tv; + gettimeofday (&tv, NULL); + ts->tv_sec = tv.tv_sec; + ts->tv_nsec = tv.tv_usec * 1000; + } + +#endif +} diff --git a/gl/gettimeofday.c b/gl/gettimeofday.c new file mode 100644 index 0000000000..271c7e980e --- /dev/null +++ b/gl/gettimeofday.c @@ -0,0 +1,144 @@ +/* Provide gettimeofday for systems that don't have it or for which it's broken. + + Copyright (C) 2001-2003, 2005-2007, 2009-2010 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, 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, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* written by Jim Meyering */ + +#include + +/* Specification. */ +#include + +#include + +#if HAVE_SYS_TIMEB_H +# include +#endif + +#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME + +/* Work around the bug in some systems whereby gettimeofday clobbers + the static buffer that localtime uses for its return value. The + gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has + this problem. The tzset replacement is necessary for at least + Solaris 2.5, 2.5.1, and 2.6. */ + +static struct tm tm_zero_buffer; +static struct tm *localtime_buffer_addr = &tm_zero_buffer; + +#undef localtime +extern struct tm *localtime (time_t const *); + +#undef gmtime +extern struct tm *gmtime (time_t const *); + +/* This is a wrapper for localtime. It is used only on systems for which + gettimeofday clobbers the static buffer used for localtime's result. + + On the first call, record the address of the static buffer that + localtime uses for its result. */ + +struct tm * +rpl_localtime (time_t const *timep) +{ + struct tm *tm = localtime (timep); + + if (localtime_buffer_addr == &tm_zero_buffer) + localtime_buffer_addr = tm; + + return tm; +} + +/* Same as above, since gmtime and localtime use the same buffer. */ +struct tm * +rpl_gmtime (time_t const *timep) +{ + struct tm *tm = gmtime (timep); + + if (localtime_buffer_addr == &tm_zero_buffer) + localtime_buffer_addr = tm; + + return tm; +} + +#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ + +#if TZSET_CLOBBERS_LOCALTIME + +#undef tzset +extern void tzset (void); + +/* This is a wrapper for tzset, for systems on which tzset may clobber + the static buffer used for localtime's result. */ +void +rpl_tzset (void) +{ + /* Save and restore the contents of the buffer used for localtime's + result around the call to tzset. */ + struct tm save = *localtime_buffer_addr; + tzset (); + *localtime_buffer_addr = save; +} +#endif + +/* This is a wrapper for gettimeofday. It is used only on systems + that lack this function, or whose implementation of this function + causes problems. */ + +int +rpl_gettimeofday (struct timeval *restrict tv, void *restrict tz) +{ +#undef gettimeofday +#if HAVE_GETTIMEOFDAY +# if GETTIMEOFDAY_CLOBBERS_LOCALTIME + /* Save and restore the contents of the buffer used for localtime's + result around the call to gettimeofday. */ + struct tm save = *localtime_buffer_addr; +# endif + + int result = gettimeofday (tv, (struct timezone *) tz); + +# if GETTIMEOFDAY_CLOBBERS_LOCALTIME + *localtime_buffer_addr = save; +# endif + + return result; + +#else + +# if HAVE__FTIME + + struct _timeb timebuf; + _ftime (&timebuf); + tv->tv_sec = timebuf.time; + tv->tv_usec = timebuf.millitm * 1000; + +# else + +# if !defined OK_TO_USE_1S_CLOCK +# error "Only 1-second nominal clock resolution found. Is that intended?" \ + "If so, compile with the -DOK_TO_USE_1S_CLOCK option." +# endif + tv->tv_sec = time (NULL); + tv->tv_usec = 0; + +# endif + + return 0; + +#endif +} diff --git a/gl/m4/clock_time.m4 b/gl/m4/clock_time.m4 new file mode 100644 index 0000000000..8be179db87 --- /dev/null +++ b/gl/m4/clock_time.m4 @@ -0,0 +1,31 @@ +# clock_time.m4 serial 10 +dnl Copyright (C) 2002-2006, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME. +# For a program named, say foo, you should add a line like the following +# in the corresponding Makefile.am file: +# foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) + +AC_DEFUN([gl_CLOCK_TIME], +[ + dnl Persuade glibc and Solaris to declare these functions. + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + + # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. + # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. + + # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* + # programs in the package would end up linked with that potentially-shared + # library, inducing unnecessary run-time overhead. + LIB_CLOCK_GETTIME= + AC_SUBST([LIB_CLOCK_GETTIME]) + gl_saved_libs=$LIBS + AC_SEARCH_LIBS([clock_gettime], [rt posix4], + [test "$ac_cv_search_clock_gettime" = "none required" || + LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) + AC_CHECK_FUNCS([clock_gettime clock_settime]) + LIBS=$gl_saved_libs +]) diff --git a/gl/m4/gettime.m4 b/gl/m4/gettime.m4 new file mode 100644 index 0000000000..9e7fde4272 --- /dev/null +++ b/gl/m4/gettime.m4 @@ -0,0 +1,15 @@ +# gettime.m4 serial 7 +dnl Copyright (C) 2002, 2004-2006, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_GETTIME], +[ + AC_LIBOBJ([gettime]) + + dnl Prerequisites of lib/gettime.c. + AC_REQUIRE([gl_CLOCK_TIME]) + AC_REQUIRE([gl_TIMESPEC]) + AC_CHECK_FUNCS_ONCE([gettimeofday nanotime]) +]) diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index c3552d1ee6..adad55b84b 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,7 +15,7 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat update-copyright version-etc-fsf warnings +# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --tests-base=gl/tests --aux-dir=build-aux --with-tests --libtool --macro-prefix=gl --no-vc-files accept arpa_inet autobuild bind close connect error fdl-1.3 gendocs getaddrinfo getline getpass-gnu gettime gnupload gpl-3.0 inet_ntop inet_pton lgpl-2.1 listen maintainer-makefile manywarnings minmax perror pmccabe2html progname read-file readline recv select send setsockopt shutdown socket sockets sys_stat update-copyright version-etc-fsf warnings # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) @@ -32,6 +32,7 @@ gl_MODULES([ getaddrinfo getline getpass-gnu + gettime gnupload gpl-3.0 inet_ntop diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 4f08319901..fd0b0da43a 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -65,6 +65,7 @@ AC_SUBST([LTALLOCA]) AC_LIBOBJ([bind]) fi gl_SYS_SOCKET_MODULE_INDICATOR([bind]) + gl_CLOCK_TIME gl_FUNC_CLOSE gl_UNISTD_MODULE_INDICATOR([close]) AC_REQUIRE([gl_HEADER_SYS_SOCKET]) @@ -91,6 +92,9 @@ AC_SUBST([LTALLOCA]) gl_FUNC_GETPASS_GNU AC_SUBST([LIBINTL]) AC_SUBST([LTLIBINTL]) + gl_GETTIME + gl_FUNC_GETTIMEOFDAY + gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) # Autoconf 2.61a.99 and earlier don't support linking a file only # in VPATH builds. But since GNUmakefile is for maintainer use # only, it does not matter if we skip the link with older autoconf. @@ -191,6 +195,7 @@ AC_SUBST([LTALLOCA]) gl_HEADER_SYS_TIME_H AC_PROG_MKDIR_P gl_HEADER_TIME_H + gl_TIMESPEC gl_UNISTD_H gl_FUNC_VASNPRINTF gl_VERSION_ETC @@ -237,8 +242,6 @@ AC_SUBST([LTALLOCA]) gl_COMMON gl_source_base='gl/tests' gl_FUNC_UNGETC_WORKS - gl_FUNC_GETTIMEOFDAY - gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) AC_C_BIGENDIAN AC_C_BIGENDIAN AC_REQUIRE([gl_HEADER_SYS_SOCKET]) @@ -393,6 +396,8 @@ AC_DEFUN([gl_FILE_LIST], [ lib/getpass.c lib/getpass.h lib/gettext.h + lib/gettime.c + lib/gettimeofday.c lib/inet_ntop.c lib/inet_pton.c lib/intprops.h @@ -440,6 +445,7 @@ AC_DEFUN([gl_FILE_LIST], [ lib/sys_stat.in.h lib/sys_time.in.h lib/time.in.h + lib/timespec.h lib/unistd.in.h lib/vasnprintf.c lib/vasnprintf.h @@ -453,6 +459,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/alloca.m4 m4/arpa_inet_h.m4 m4/autobuild.m4 + m4/clock_time.m4 m4/close.m4 m4/errno_h.m4 m4/error.m4 @@ -464,6 +471,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/getdelim.m4 m4/getline.m4 m4/getpass.m4 + m4/gettime.m4 m4/gettimeofday.m4 m4/gnulib-common.m4 m4/hostent.m4 @@ -512,6 +520,7 @@ AC_DEFUN([gl_FILE_LIST], [ m4/sys_stat_h.m4 m4/sys_time_h.m4 m4/time_h.m4 + m4/timespec.m4 m4/ungetc.m4 m4/unistd_h.m4 m4/vasnprintf.m4 @@ -576,7 +585,6 @@ AC_DEFUN([gl_FILE_LIST], [ tests/test-wchar.c tests/zerosize-ptr.h tests=lib/dummy.c - tests=lib/gettimeofday.c tests=lib/ioctl.c tests=lib/sys_ioctl.in.h tests=lib/verify.h diff --git a/gl/m4/timespec.m4 b/gl/m4/timespec.m4 new file mode 100644 index 0000000000..5dbaed74a0 --- /dev/null +++ b/gl/m4/timespec.m4 @@ -0,0 +1,15 @@ +#serial 14 + +# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc. + +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +dnl From Jim Meyering + +AC_DEFUN([gl_TIMESPEC], +[ + dnl Prerequisites of lib/timespec.h. + AC_REQUIRE([AC_C_INLINE]) +]) diff --git a/gl/netdb.in.h b/gl/netdb.in.h index 6e0f966c9a..dd0f2f07c3 100644 --- a/gl/netdb.in.h +++ b/gl/netdb.in.h @@ -90,7 +90,7 @@ struct addrinfo # endif # ifndef AI_ADDRCONFIG # define AI_ADDRCONFIG 0 /* 0x0020: Use configuration of this host to choose - returned address type.. */ + returned address type. */ # endif /* Error values for `getaddrinfo' function. */ diff --git a/gl/tests/Makefile.am b/gl/tests/Makefile.am index a3a618c730..cdf9763658 100644 --- a/gl/tests/Makefile.am +++ b/gl/tests/Makefile.am @@ -148,15 +148,6 @@ EXTRA_DIST += test-getline.c signature.h macros.h ## end gnulib module getline-tests -## begin gnulib module gettimeofday - - -EXTRA_DIST += gettimeofday.c - -EXTRA_libtests_a_SOURCES += gettimeofday.c - -## end gnulib module gettimeofday - ## begin gnulib module gettimeofday-tests TESTS += test-gettimeofday diff --git a/gl/tests/gettimeofday.c b/gl/tests/gettimeofday.c deleted file mode 100644 index 271c7e980e..0000000000 --- a/gl/tests/gettimeofday.c +++ /dev/null @@ -1,144 +0,0 @@ -/* Provide gettimeofday for systems that don't have it or for which it's broken. - - Copyright (C) 2001-2003, 2005-2007, 2009-2010 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, 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, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -/* written by Jim Meyering */ - -#include - -/* Specification. */ -#include - -#include - -#if HAVE_SYS_TIMEB_H -# include -#endif - -#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME - -/* Work around the bug in some systems whereby gettimeofday clobbers - the static buffer that localtime uses for its return value. The - gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has - this problem. The tzset replacement is necessary for at least - Solaris 2.5, 2.5.1, and 2.6. */ - -static struct tm tm_zero_buffer; -static struct tm *localtime_buffer_addr = &tm_zero_buffer; - -#undef localtime -extern struct tm *localtime (time_t const *); - -#undef gmtime -extern struct tm *gmtime (time_t const *); - -/* This is a wrapper for localtime. It is used only on systems for which - gettimeofday clobbers the static buffer used for localtime's result. - - On the first call, record the address of the static buffer that - localtime uses for its result. */ - -struct tm * -rpl_localtime (time_t const *timep) -{ - struct tm *tm = localtime (timep); - - if (localtime_buffer_addr == &tm_zero_buffer) - localtime_buffer_addr = tm; - - return tm; -} - -/* Same as above, since gmtime and localtime use the same buffer. */ -struct tm * -rpl_gmtime (time_t const *timep) -{ - struct tm *tm = gmtime (timep); - - if (localtime_buffer_addr == &tm_zero_buffer) - localtime_buffer_addr = tm; - - return tm; -} - -#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */ - -#if TZSET_CLOBBERS_LOCALTIME - -#undef tzset -extern void tzset (void); - -/* This is a wrapper for tzset, for systems on which tzset may clobber - the static buffer used for localtime's result. */ -void -rpl_tzset (void) -{ - /* Save and restore the contents of the buffer used for localtime's - result around the call to tzset. */ - struct tm save = *localtime_buffer_addr; - tzset (); - *localtime_buffer_addr = save; -} -#endif - -/* This is a wrapper for gettimeofday. It is used only on systems - that lack this function, or whose implementation of this function - causes problems. */ - -int -rpl_gettimeofday (struct timeval *restrict tv, void *restrict tz) -{ -#undef gettimeofday -#if HAVE_GETTIMEOFDAY -# if GETTIMEOFDAY_CLOBBERS_LOCALTIME - /* Save and restore the contents of the buffer used for localtime's - result around the call to gettimeofday. */ - struct tm save = *localtime_buffer_addr; -# endif - - int result = gettimeofday (tv, (struct timezone *) tz); - -# if GETTIMEOFDAY_CLOBBERS_LOCALTIME - *localtime_buffer_addr = save; -# endif - - return result; - -#else - -# if HAVE__FTIME - - struct _timeb timebuf; - _ftime (&timebuf); - tv->tv_sec = timebuf.time; - tv->tv_usec = timebuf.millitm * 1000; - -# else - -# if !defined OK_TO_USE_1S_CLOCK -# error "Only 1-second nominal clock resolution found. Is that intended?" \ - "If so, compile with the -DOK_TO_USE_1S_CLOCK option." -# endif - tv->tv_sec = time (NULL); - tv->tv_usec = 0; - -# endif - - return 0; - -#endif -} diff --git a/gl/timespec.h b/gl/timespec.h new file mode 100644 index 0000000000..81b342300e --- /dev/null +++ b/gl/timespec.h @@ -0,0 +1,39 @@ +/* timespec -- System time interface + + Copyright (C) 2000, 2002, 2004-2005, 2007, 2009-2010 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 . */ + +#if ! defined TIMESPEC_H +# define TIMESPEC_H + +# include + +/* Return negative, zero, positive if A < B, A == B, A > B, respectively. + Assume the nanosecond components are in range, or close to it. */ +static inline int +timespec_cmp (struct timespec a, struct timespec b) +{ + return (a.tv_sec < b.tv_sec ? -1 + : a.tv_sec > b.tv_sec ? 1 + : a.tv_nsec < b.tv_nsec ? -1 + : a.tv_nsec > b.tv_nsec ? 1 + : 0); +} + +void gettime (struct timespec *); +int settime (struct timespec const *); + +#endif -- cgit v1.2.1