mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-30 13:01:23 +03:00
Replace clock_gettime with gettimeofday when missing
This commit is contained in:
11
src/misc.c
11
src/misc.c
@@ -42,6 +42,9 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifndef HAVE_RT
|
||||||
|
#include <sys/time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#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
|
* @param[out] ts pointer to an allocated ssh_timestamp structure
|
||||||
*/
|
*/
|
||||||
void ssh_timestamp_init(struct ssh_timestamp *ts){
|
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;
|
struct timespec tp;
|
||||||
clock_gettime(CLOCK, &tp);
|
clock_gettime(CLOCK, &tp);
|
||||||
ts->seconds = tp.tv_sec;
|
|
||||||
ts->useconds = tp.tv_nsec / 1000;
|
ts->useconds = tp.tv_nsec / 1000;
|
||||||
|
#endif
|
||||||
|
ts->seconds = tp.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user