diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2011-05-25 21:27:48 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-05-25 22:00:00 +0200 |
commit | fd6d0b6897813ef9978c8714cf4ce37d8a8b179f (patch) | |
tree | c22e0a99eba3e3aa1ae5a4a2178c08cd87853b40 | |
parent | 09b0018b938bfbbe0d5b5363b8e011aa7bfbf2f2 (diff) | |
download | libssh-fd6d0b6897813ef9978c8714cf4ce37d8a8b179f.tar.gz libssh-fd6d0b6897813ef9978c8714cf4ce37d8a8b179f.tar.xz libssh-fd6d0b6897813ef9978c8714cf4ce37d8a8b179f.zip |
Replace clock_gettime with gettimeofday when missing
(cherry picked from commit 65282841e2a3e8af634759b6f7b39581a885d9d5)
-rw-r--r-- | src/misc.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -42,6 +42,9 @@ #include <sys/types.h> #include <ctype.h> #include <time.h> +#ifndef HAVE_RT +#include <sys/time.h> +#endif #ifdef _WIN32 @@ -869,10 +872,16 @@ 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 struct timespec tp; clock_gettime(CLOCK, &tp); - ts->seconds = tp.tv_sec; ts->useconds = tp.tv_nsec / 1000; +#endif + ts->seconds = tp.tv_sec; } /** |