From 61e88f304b702ccf967f9bc3aae8d3e0499e4273 Mon Sep 17 00:00:00 2001 From: durch Date: Tue, 14 Mar 2023 14:38:34 +0000 Subject: [PATCH] Checkpoint --- common/cpu-cycle/Cargo.toml | 9 +++++++++ common/cpu-cycle/src/lib.rs | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 common/cpu-cycle/Cargo.toml create mode 100644 common/cpu-cycle/src/lib.rs diff --git a/common/cpu-cycle/Cargo.toml b/common/cpu-cycle/Cargo.toml new file mode 100644 index 0000000000..782adbb78f --- /dev/null +++ b/common/cpu-cycle/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "cpu-cycle" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +libc = "0.2" diff --git a/common/cpu-cycle/src/lib.rs b/common/cpu-cycle/src/lib.rs new file mode 100644 index 0000000000..4929bdcb11 --- /dev/null +++ b/common/cpu-cycle/src/lib.rs @@ -0,0 +1,19 @@ +use libc::c_int; + +#[link(name = "cpucycles")] +extern "C" { + fn cpucycles() -> c_int; +} + +#[cfg(test)] +mod test { + use crate::cpucycles; + + #[test] + fn test_cpucycles() { + unsafe { + let cycles = cpucycles(); + println!("{cycles}") + } + } +}