38 #ifndef included_time_h 39 #define included_time_h 79 #if defined(__x86_64__) || defined(i386) 84 asm volatile (
"rdtsc":
"=a" (
a),
"=d" (d));
88 #elif defined (__powerpc64__) 94 asm volatile (
"mftb %0":
"=r" (t));
98 #elif defined (__SPU__) 104 return spu_rdch (0x8);
110 #elif defined (__powerpc__) 120 "cmpw %[hi1],%[hi2]\n" 121 "bne 1b\n":[hi1]
"=r" (hi1),[hi2]
"=r" (hi2),[
lo]
"=r" (
lo));
122 return (
u64) lo + ((
u64) hi2 << (
u64) 32);
125 #elif defined (__aarch64__) 131 asm volatile (
"mrs %0, cntvct_el0":
"=r" (vct));
135 #elif defined (__arm__) 136 #if defined(__ARM_ARCH_8A__) 141 asm volatile (
"mrrc p15, 0, %Q0, %R0, c9":
"=r" (tsc));
144 #elif defined(__ARM_ARCH_7A__) 149 asm volatile (
"mrc p15, 0, %0, c9, c13, 0":
"=r" (tsc));
157 asm volatile (
"mrc p15, 0, %[lo], c15, c12, 1":[
lo]
"=r" (
lo));
162 #elif defined (__xtensa__) 171 #elif defined (__TMS320C6X__) 178 asm volatile (
" dint\n" 180 " mvc .s2 TSCH,%1\n" " rint\n":
"=b" (l),
"=b" (h));
182 return ((
u64) h << 32) | l;
185 #elif defined(_mips) && __mips == 64 191 asm volatile (
"rdhwr %0,$31\n":
"=r" (result));
196 #error "don't know how to read CPU time stamp" 206 #define CLIB_US_TIME_PERIOD (1e-6) 207 #define CLIB_US_TIME_FREQ (1.0/CLIB_US_TIME_PERIOD) 227 #define CLIB_TIME_MAX (1.7976931348623157e+308) 248 #include <sys/time.h> 249 #include <sys/resource.h> 251 #include <sys/syscall.h> 259 clock_gettime (CLOCK_REALTIME, &ts);
265 return ts.tv_sec + 1e-9 * ts.tv_nsec;
274 clock_gettime (CLOCK_REALTIME, &ts);
278 return 1e9 * ts.tv_sec + ts.tv_nsec;
286 clock_gettime (CLOCK_REALTIME, &ts);
298 getrusage (RUSAGE_SELF, &u);
299 return u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec
300 + u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec;
306 struct timespec ts, tsrem;
308 ts.tv_nsec = 1e9 * (dt - (
f64) ts.tv_sec);
310 while (nanosleep (&ts, &tsrem) < 0)
static void clib_cpu_time_wait(u64 dt)
void clib_time_verify_frequency(clib_time_t *c)
format_function_t format_clib_time
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)
#define SYS_clock_gettime
void clib_time_init(clib_time_t *c)