From 07fb895fe98b29cc432f742ae51b09f502a1dce6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 25 May 2011 22:08:31 +0200 Subject: cmake: Fix detection of clock_gettime. --- src/misc.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/misc.c') 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 #include #include -#ifndef HAVE_RT +#ifndef HAVE_CLOCK_GETTIME #include #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 -- cgit v1.2.3