mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-30 17:49:02 +00:00
client: Fall back to gettimeofday if clock_gettime not found
This commit is contained in:
parent
93dc13c91a
commit
3f3283ee17
@ -22,6 +22,9 @@
|
||||
#ifdef WIN32
|
||||
#include <sys/timeb.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
Thread::Thread(thread_main_t thread_main, void* opaque)
|
||||
{
|
||||
@ -43,8 +46,13 @@ static inline void rel_time(struct timespec& time, uint64_t delta_nano)
|
||||
_ftime_s(&now);
|
||||
time.tv_sec = (long)now.time;
|
||||
time.tv_nsec = now.millitm * 1000 * 1000;
|
||||
#else
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
clock_gettime(CLOCK_MONOTONIC, &time);
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
time.tv_sec = tv.tv_sec;
|
||||
time.tv_nsec = tv.tv_usec*1000;
|
||||
#endif
|
||||
delta_nano += (uint64_t)time.tv_sec * 1000 * 1000 * 1000;
|
||||
delta_nano += time.tv_nsec;
|
||||
|
||||
@ -41,6 +41,9 @@
|
||||
#include <values.h>
|
||||
#include <signal.h>
|
||||
#include <sys/shm.h>
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#include "platform.h"
|
||||
#include "application.h"
|
||||
@ -425,9 +428,15 @@ void Platform::send_quit_request()
|
||||
|
||||
uint64_t Platform::get_monolithic_time()
|
||||
{
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
struct timespec time_space;
|
||||
clock_gettime(CLOCK_MONOTONIC, &time_space);
|
||||
return uint64_t(time_space.tv_sec) * 1000 * 1000 * 1000 + uint64_t(time_space.tv_nsec);
|
||||
#else
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return uint64_t(tv.tv_sec) * 1000 * 1000 * 1000 + uint64_t(tv.tv_usec) * 1000;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Platform::get_temp_dir(std::string& path)
|
||||
|
||||
@ -27,6 +27,8 @@ AM_PROG_CC_C_O
|
||||
AC_C_BIGENDIAN
|
||||
AC_PATH_PROGS(PYTHON, python2 python)
|
||||
|
||||
AC_CHECK_HEADERS([sys/time.h])
|
||||
|
||||
SPICE_LT_VERSION=m4_format("%d:%d:%d", 1, 0, 2)
|
||||
AC_SUBST(SPICE_LT_VERSION)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user