Skip to content

Commit fbabe5e

Browse files
committed
add POSIX macros check and fallback
1 parent 344cbdc commit fbabe5e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

flang/runtime/extensions.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
2323
int error = ctime_s(buffer, bufsize, &cur_time);
2424
RUNTIME_CHECK(terminator, error == 0);
2525
}
26-
#else
26+
#elif _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || \
27+
_POSIX_SOURCE
2728
inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
2829
Fortran::runtime::Terminator terminator) {
2930
const char *res = ctime_r(&cur_time, buffer);
3031
RUNTIME_CHECK(terminator, res != nullptr);
3132
}
33+
#else
34+
inline void ctime_alloc(char *buffer, size_t bufsize, const time_t cur_time,
35+
Fortran::runtime::Terminator terminator) {
36+
buffer[0] = '\0';
37+
terminator.Crash("fdate is not supported.");
38+
}
3239
#endif
3340

3441
extern "C" {

0 commit comments

Comments
 (0)