-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang] allow _POSIX_SOURCE to be defined without a value #78179
Conversation
@llvm/pr-subscribers-flang-runtime Author: Kelvin Li (kkwli) ChangesThe Full diff: https://github.com/llvm/llvm-project/pull/78179.diff 2 Files Affected:
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);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know much about AIX but a define(_POSIX_SOURCE)
would guarantee that it will work when define with and without a value, with the exception of 0.
I assume that there are no cases where it is defined as 0? Normally it should follow the yyyymm format like 200809L
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old-school idiom for this would be (_POSIX_SOURCE+0)
.
You don't need the parentheses with defined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
The `_POSIX_SOURCE` macro is defined without a value on AIX. Change the check to `defined(_POSIX_SOURCE)`.
The
_POSIX_SOURCE
macro is defined without a value on AIX.