summaryrefslogtreecommitdiff
path: root/doc/interoperability/rust-from-c/foo
diff options
context:
space:
mode:
Diffstat (limited to 'doc/interoperability/rust-from-c/foo')
-rw-r--r--doc/interoperability/rust-from-c/foo/TARGETS9
-rw-r--r--doc/interoperability/rust-from-c/foo/foo.h2
-rw-r--r--doc/interoperability/rust-from-c/foo/foo.rs4
3 files changed, 15 insertions, 0 deletions
diff --git a/doc/interoperability/rust-from-c/foo/TARGETS b/doc/interoperability/rust-from-c/foo/TARGETS
new file mode 100644
index 0000000..8d19b35
--- /dev/null
+++ b/doc/interoperability/rust-from-c/foo/TARGETS
@@ -0,0 +1,9 @@
+{ "foo":
+ { "type": ["@", "rules-rust", "rust", "library"]
+ , "name": ["foo"]
+ , "crate_root": ["foo.rs"]
+ , "native": ["true"]
+ , "c_hdrs": ["foo.h"]
+ , "stage": ["foo"]
+ }
+}
diff --git a/doc/interoperability/rust-from-c/foo/foo.h b/doc/interoperability/rust-from-c/foo/foo.h
new file mode 100644
index 0000000..88deb2e
--- /dev/null
+++ b/doc/interoperability/rust-from-c/foo/foo.h
@@ -0,0 +1,2 @@
+#pragma once
+int foo(int);
diff --git a/doc/interoperability/rust-from-c/foo/foo.rs b/doc/interoperability/rust-from-c/foo/foo.rs
new file mode 100644
index 0000000..65cbffc
--- /dev/null
+++ b/doc/interoperability/rust-from-c/foo/foo.rs
@@ -0,0 +1,4 @@
+#[no_mangle]
+pub extern "C" fn foo(x: i32) -> i32 {
+ return x.abs();
+}