From 59802547c336d61aa7e950414a3f44180e211974 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 29 May 2022 17:01:03 +0200 Subject: client ping working --- client/time_linux.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 client/time_linux.c (limited to 'client/time_linux.c') diff --git a/client/time_linux.c b/client/time_linux.c new file mode 100644 index 0000000..5b72838 --- /dev/null +++ b/client/time_linux.c @@ -0,0 +1,21 @@ +#ifdef W2_HOST_LINUX + +#include + +#include "time.h" + +unsigned long w2_get_time() { + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + return ((now.tv_sec * 1000) + (now.tv_nsec / 1000000)); +} + +void w2_timer_start(w2_e_client_timers label) { + g_w2_client_timers[label] = w2_get_time(); +} + +unsigned long w2_timer_end(w2_e_client_timers label) { + return w2_get_time() - g_w2_client_timers[label]; +} + +#endif -- cgit v1.2.3