Skip to content

Commit 218bed4

Browse files
committed
Use c++ std library sleep
1 parent 67b4e6a commit 218bed4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

flang/runtime/extensions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include "flang/Runtime/descriptor.h"
1717
#include "flang/Runtime/entry-names.h"
1818
#include "flang/Runtime/io-api.h"
19+
#include <chrono>
1920
#include <ctime>
21+
#include <thread>
2022

2123
#ifdef _WIN32
2224
inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
@@ -40,10 +42,8 @@ inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time,
4042
#endif
4143

4244
#if _REENTRANT || _POSIX_C_SOURCE >= 199506L
43-
// System is posix-compliant and has getlogin_r and sleep
45+
// System is posix-compliant and has getlogin_r
4446
#include <unistd.h>
45-
#elif _WIN32
46-
#include <windows.h> // for sleep
4747
#endif
4848

4949
extern "C" {
@@ -123,7 +123,7 @@ void RTNAME(Sleep)(std::int64_t seconds) {
123123
if (seconds < 1) {
124124
return;
125125
}
126-
sleep(static_cast<unsigned>(seconds));
126+
std::this_thread::sleep_for(std::chrono::seconds(seconds));
127127
}
128128

129129
} // namespace Fortran::runtime

0 commit comments

Comments
 (0)