summaryrefslogtreecommitdiff
path: root/include/gras/detail/chrono.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/gras/detail/chrono.hpp')
-rw-r--r--include/gras/detail/chrono.hpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/include/gras/detail/chrono.hpp b/include/gras/detail/chrono.hpp
index bd247e5..9fe317a 100644
--- a/include/gras/detail/chrono.hpp
+++ b/include/gras/detail/chrono.hpp
@@ -29,6 +29,7 @@ namespace gras
#else
#include <ctime>
+#include <sys/time.h>
namespace gras
{
@@ -36,8 +37,14 @@ namespace gras
GRAS_FORCE_INLINE time_ticks_t time_now(void)
{
struct timespec ts;
- clock_gettime(CLOCK_MONOTONIC, &ts);
- return ts.tv_sec*1000000000UL + ts.tv_nsec;
+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+ return ts.tv_sec*1000000000UL + ts.tv_nsec;
+
+ struct timeval tv;
+ if (gettimeofday(&tv, NULL) == 0)
+ return tv.tv_sec*1000000000UL + tv.tv_usec*1000UL;
+
+ return 0;
}
GRAS_FORCE_INLINE time_ticks_t time_tps(void)