Created SILC Runtime Toolkit git repository Part II.
[runtime.git] / lib / silcutil / unix / silcunixutil.c
index 4b37ea5e769c65e59dd12656130e675010ad295d..def4f1d783913b291909fbf9d0a8c820c8a9da07 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 1997 - 2007 Pekka Riikonen
+  Copyright (C) 1997 - 2008 Pekka Riikonen
 
   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
@@ -17,7 +17,7 @@
 
 */
 
-#include "silc.h"
+#include "silcruntime.h"
 
 /* Returns the username of the user. If the global variable LOGNAME
    does not exists we will get the name from the password file. */
@@ -69,7 +69,16 @@ char *silc_get_real_name()
 
 int silc_gettimeofday(struct timeval *p)
 {
+#if defined(HAVE_CLOCK_GETTIME)
+  struct timespec tp;
+  if (clock_gettime(CLOCK_REALTIME, &tp))
+    return -1;
+  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)