summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-01-25 23:04:22 -0800
committerFuwn <[email protected]>2022-01-25 23:04:22 -0800
commit6699cbaa1c16b464bcfc1963143ebc945154b671 (patch)
treeb6f83ca4f13a14e3539754d8428c76cab86beb5d /src/lib.rs
downloadrawaccel-sys-6699cbaa1c16b464bcfc1963143ebc945154b671.tar.xz
rawaccel-sys-6699cbaa1c16b464bcfc1963143ebc945154b671.zip
feat: :star:HEADmain
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..5252d2c
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,26 @@
+#![feature(extern_types)]
+
+#[cxx::bridge(namespace = "rawaccel")]
+pub mod utility {
+ unsafe extern "C++" {
+ include!("rawaccel-sys/rawaccel/common/utility.hpp");
+
+ pub fn minsd(a: f64, b: f64) -> f64;
+ pub fn maxsd(a: f64, b: f64) -> f64;
+ pub fn clampsd(v: f64, lo: f64, hi: f64) -> f64;
+ pub fn ilogb(x: f64) -> i32;
+ pub fn scalbn(x: f64, n: i32) -> f64;
+ pub fn infnan(x: f64) -> bool;
+ }
+}
+
+#[cfg(test)]
+mod test {
+ use crate::utility;
+
+ #[test]
+ fn test_utility_minsd() { assert_eq!(utility::minsd(2.0, 3.0), 2.0) }
+
+ #[test]
+ fn test_utility_maxsd() { assert_eq!(utility::maxsd(2.0, 3.0), 3.0) }
+}