[flang] Remove C++ runtime dependency from Sleep extension (#84911)
The Sleep extension currently has a potential dependency on the C++ runtime. I run into this dependency using libc++ on Linux. This patch uses the POSIX `sleep` function or the Windows `Sleep` function instead to avoid this dependency.
This commit is contained in:
parent
27becf0c3c
commit
227fe1c199
@ -23,6 +23,12 @@
|
||||
#include <thread>
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
#include <synchapi.h>
|
||||
|
||||
inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
|
||||
Fortran::runtime::Terminator terminator) {
|
||||
int error{ctime_s(buffer, bufsize, &cur_time)};
|
||||
@ -136,7 +142,11 @@ void RTNAME(Sleep)(std::int64_t seconds) {
|
||||
if (seconds < 1) {
|
||||
return;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::seconds(seconds));
|
||||
#if _WIN32
|
||||
Sleep(seconds * 1000);
|
||||
#else
|
||||
sleep(seconds);
|
||||
#endif
|
||||
}
|
||||
|
||||
// TODO: not supported on Windows
|
||||
|
Loading…
x
Reference in New Issue
Block a user