From: Martin Ling Date: Sun, 23 Sep 2018 17:03:32 +0000 (+0100) Subject: Fall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable. X-Git-Tag: libserialport-0.1.2~81 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=7fb9a7b0a72bea83d05ef19e09e6b95b066b523d;p=libserialport.git Fall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable. Sounds like this may be necessary on some older systems. --- diff --git a/serialport.c b/serialport.c index 6e68153..6875fe1 100644 --- a/serialport.c +++ b/serialport.c @@ -61,7 +61,8 @@ static void get_time(struct timeval *time) { #ifdef HAVE_CLOCK_GETTIME struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) + clock_gettime(CLOCK_REALTIME, &ts); time->tv_sec = ts.tv_sec; time->tv_usec = ts.tv_nsec / 1000; #elif defined(__APPLE__)