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}") + } + } +}