diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp index e70dff3997233..f6c39468d5655 100644 --- a/flang-rt/lib/runtime/extensions.cpp +++ b/flang-rt/lib/runtime/extensions.cpp @@ -27,10 +27,7 @@ #include #ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#define NOMINMAX -#include - +#include "flang/Common/windows-include.h" #include inline void CtimeBuffer(char *buffer, size_t bufsize, const time_t cur_time, @@ -309,6 +306,9 @@ void RTNAME(Perror)(const char *str) { perror(str); } // GNU extension function TIME() std::int64_t RTNAME(time)() { return time(nullptr); } +// MCLOCK: returns accumulated CPU time in ticks +std::int32_t FORTRAN_PROCEDURE_NAME(mclock)() { return std::clock(); } + // Extension procedures related to I/O namespace io { diff --git a/flang/docs/Intrinsics.md b/flang/docs/Intrinsics.md index 0118f8eb7d913..f7da6c889d413 100644 --- a/flang/docs/Intrinsics.md +++ b/flang/docs/Intrinsics.md @@ -709,8 +709,9 @@ CACHESIZE, EOF, FP_CLASS, INT_PTR_KIND, ISNAN, LOC MALLOC, FREE ``` -### Library subroutine +### Library subroutines and functions ``` +ticks = MCLOCK() CALL BACKTRACE() CALL FDATE(TIME) CALL GETLOG(USRNAME) diff --git a/flang/include/flang/Runtime/extensions.h b/flang/include/flang/Runtime/extensions.h index 06ae7f35d9b5b..b350204714431 100644 --- a/flang/include/flang/Runtime/extensions.h +++ b/flang/include/flang/Runtime/extensions.h @@ -12,14 +12,12 @@ #ifndef FORTRAN_RUNTIME_EXTENSIONS_H_ #define FORTRAN_RUNTIME_EXTENSIONS_H_ -#include "flang/Runtime/entry-names.h" - -#define FORTRAN_PROCEDURE_NAME(name) name##_ - #include "flang/Runtime/entry-names.h" #include #include +#define FORTRAN_PROCEDURE_NAME(name) name##_ + #ifdef _WIN32 // UID and GID don't exist on Windows, these exist to avoid errors. typedef std::uint32_t uid_t; @@ -89,5 +87,8 @@ int FORTRAN_PROCEDURE_NAME(ierrno)(); // GNU extension subroutine PERROR(STRING) void RTNAME(Perror)(const char *str); +// MCLOCK -- returns accumulated time in ticks +int FORTRAN_PROCEDURE_NAME(mclock)(); + } // extern "C" #endif // FORTRAN_RUNTIME_EXTENSIONS_H_