diff --git a/core/time.c b/core/time.c index 4bd7f42..b08b77d 100644 --- a/core/time.c +++ b/core/time.c @@ -27,3 +27,10 @@ unsigned long usecs_to_jiffies(const unsigned int u) // This could overflow return (u * HZ) / 1000000L; } + +#include +inline uint64_t read_cycle_counter() +{ + uint64_t tsc = __rdtsc(); + return tsc; +} diff --git a/core/time.h b/core/time.h index 699b33d..a5a4bdd 100644 --- a/core/time.h +++ b/core/time.h @@ -1,4 +1,5 @@ #pragma once +#include #define HZ 100 /* @@ -50,3 +51,5 @@ unsigned int jiffies_to_msecs(const unsigned long j); unsigned int jiffies_to_usecs(const unsigned long j); unsigned long msecs_to_jiffies(const unsigned int m); unsigned long usecs_to_jiffies(const unsigned int u); + +uint64_t read_cycle_counter();