38 #ifndef included_time_h 39 #define included_time_h 73 #if defined(__x86_64__) || defined(i386) 78 asm volatile (
"rdtsc":
"=a" (
a),
"=d" (d));
82 #elif defined (__powerpc64__) 88 asm volatile (
"mftb %0":
"=r" (t));
92 #elif defined (__SPU__) 98 return spu_rdch (0x8);
104 #elif defined (__powerpc__) 114 "cmpw %[hi1],%[hi2]\n" 115 "bne 1b\n":[hi1]
"=r" (hi1),[hi2]
"=r" (hi2),[
lo]
"=r" (
lo));
116 return (
u64) lo + ((
u64) hi2 << (
u64) 32);
119 #elif defined (__aarch64__) 125 asm volatile (
"mrs %0, cntvct_el0":
"=r" (vct));
129 #elif defined (__arm__) 130 #if defined(__ARM_ARCH_8A__) 135 asm volatile (
"mrrc p15, 0, %Q0, %R0, c9":
"=r" (tsc));
138 #elif defined(__ARM_ARCH_7A__) 143 asm volatile (
"mrc p15, 0, %0, c9, c13, 0":
"=r" (tsc));
151 asm volatile (
"mrc p15, 0, %[lo], c15, c12, 1":[
lo]
"=r" (
lo));
156 #elif defined (__xtensa__) 165 #elif defined (__TMS320C6X__) 172 asm volatile (
" dint\n" 174 " mvc .s2 TSCH,%1\n" " rint\n":
"=b" (l),
"=b" (h));
176 return ((
u64) h << 32) | l;
179 #elif defined(_mips) && __mips == 64 185 asm volatile (
"rdhwr %0,$31\n":
"=r" (result));
190 #error "don't know how to read CPU time stamp" 200 #define CLIB_US_TIME_PERIOD (1e-6) 201 #define CLIB_US_TIME_FREQ (1.0/CLIB_US_TIME_PERIOD) 221 #define CLIB_TIME_MAX (1.7976931348623157e+308) 242 #include <sys/time.h> 243 #include <sys/resource.h> 245 #include <sys/syscall.h> 253 clock_gettime (CLOCK_REALTIME, &ts);
259 return ts.tv_sec + 1e-9 * ts.tv_nsec;
268 clock_gettime (CLOCK_REALTIME, &ts);
272 return 1e9 * ts.tv_sec + ts.tv_nsec;
280 clock_gettime (CLOCK_REALTIME, &ts);
292 getrusage (RUSAGE_SELF, &u);
293 return u.ru_utime.tv_sec + 1e-6 * u.ru_utime.tv_usec
294 + u.ru_stime.tv_sec + 1e-6 * u.ru_stime.tv_usec;
300 struct timespec ts, tsrem;
302 ts.tv_nsec = 1e9 * (dt - (
f64) ts.tv_sec);
304 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)
#define SYS_clock_gettime
void clib_time_init(clib_time_t *c)