[flang] Add default implementation for SYSTEM_CLOCK
Add an implementation for the runtime functions related to SYSTEM_CLOCK. As with CPU_TIME, this is based on std::clock(), which should be available everywhere, but it is highly recommended to add platform-specific implementations for systems where std::clock() behaves poorly (e.g. POSIX). The documentation for std::clock() doesn't specify a maximum value and in fact wrap around behaviour is non-conforming. Therefore, this implementation of SYSTEM_CLOCK is not guaranteed to wrap around either, and after std::clock reaches its maximum value we will likely just return failure rather than wrap around. If this happens often on your system, please add a new platform-specific implementation. We define COUNT_MAX as either the maximum value that can be stored in a std::clock_t or in a 64-bit integer (whichever is smaller), and COUNT_RATE as CLOCKS_PER_SEC. For POSIX systems, the value of CLOCKS_PER_SEC is hardcoded to 10^6 and irrelevant for the values returned by std::clock. Differential Revision: https://reviews.llvm.org/D105969
Loading
Please register or sign in to comment