diff --git a/hello-rust/Cargo.toml b/hello-rust/Cargo.toml new file mode 100644 index 0000000..d1aa7e6 --- /dev/null +++ b/hello-rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "hello-rust" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/hello-rust/libmultiply.a b/hello-rust/libmultiply.a new file mode 100644 index 0000000..61bfe1c Binary files /dev/null and b/hello-rust/libmultiply.a differ diff --git a/hello-rust/main b/hello-rust/main new file mode 100755 index 0000000..436ee2e Binary files /dev/null and b/hello-rust/main differ diff --git a/hello-rust/multiply.o b/hello-rust/multiply.o new file mode 100644 index 0000000..8360cd3 Binary files /dev/null and b/hello-rust/multiply.o differ diff --git a/hello-rust/src/main.rs b/hello-rust/src/main.rs new file mode 100644 index 0000000..6849d86 --- /dev/null +++ b/hello-rust/src/main.rs @@ -0,0 +1,12 @@ +extern crate core; +use core::ffi::c_int; + +extern "C" { + fn multiply(a: c_int, b: c_int) -> c_int; +} + +fn main() { + unsafe { + println!("Result: {}", multiply(100, 5)); + } +} diff --git a/hello-rust/src/multiply.c b/hello-rust/src/multiply.c new file mode 100644 index 0000000..faeec14 --- /dev/null +++ b/hello-rust/src/multiply.c @@ -0,0 +1,11 @@ +#include +#include + +int32_t multiply(int32_t a, int32_t b) { + printf("[C] Hello from C!\n"); + printf("[C] Input a is: %i \n", a); + printf("[C] Input b is: %i \n", b); + printf("[C] Multiplying and returning result to Rust..\n"); + + return a * b; +}