38 #ifndef included_time_h 39 #define included_time_h 70 #if defined(__x86_64__) || defined(i386) 75 :
"=a" (
a),
"=d" (d));
79 #elif defined (__powerpc64__) 84 asm volatile (
"mftb %0" :
"=r" (t));
88 #elif defined (__SPU__) 93 return spu_rdch (0x8);
99 #elif defined (__powerpc__) 109 "cmpw %[hi1],%[hi2]\n" 111 : [hi1]
"=r" (hi1), [hi2]
"=r" (hi2), [
lo]
"=r" (
lo));
112 return (
u64) lo + ((
u64) hi2 << (
u64) 32);
115 #elif defined (__arm__) 116 #if defined(__ARM_ARCH_7A__) 120 asm volatile(
"mrrc p15, 0, %Q0, %R0, c9" :
"=r" (tsc));
127 asm volatile (
"mrc p15, 0, %[lo], c15, c12, 1" 133 #elif defined (__xtensa__) 139 #elif defined (__TMS320C6X__) 145 asm volatile (
" dint\n" 149 :
"=b" (l),
"=b" (h));
151 return ((
u64)h << 32) | l;
154 #elif defined (__aarch64__) 160 asm volatile(
"mrs %0, cntvct_el0" :
"=r" (tsc));
166 #error "don't know how to read CPU time stamp" 202 #include <sys/time.h> 203 #include <sys/resource.h> 205 #include <sys/syscall.h> 213 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
214 return ts.tv_sec + 1e-9*ts.tv_nsec;
221 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
222 return 1e9*ts.tv_sec + ts.tv_nsec;
228 getrusage (RUSAGE_SELF, &u);
229 return u.ru_utime.tv_sec + 1e-6*u.ru_utime.tv_usec
230 + u.ru_stime.tv_sec + 1e-6*u.ru_stime.tv_usec;
237 t.tv_nsec = 1e9 * dt;
always_inline f64 unix_time_now(void)
always_inline f64 unix_usage_now(void)
always_inline f64 clib_time_now_internal(clib_time_t *c, u64 n)
void clib_time_verify_frequency(clib_time_t *c)
u32 log2_clocks_per_second
always_inline f64 clib_time_now(clib_time_t *c)
u32 log2_clocks_per_frequency_verify
always_inline void unix_sleep(f64 dt)
f64 last_verify_reference_time
always_inline void clib_cpu_time_wait(u64 dt)
void clib_time_init(clib_time_t *c)
always_inline u64 clib_cpu_time_now(void)
always_inline u64 unix_time_now_nsec(void)