Skip to content

Commit 64bb4a9

Browse files
committed
Remove dead TSC code from the dark ages
1 parent a4eeb3c commit 64bb4a9

File tree

2 files changed

+5
-55
lines changed

2 files changed

+5
-55
lines changed

plugins/experimental/uri_signing/jwt.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ double
8585
now(void)
8686
{
8787
struct timespec t;
88+
89+
#if defined(CLOCK_REALTIME_COARSE)
8890
if (!clock_gettime(CLOCK_REALTIME_COARSE, &t)) {
91+
#else
92+
if (!clock_gettime(CLOCK_REALTIME, &t)) {
93+
#endif
8994
return (double)t.tv_sec + 1.0e-9 * (double)t.tv_nsec;
9095
}
9196
return NAN;

src/tscore/ink_hrtime.cc

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -178,58 +178,3 @@ squid_timestamp_to_buf(char *buf, unsigned int buf_size, long timestamp_sec, lon
178178

179179
return res;
180180
}
181-
182-
#ifdef USE_TIME_STAMP_COUNTER_HRTIME
183-
uint32_t
184-
init_hrtime_TCS()
185-
{
186-
int freqlen = sizeof(hrtime_freq);
187-
if (sysctlbyname("machdep.tsc_freq", &hrtime_freq, (size_t *)&freqlen, nullptr, 0) < 0) {
188-
perror("sysctl: machdep.tsc_freq");
189-
exit(1);
190-
}
191-
hrtime_freq_float = (double)1000000000 / (double)hrtime_freq;
192-
return hrtime_freq;
193-
}
194-
195-
double hrtime_freq_float = 0.5; // 500 Mhz
196-
uint32_t hrtime_freq = init_hrtime_TCS();
197-
#endif
198-
199-
#ifdef NEED_HRTIME_BASIS
200-
timespec timespec_basis;
201-
ink_hrtime hrtime_offset;
202-
ink_hrtime hrtime_basis = init_hrtime_basis();
203-
204-
ink_hrtime
205-
init_hrtime_basis()
206-
{
207-
ink_hrtime t1, t2, b, now;
208-
timespec ts;
209-
#ifdef USE_TIME_STAMP_COUNTER_HRTIME
210-
init_hrtime_TCS();
211-
#endif
212-
do {
213-
t1 = ink_get_hrtime();
214-
#if HAVE_CLOCK_GETTIME
215-
ink_assert(!clock_gettime(CLOCK_REALTIME_COARSE, &timespec_basis));
216-
#else
217-
{
218-
struct timeval tnow;
219-
ink_assert(!gettimeofday(&tnow, nullptr));
220-
timespec_basis.tv_sec = tnow.tv_sec;
221-
timespec_basis.tv_nsec = tnow.tv_usec * 1000;
222-
}
223-
#endif
224-
t2 = ink_get_hrtime();
225-
// accuracy must be at least 100 microseconds
226-
} while (t2 - t1 > HRTIME_USECONDS(100));
227-
b = (t2 + t1) / 2;
228-
now = ink_hrtime_from_timespec(&timespec_basis);
229-
ts = ink_hrtime_to_timespec(now);
230-
ink_assert(ts.tv_sec == timespec_basis.tv_sec && ts.tv_nsec == timespec_basis.tv_nsec);
231-
hrtime_offset = now - b;
232-
hrtime_basis = b;
233-
return b;
234-
}
235-
#endif

0 commit comments

Comments
 (0)