From 687ee7236e03d1944c5037a45eb5c9748217529c Mon Sep 17 00:00:00 2001 From: pwpiwi Date: Mon, 24 Feb 2020 11:37:38 +0100 Subject: [PATCH] compatibility fix: get_clocktime() is not a available with older glibc --- client/comms.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client/comms.c b/client/comms.c index b3b85fd2..b4091e00 100644 --- a/client/comms.c +++ b/client/comms.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "uart.h" #include "ui.h" @@ -144,7 +145,14 @@ static void storeCommand(UsbCommand *command) { static int getCommand(UsbCommand* response, uint32_t ms_timeout) { struct timespec end_time; +#if (_POSIX_TIMERS > 0) clock_gettime(CLOCK_REALTIME, &end_time); +#else + struct timeval tv; + gettimeofday(&tv, NULL); + end_time.tv_sec = tv.tv_sec; + end_time.tv_nsec = tv.tv_usec * 1000; +#endif end_time.tv_sec += ms_timeout / 1000; end_time.tv_nsec += (ms_timeout % 1000) * 1000000; if (end_time.tv_nsec > 1000000000) {