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 (__aarch64__) 123 asm volatile (
"mrs %0, cntvct_el0":
"=r" (vct));
127 #elif defined (__arm__) 128 #if defined(__ARM_ARCH_8A__) 133 asm volatile (
"mrrc p15, 0, %Q0, %R0, c9":
"=r" (tsc));
136 #elif defined(__ARM_ARCH_7A__) 141 asm volatile (
"mrc p15, 0, %0, c9, c13, 0":
"=r" (tsc));
149 asm volatile (
"mrc p15, 0, %[lo], c15, c12, 1":[
lo]
"=r" (
lo));
154 #elif defined (__xtensa__) 163 #elif defined (__TMS320C6X__) 170 asm volatile (
" dint\n" 172 " mvc .s2 TSCH,%1\n" " rint\n":
"=b" (l),
"=b" (h));
174 return ((
u64) h << 32) | l;
178 #error "don't know how to read CPU time stamp" 200 #define CLIB_TIME_MAX (1.7976931348623157e+308) 221 #include <sys/time.h> 222 #include <sys/resource.h> 224 #include <sys/syscall.h> 233 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
234 return ts.tv_sec + 1e-9 * ts.tv_nsec;
242 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
243 return 1e9 * ts.tv_sec + ts.tv_nsec;
250 syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
259 getrusage (RUSAGE_SELF, &u);
260 return u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec
261 + u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec;
267 struct timespec ts, tsrem;
269 ts.tv_nsec = 1e9 * (dt - (
f64) ts.tv_sec);
271 while (nanosleep (&ts, &tsrem) < 0)
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)
static void unix_time_now_nsec_fraction(u32 *sec, u32 *nsec)
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)