38 #ifndef included_time_h 39 #define included_time_h 71 #if defined(__x86_64__) || defined(i386) 76 asm volatile (
"rdtsc":
"=a" (
a),
"=d" (d));
80 #elif defined (__powerpc64__) 86 asm volatile (
"mftb %0":
"=r" (t));
90 #elif defined (__SPU__) 96 return spu_rdch (0x8);
102 #elif defined (__powerpc__) 112 "cmpw %[hi1],%[hi2]\n" 113 "bne 1b\n":[hi1]
"=r" (hi1),[hi2]
"=r" (hi2),[
lo]
"=r" (
lo));
114 return (
u64) lo + ((
u64) hi2 << (
u64) 32);
117 #elif defined (__arm__) 118 #if defined(__ARM_ARCH_8A__) 123 asm volatile (
"mrrc p15, 0, %Q0, %R0, c9":
"=r" (tsc));
126 #elif defined(__ARM_ARCH_7A__) 131 asm volatile (
"mrc p15, 0, %0, c9, c13, 0":
"=r" (tsc));
139 asm volatile (
"mrc p15, 0, %[lo], c15, c12, 1":[
lo]
"=r" (
lo));
144 #elif defined (__xtensa__) 153 #elif defined (__TMS320C6X__) 160 asm volatile (
" dint\n" 162 " mvc .s2 TSCH,%1\n" " rint\n":
"=b" (l),
"=b" (h));
164 return ((
u64) h << 32) | l;
167 #elif defined (__aarch64__) 174 asm volatile (
"mrs %0, cntvct_el0":
"=r" (tsc));
180 #error "don't know how to read CPU time stamp" 220 #include <sys/time.h> 221 #include <sys/resource.h> 223 #include <sys/syscall.h> 232 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
233 return ts.tv_sec + 1e-9 * ts.tv_nsec;
241 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
242 return 1e9 * ts.tv_sec + ts.tv_nsec;
249 getrusage (RUSAGE_SELF, &u);
250 return u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec
251 + u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec;
259 t.tv_nsec = 1e9 * dt;
static void clib_cpu_time_wait(u64 dt)
void clib_time_verify_frequency(clib_time_t *c)
static f64 clib_time_now(clib_time_t *c)
static u64 clib_cpu_time_now(void)
u32 log2_clocks_per_second
static void unix_sleep(f64 dt)
static f64 unix_time_now(void)
u32 log2_clocks_per_frequency_verify
static u64 unix_time_now_nsec(void)
static f64 unix_usage_now(void)
f64 last_verify_reference_time
static f64 clib_time_now_internal(clib_time_t *c, u64 n)
void clib_time_init(clib_time_t *c)