@@ -106,58 +106,6 @@ count_t GetSystemClockCountMax(fallback_implementation) {
106
106
return std::min (std::numeric_limits<std::clock_t >::max (),
107
107
std::numeric_limits<count_t >::max ());
108
108
}
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
- }
161
109
} // anonymous namespace
162
110
163
111
namespace Fortran ::runtime {
0 commit comments