[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
Tue Jul 16 06:18:47 PDT 2024
https://github.com/DanielCChen updated https://github.com/llvm/llvm-project/pull/98915
>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 1/2] [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));
}
>From 458ee6ebbd13cb33dc78f19435793e53d7c7de48 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Tue, 16 Jul 2024 09:18:33 -0400
Subject: [PATCH 2/2] [Flang] Exclude the reference to TIME_UTC for AIX.
---
flang/runtime/time-intrinsic.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/flang/runtime/time-intrinsic.cpp b/flang/runtime/time-intrinsic.cpp
index 401be4ebf4764..92b937bc6f626 100644
--- a/flang/runtime/time-intrinsic.cpp
+++ b/flang/runtime/time-intrinsic.cpp
@@ -139,16 +139,13 @@ count_t ConvertTimeSpecToCount(int kind, const struct timespec &tspec) {
}
}
+#ifndef _AIX
// This is the fallback implementation, which should work everywhere.
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));
}
@@ -157,6 +154,7 @@ count_t GetSystemClockCount(int kind, fallback_implementation) {
// with the requested kind at the call site.
return ConvertTimeSpecToCount(kind, tspec);
}
+#endif
template <typename Unused = void>
count_t GetSystemClockCountRate(int kind, fallback_implementation) {
More information about the flang-commits
mailing list