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

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


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-runtime

Author: Kelvin Li (kkwli)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/78179.diff


2 Files Affected:

- (modified) flang/runtime/extensions.cpp (+1-1) 
- (modified) flang/unittests/Runtime/CommandTest.cpp (+1-1) 


``````````diff
diff --git a/flang/runtime/extensions.cpp b/flang/runtime/extensions.cpp
index 352da8f11d9d565..158998321b06662 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 a0f14c519412a41..dfb4f2cd8bd9968 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);

``````````

</details>


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


More information about the flang-commits mailing list