]> sigrok.org Git - libserialport.git/commitdiff
Fall back to CLOCK_REALTIME if CLOCK_MONOTONIC not usable.
authorMartin Ling <redacted>
Sun, 23 Sep 2018 17:03:32 +0000 (18:03 +0100)
committerMartin Ling <redacted>
Sat, 28 Dec 2019 21:02:19 +0000 (22:02 +0100)
Sounds like this may be necessary on some older systems.

serialport.c

index 6e681533ed24896a33de59f7e17597a4f0bf5082..6875fe1abce32bf8248eed326f9f200a70d75e64 100644 (file)
@@ -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__)