aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-05-25 22:08:31 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-05-25 22:08:31 +0200
commit07fb895fe98b29cc432f742ae51b09f502a1dce6 (patch)
tree2ee58ce80e5611d1eda660451b205c995c4e751f /src/misc.c
parent65282841e2a3e8af634759b6f7b39581a885d9d5 (diff)
downloadlibssh-07fb895fe98b29cc432f742ae51b09f502a1dce6.tar.gz
libssh-07fb895fe98b29cc432f742ae51b09f502a1dce6.tar.xz
libssh-07fb895fe98b29cc432f742ae51b09f502a1dce6.zip
cmake: Fix detection of clock_gettime.
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/misc.c b/src/misc.c
index 5705f2fb..fe04ac66 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -42,7 +42,7 @@
#include <sys/types.h>
#include <ctype.h>
#include <time.h>
-#ifndef HAVE_RT
+#ifndef HAVE_CLOCK_GETTIME
#include <sys/time.h>
#endif
@@ -872,18 +872,20 @@ int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2) {
* @param[out] ts pointer to an allocated ssh_timestamp structure
*/
void ssh_timestamp_init(struct ssh_timestamp *ts){
-#ifndef HAVE_RT
- struct timeval tp;
- gettimeofday(&tp, NULL);
- ts->useconds = tp.tv_usec;
-#else
+#ifdef HAVE_CLOCK_GETTIME
struct timespec tp;
clock_gettime(CLOCK, &tp);
ts->useconds = tp.tv_nsec / 1000;
+#else
+ struct timeval tp;
+ gettimeofday(&tp, NULL);
+ ts->useconds = tp.tv_usec;
#endif
ts->seconds = tp.tv_sec;
}
+#undef CLOCK
+
/**
* @internal
* @brief gets the time difference between two timestamps in ms