Merge pull request #24059 from yang-g/time_precise

Introduce a macro to override the precise clock
pull/23710/head
Yang Gao 4 years ago committed by GitHub
commit 805475dde8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/lib/gpr/time_precise.cc
  2. 8
      src/core/lib/gpr/time_precise.h

@ -31,6 +31,7 @@
#include "src/core/lib/gpr/time_precise.h"
#ifndef GPR_CYCLE_COUNTER_CUSTOM
#if GPR_CYCLE_COUNTER_RDTSC_32 || GPR_CYCLE_COUNTER_RDTSC_64
#if GPR_LINUX
static bool read_freq_from_kernel(double* freq) {
@ -163,3 +164,4 @@ gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b) {
gpr_cycle_counter_to_time(b));
}
#endif /* GPR_CYCLE_COUNTER_FALLBACK */
#endif /* !GPR_CYCLE_COUNTER_CUSTOM */

@ -31,7 +31,10 @@
// Using gpr_get_cycle_counter() is preferred to using ExecCtx::Get()->Now()
// whenever possible.
#if GPR_CYCLE_COUNTER_RDTSC_32
#if GPR_CYCLE_COUNTER_CUSTOM
typedef int64_t gpr_cycle_counter;
gpr_cycle_counter gpr_get_cycle_counter();
#elif GPR_CYCLE_COUNTER_RDTSC_32
typedef int64_t gpr_cycle_counter;
inline gpr_cycle_counter gpr_get_cycle_counter() {
int64_t ret;
@ -54,7 +57,8 @@ gpr_cycle_counter gpr_get_cycle_counter();
#else
#error Must define exactly one of \
GPR_CYCLE_COUNTER_RDTSC_32, \
GPR_CYCLE_COUNTER_RDTSC_64, or \
GPR_CYCLE_COUNTER_RDTSC_64, \
GPR_CYCLE_COUNTER_CUSTOM, or \
GPR_CYCLE_COUNTER_FALLBACK
#endif

Loading…
Cancel
Save