https://gcc.gnu.org/g:06867d9fa69ca6d4ded4602e6601c7153599cbff

commit r15-6443-g06867d9fa69ca6d4ded4602e6601c7153599cbff
Author: John David Anglin <dang...@gcc.gnu.org>
Date:   Thu Dec 26 11:27:36 2024 -0500

    Fix timevar.cc build on systems that don't have CLOCK_MONOTONIC
    
    2024-12-26  John David Anglin  <dang...@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.

Diff:
---
 gcc/timevar.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/timevar.cc b/gcc/timevar.cc
index 48d0c72cbdfc..21fd65d2f892 100644
--- a/gcc/timevar.cc
+++ b/gcc/timevar.cc
@@ -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

Reply via email to