]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix timevar.cc build on systems that don't have CLOCK_MONOTONIC
authorJohn David Anglin <danglin@gcc.gnu.org>
Thu, 26 Dec 2024 16:27:36 +0000 (11:27 -0500)
committerJohn David Anglin <danglin@gcc.gnu.org>
Thu, 26 Dec 2024 16:27:36 +0000 (11:27 -0500)
2024-12-26  John David Anglin  <danglin@gcc.gnu.org>

gcc/ChangeLog:

PR target/118050
* timevar.cc (get_time): Only use CLOCK_MONOTONIC if
'_POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)'.
Otherise, use CLOCK_REALTIME.

gcc/timevar.cc

index 48d0c72cbdfc6db3e49e1069a82377f817edd766..21fd65d2f892e68e8a81b2f8d4d09e85b1ffb062 100644 (file)
@@ -160,7 +160,11 @@ get_time (struct timevar_time_def *now)
 
 #ifdef HAVE_CLOCK_GETTIME
   struct timespec ts;
+#if _POSIX_TIMERS > 0 && defined(_POSIX_MONOTONIC_CLOCK)
   clock_gettime (CLOCK_MONOTONIC, &ts);
+#else
+  clock_gettime (CLOCK_REALTIME, &ts);
+#endif
   now->wall = ts.tv_sec * 1000000000 + ts.tv_nsec;
   return;
 #define HAVE_WALL_TIME 1