Skip to content

Commit

Permalink
Add the naked attribute of intrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
DianQK committed Dec 17, 2023
1 parent 99a0ebd commit a215988
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions rp2040-hal/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,29 @@ macro_rules! intrinsics {
intrinsics!($($rest)*);
};

// Naked functions are special: we can't generate wrappers for them since
// they use a custom calling convention.
(
#[naked]
$(#[$($attr:tt)*])*
unsafe extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
$($body:tt)*
}

$($rest:tt)*
) => (
mod $name {
#[naked]
$(#[$($attr)*])*
#[no_mangle]
pub unsafe extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
$($body)*
}
}

intrinsics!($($rest)*);
);

(
$(#[$($attr:tt)*])*
unsafe extern $abi:tt fn $name:ident( $($argname:ident: $ty:ty),* ) $(-> $ret:ty)? {
Expand Down
1 change: 1 addition & 0 deletions rp2040-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#![warn(missing_docs)]
#![no_std]
#![feature(naked_functions)]

#[doc(hidden)]
pub use paste;
Expand Down

0 comments on commit a215988

Please sign in to comment.