19 #ifndef GRPC_CORE_LIB_GPR_TIME_PRECISE_H
20 #define GRPC_CORE_LIB_GPR_TIME_PRECISE_H
34 #if GPR_CYCLE_COUNTER_CUSTOM
35 typedef int64_t gpr_cycle_counter;
36 gpr_cycle_counter gpr_get_cycle_counter();
37 #elif GPR_CYCLE_COUNTER_RDTSC_32
38 typedef int64_t gpr_cycle_counter;
39 inline gpr_cycle_counter gpr_get_cycle_counter() {
41 __asm__
volatile(
"rdtsc" :
"=A"(ret));
44 #elif GPR_CYCLE_COUNTER_RDTSC_64
45 typedef int64_t gpr_cycle_counter;
46 inline gpr_cycle_counter gpr_get_cycle_counter() {
48 __asm__
volatile(
"rdtsc" :
"=a"(low),
"=d"(high));
49 return (high << 32) | low;
51 #elif GPR_CYCLE_COUNTER_FALLBACK
55 typedef double gpr_cycle_counter;
56 gpr_cycle_counter gpr_get_cycle_counter();
58 #error Must define exactly one of \
59 GPR_CYCLE_COUNTER_RDTSC_32, \
60 GPR_CYCLE_COUNTER_RDTSC_64, \
61 GPR_CYCLE_COUNTER_CUSTOM, or \
62 GPR_CYCLE_COUNTER_FALLBACK
Analogous to struct timespec.
Definition: gpr_types.h:47
gpr_timespec gpr_cycle_counter_to_time(gpr_cycle_counter cycles)
void gpr_precise_clock_now(gpr_timespec *clk)
void gpr_precise_clock_init(void)
gpr_timespec gpr_cycle_counter_sub(gpr_cycle_counter a, gpr_cycle_counter b)