From a93e90cf3c50344a2582acb0e60187dbef90ee28 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Mon, 30 May 2022 20:44:53 +0200 Subject: cmake: add example how to integrate cargo --- content/2022-05-30-cmake-cargo-example/libcalc/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 content/2022-05-30-cmake-cargo-example/libcalc/src/lib.rs (limited to 'content/2022-05-30-cmake-cargo-example/libcalc/src') diff --git a/content/2022-05-30-cmake-cargo-example/libcalc/src/lib.rs b/content/2022-05-30-cmake-cargo-example/libcalc/src/lib.rs new file mode 100644 index 0000000..a36aace --- /dev/null +++ b/content/2022-05-30-cmake-cargo-example/libcalc/src/lib.rs @@ -0,0 +1,9 @@ +#[no_mangle] +pub extern "C" fn wrap_add(a: i32, b: i32) -> i32 { + a.wrapping_add(b) +} + +#[no_mangle] +pub extern "C" fn sat_add(a: i32, b: i32) -> i32 { + a.saturating_add(b) +} -- cgit v1.2.3