aboutsummaryrefslogtreecommitdiff
path: root/src/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/time.rs')
-rw-r--r--src/time.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/time.rs b/src/time.rs
index eb0111b..e51cf08 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -43,15 +43,29 @@ mod test {
#[test]
fn check_rdtsc() {
- unsafe {
- assert!(rdtsc() > 0, "rdtsc returned 0, unlikely!");
+ let cpuid = crate::cpuid::CpuId::new();
+ let has_tsc = cpuid
+ .get_feature_info()
+ .map_or(false, |finfo| finfo.has_tsc());
+
+ if has_tsc {
+ unsafe {
+ assert!(rdtsc() > 0, "rdtsc returned 0, unlikely!");
+ }
}
}
#[test]
fn check_rdtscp() {
- unsafe {
- assert!(rdtscp() > 0, "rdtscp returned 0, unlikely!");
+ let cpuid = crate::cpuid::CpuId::new();
+ let has_tsc = cpuid
+ .get_feature_info()
+ .map_or(false, |finfo| finfo.has_tsc());
+
+ if has_tsc {
+ unsafe {
+ assert!(rdtscp() > 0, "rdtscp returned 0, unlikely!");
+ }
}
}
}