From 9e591b831716ee060cd574a35c5d418df7c67a78 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 1 Sep 2007 09:27:48 +0000 Subject: [PATCH] Use clock_gettime if it is available. --- lib/silcutil/unix/silcunixutil.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/silcutil/unix/silcunixutil.c b/lib/silcutil/unix/silcunixutil.c index 4b37ea5e..50e01d07 100644 --- a/lib/silcutil/unix/silcunixutil.c +++ b/lib/silcutil/unix/silcunixutil.c @@ -69,7 +69,15 @@ char *silc_get_real_name() int silc_gettimeofday(struct timeval *p) { +#if defined(HAVE_CLOCK_GETTIME) + struct timespec tp; + clock_gettime(CLOCK_REALTIME, &tp); + p->tv_sec = tp.tv_sec; + p->tv_usec = tp.tv_nsec / 1000; + return 0; +#else return gettimeofday(p, NULL); +#endif /* HAVE_CLOCK_GETTIME */ } int silc_file_set_nonblock(int fd) -- 2.24.0