aboutsummaryrefslogtreecommitdiff
path: root/src/call_asm.rs
diff options
context:
space:
mode:
authorGravatar Jonas Schievink <jonasschievink@gmail.com> 2020-08-29 02:17:35 +0200
committerGravatar Jonas Schievink <jonasschievink@gmail.com> 2020-08-29 02:47:05 +0200
commita3572979cb88b0ca5760b4a672f652250dadf3bb (patch)
treed46c96861950cce6aa9e9a1872c9f55a18e5cf30 /src/call_asm.rs
parent54f541c87b0723ad8976f978b2233d56100702b6 (diff)
downloadcortex-m-a3572979cb88b0ca5760b4a672f652250dadf3bb.tar.gz
cortex-m-a3572979cb88b0ca5760b4a672f652250dadf3bb.tar.zst
cortex-m-a3572979cb88b0ca5760b4a672f652250dadf3bb.zip
Merge asm implementations
Diffstat (limited to 'src/call_asm.rs')
-rw-r--r--src/call_asm.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/call_asm.rs b/src/call_asm.rs
new file mode 100644
index 0000000..295277f
--- /dev/null
+++ b/src/call_asm.rs
@@ -0,0 +1,24 @@
+/// An internal macro to invoke an assembly routine.
+///
+/// Depending on whether the unstable `inline-asm` feature is enabled, this will either call into
+/// the inline assembly implementation directly, or through the FFI shim (see `asm/lib.rs`).
+macro_rules! call_asm {
+ ( $func:ident ( $($args:ident: $tys:ty),* ) $(-> $ret:ty)? ) => {{
+ #[allow(unused_unsafe)]
+ unsafe {
+ match () {
+ #[cfg(feature = "inline-asm")]
+ () => crate::asm::inline::$func($($args),*),
+
+ #[cfg(not(feature = "inline-asm"))]
+ () => {
+ extern "C" {
+ fn $func($($args: $tys),*) $(-> $ret)?;
+ }
+
+ $func($($args),*)
+ },
+ }
+ }
+ }};
+}