1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-29 01:03:57 +03:00

cmake: Fix detection of clock_gettime.

This commit is contained in:
Andreas Schneider
2011-05-25 22:08:31 +02:00
parent 65282841e2
commit 07fb895fe9
3 changed files with 16 additions and 14 deletions

View File

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