Skip to content

Commit 66af69c

Browse files
committed
Revert "[flang] Add POSIX implementation for SYSTEM_CLOCK"
This reverts commit 2534d53.
1 parent 1a3ab4a commit 66af69c

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

flang/runtime/time-intrinsic.cpp

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -106,58 +106,6 @@ count_t GetSystemClockCountMax(fallback_implementation) {
106106
return std::min(std::numeric_limits<std::clock_t>::max(),
107107
std::numeric_limits<count_t>::max());
108108
}
109-
110-
constexpr count_t NSECS_PER_SEC{1'000'000'000};
111-
112-
// POSIX implementation using clock_gettime. This is only enabled if
113-
// clock_gettime is available.
114-
template <typename T = int, typename U = struct timespec>
115-
count_t GetSystemClockCount(preferred_implementation,
116-
// We need some dummy parameters to pass to decltype(clock_gettime).
117-
T ClockId = 0, U *Timespec = nullptr,
118-
decltype(clock_gettime(ClockId, Timespec)) *Enabled = nullptr) {
119-
#if defined CLOCK_THREAD_CPUTIME_ID
120-
#define CLOCKID CLOCK_THREAD_CPUTIME_ID
121-
#elif defined CLOCK_PROCESS_CPUTIME_ID
122-
#define CLOCKID CLOCK_PROCESS_CPUTIME_ID
123-
#elif defined CLOCK_MONOTONIC
124-
#define CLOCKID CLOCK_MONOTONIC
125-
#else
126-
#define CLOCKID CLOCK_REALTIME
127-
#endif
128-
struct timespec tspec;
129-
if (clock_gettime(CLOCKID, &tspec) != 0) {
130-
// Return -HUGE() to represent failure.
131-
return -std::numeric_limits<count_t>::max();
132-
}
133-
134-
// Wrap around to avoid overflows.
135-
constexpr count_t max_secs{
136-
std::numeric_limits<count_t>::max() / NSECS_PER_SEC};
137-
count_t wrapped_secs{tspec.tv_sec % max_secs};
138-
139-
// At this point, wrapped_secs < max_secs, and max_secs has already been
140-
// truncated by the division. Therefore, we should still have enough room to
141-
// add tv_nsec, since it is < NSECS_PER_SEC.
142-
return tspec.tv_nsec + wrapped_secs * NSECS_PER_SEC;
143-
}
144-
145-
template <typename T = int, typename U = struct timespec>
146-
count_t GetSystemClockCountRate(preferred_implementation,
147-
// We need some dummy parameters to pass to decltype(clock_gettime).
148-
T ClockId = 0, U *Timespec = nullptr,
149-
decltype(clock_gettime(ClockId, Timespec)) *Enabled = nullptr) {
150-
return NSECS_PER_SEC;
151-
}
152-
153-
template <typename T = int, typename U = struct timespec>
154-
count_t GetSystemClockCountMax(preferred_implementation,
155-
// We need some dummy parameters to pass to decltype(clock_gettime).
156-
T ClockId = 0, U *Timespec = nullptr,
157-
decltype(clock_gettime(ClockId, Timespec)) *Enabled = nullptr) {
158-
count_t max_secs{std::numeric_limits<count_t>::max() / NSECS_PER_SEC};
159-
return max_secs * NSECS_PER_SEC - 1;
160-
}
161109
} // anonymous namespace
162110

163111
namespace Fortran::runtime {

0 commit comments

Comments
 (0)