From a710891659202c82545e84725d4e5cd77aef567c Mon Sep 17 00:00:00 2001 From: Darren Tucker Date: Sun, 2 Jun 2013 08:18:31 +1000 Subject: [PATCH] - (dtucker) [configure.ac misc.c] Look for clock_gettime in librt and fall back to time(NULL) if we can't find it anywhere. --- ChangeLog | 2 ++ configure.ac | 7 +++++-- misc.c | 4 ++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f4323e07..50ce1b736 100644 --- a/ChangeLog +++ b/ChangeLog @@ -54,6 +54,8 @@ openbsd-compat/getrrsetbyname-ldns.c openbsd-compat/port-aix.c openbsd-compat/port-linux.c] Replace portable-specific instances of xfree with the equivalent calls to free. + - (dtucker) [configure.ac misc.c] Look for clock_gettime in librt and fall + back to time(NULL) if we can't find it anywhere. 20130529 - (dtucker) [configure.ac openbsd-compat/bsd-misc.h] bz#2087: Add a null diff --git a/configure.ac b/configure.ac index d35a19bcc..1b64d11ae 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -# $Id: configure.ac,v 1.527 2013/06/01 21:18:48 dtucker Exp $ +# $Id: configure.ac,v 1.528 2013/06/01 22:18:32 dtucker Exp $ # # Copyright (c) 1999-2004 Damien Miller # @@ -15,7 +15,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org]) -AC_REVISION($Revision: 1.527 $) +AC_REVISION($Revision: 1.528 $) AC_CONFIG_SRCDIR([ssh.c]) AC_LANG([C]) @@ -1648,6 +1648,9 @@ const char *gai_strerror(int); AC_SEARCH_LIBS([nanosleep], [rt posix4], [AC_DEFINE([HAVE_NANOSLEEP], [1], [Some systems put nanosleep outside of libc])]) +AC_SEARCH_LIBS([clock_gettime], [rt], + [AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [Have clock_gettime])]) + dnl Make sure prototypes are defined for these before using them. AC_CHECK_DECL([getrusage], [AC_CHECK_FUNCS([getrusage])]) AC_CHECK_DECL([strsep], diff --git a/misc.c b/misc.c index cd45e9ecc..fd745444e 100644 --- a/misc.c +++ b/misc.c @@ -857,12 +857,16 @@ ms_to_timeval(struct timeval *tv, int ms) time_t monotime(void) { +#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) fatal("clock_gettime: %s", strerror(errno)); return (ts.tv_sec); +#else + return time(NULL); +#endif } void