[flang-commits] [flang] [Flang] `TIME_UTC` is not available on AIX7.2. Using POSIX alternative `clock_gettime` instead. (PR #98915)

Daniel Chen via flang-commits flang-commits at lists.llvm.org
Mon Jul 15 08:13:30 PDT 2024


https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/98915

This PR is to fix a build breakage on AIX7.2 due to `TIME_UTC` is not available.

>From 4ca55d76cbd70de68da3e794167082429f787550 Mon Sep 17 00:00:00 2001
From: DanielCChen <cdchen at ca.ibm.com>
Date: Mon, 15 Jul 2024 11:11:00 -0400
Subject: [PATCH] [Flang] TIME_UTC is not available on AIX7.2. Using POSIX
 alternative clock_gettime instead.

---
 flang/runtime/time-intrinsic.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index 7352dafc9136e..401be4ebf4764 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -144,7 +144,11 @@ template <typename Unused = void>
 count_t GetSystemClockCount(int kind, fallback_implementation) {
   struct timespec tspec;
 
+#ifdef _AIX
+  if (clock_gettime(CLOCK_REALTIME, &tspec) < 0) {
+#else
   if (timespec_get(&tspec, TIME_UTC) < 0) {
+#endif
     // Return -HUGE(COUNT) to represent failure.
     return -static_cast<count_t>(GetHUGE(kind));
   }



More information about the flang-commits mailing list