- (dtucker) [configure.ac misc.c] Look for clock_gettime in librt and fall

back to time(NULL) if we can't find it anywhere.
This commit is contained in:
Darren Tucker 2013-06-02 08:18:31 +10:00
parent f60845fde2
commit a710891659
3 changed files with 11 additions and 2 deletions

View File

@ -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

View File

@ -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],

4
misc.c
View File

@ -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