[flang-commits] [flang] [flang] allow _POSIX_SOURCE to be defined without a value (PR #78179)

Kelvin Li via flang-commits flang-commits at lists.llvm.org
Mon Jan 15 08:08:19 PST 2024


https://github.com/kkwli created https://github.com/llvm/llvm-project/pull/78179

The `_POSIX_SOURCE` macro is defined without a value on AIX.

>From 41000e1b1cf404c1bfe837212d005e14468fab43 Mon Sep 17 00:00:00 2001
From: Kelvin Li <kli at ca.ibm.com>
Date: Fri, 12 Jan 2024 18:32:41 -0500
Subject: [PATCH] [flang] allow _POSIX_SOURCE to be defined without a value

---
 flang/runtime/extensions.cpp            | 2 +-
 flang/unittests/Runtime/CommandTest.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/flang/runtime/extensions.cpp b/flang/runtime/extensions.cpp
index 352da8f11d9d56..158998321b0666 100644
--- a/flang/runtime/extensions.cpp
+++ b/flang/runtime/extensions.cpp
@@ -24,7 +24,7 @@ inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
   RUNTIME_CHECK(terminator, error == 0);
 }
 #elif _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || \
-    _POSIX_SOURCE
+    defined(_POSIX_SOURCE)
 inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
     Fortran::runtime::Terminator terminator) {
   const char *res{ctime_r(&cur_time, buffer)};
diff --git a/flang/unittests/Runtime/CommandTest.cpp b/flang/unittests/Runtime/CommandTest.cpp
index a0f14c519412a4..dfb4f2cd8bd996 100644
--- a/flang/unittests/Runtime/CommandTest.cpp
+++ b/flang/unittests/Runtime/CommandTest.cpp
@@ -233,7 +233,7 @@ class NoArgv : public CommandFixture {
 };
 
 #if _WIN32 || _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || \
-    _SVID_SOURCE || _POSIX_SOURCE
+    _SVID_SOURCE || defined(_POSIX_SOURCE)
 TEST_F(NoArgv, FdateGetDate) {
   char input[]{"24LengthCharIsJustRight"};
   const std::size_t charLen = sizeof(input);



More information about the flang-commits mailing list