summaryrefslogtreecommitdiffstats
path: root/client/x11/platform.cpp
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-09-29 13:35:18 +0200
committerAlexander Larsson <alexl@redhat.com>2010-09-29 13:35:18 +0200
commit3f3283ee17d3318fa9bfb5c9900c06dbec434568 (patch)
treefd86625c5dacbd990ef6a78281c968268c14a7b5 /client/x11/platform.cpp
parent93dc13c91a2634c59d2ff233fa8ba79a534205b0 (diff)
downloadspice-3f3283ee17d3318fa9bfb5c9900c06dbec434568.tar.gz
spice-3f3283ee17d3318fa9bfb5c9900c06dbec434568.tar.xz
spice-3f3283ee17d3318fa9bfb5c9900c06dbec434568.zip
client: Fall back to gettimeofday if clock_gettime not found
Diffstat (limited to 'client/x11/platform.cpp')
-rw-r--r--client/x11/platform.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index a87dcfa9..65af063f 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -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)