embassy-rs : @pennae Fix division intrinsics naming clash with rp2040-hal

This commit is contained in:
Peter Krull 2023-04-23 19:05:32 +02:00
parent ba47fe9c41
commit b283f213d9

View File

@ -352,7 +352,6 @@ core::arch::global_asm!(
".endm", ".endm",
); );
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
macro_rules! division_function { macro_rules! division_function {
( (
$name:ident $($intrinsic:ident)* ( $argty:ty ) { $name:ident $($intrinsic:ident)* ( $argty:ty ) {
@ -362,10 +361,11 @@ macro_rules! division_function {
#[cfg(all(target_arch = "arm", feature = "intrinsics"))] #[cfg(all(target_arch = "arm", feature = "intrinsics"))]
core::arch::global_asm!( core::arch::global_asm!(
// Mangle the name slightly, since this is a global symbol. // Mangle the name slightly, since this is a global symbol.
concat!(".global _rphal_", stringify!($name)), concat!(".section .text._erphal_", stringify!($name)),
concat!(".type _rphal_", stringify!($name), ", %function"), concat!(".global _erphal_", stringify!($name)),
concat!(".type _erphal_", stringify!($name), ", %function"),
".align 2", ".align 2",
concat!("_rphal_", stringify!($name), ":"), concat!("_erphal_", stringify!($name), ":"),
$( $(
concat!(".global ", stringify!($intrinsic)), concat!(".global ", stringify!($intrinsic)),
concat!(".type ", stringify!($intrinsic), ", %function"), concat!(".type ", stringify!($intrinsic), ", %function"),
@ -380,10 +380,11 @@ macro_rules! division_function {
#[cfg(all(target_arch = "arm", not(feature = "intrinsics")))] #[cfg(all(target_arch = "arm", not(feature = "intrinsics")))]
core::arch::global_asm!( core::arch::global_asm!(
// Mangle the name slightly, since this is a global symbol. // Mangle the name slightly, since this is a global symbol.
concat!(".global _rphal_", stringify!($name)), concat!(".section .text._erphal_", stringify!($name)),
concat!(".type _rphal_", stringify!($name), ", %function"), concat!(".global _erphal_", stringify!($name)),
concat!(".type _erphal_", stringify!($name), ", %function"),
".align 2", ".align 2",
concat!("_rphal_", stringify!($name), ":"), concat!("_erphal_", stringify!($name), ":"),
"hwdivider_head", "hwdivider_head",
$($begin),+ , $($begin),+ ,
@ -393,7 +394,7 @@ macro_rules! division_function {
#[cfg(target_arch = "arm")] #[cfg(target_arch = "arm")]
extern "aapcs" { extern "aapcs" {
// Connect a local name to global symbol above through FFI. // Connect a local name to global symbol above through FFI.
#[link_name = concat!("_rphal_", stringify!($name)) ] #[link_name = concat!("_erphal_", stringify!($name)) ]
fn $name(n: $argty, d: $argty) -> u64; fn $name(n: $argty, d: $argty) -> u64;
} }
@ -403,7 +404,6 @@ macro_rules! division_function {
}; };
} }
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
division_function! { division_function! {
unsigned_divmod __aeabi_uidivmod __aeabi_uidiv ( u32 ) { unsigned_divmod __aeabi_uidivmod __aeabi_uidiv ( u32 ) {
"str r0, [r2, #0x060]", // DIV_UDIVIDEND "str r0, [r2, #0x060]", // DIV_UDIVIDEND
@ -411,7 +411,6 @@ division_function! {
} }
} }
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
division_function! { division_function! {
signed_divmod __aeabi_idivmod __aeabi_idiv ( i32 ) { signed_divmod __aeabi_idivmod __aeabi_idiv ( i32 ) {
"str r0, [r2, #0x068]", // DIV_SDIVIDEND "str r0, [r2, #0x068]", // DIV_SDIVIDEND
@ -419,7 +418,6 @@ division_function! {
} }
} }
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> { fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> {
let packed = unsafe { unsigned_divmod(n, d) }; let packed = unsafe { unsigned_divmod(n, d) };
DivResult { DivResult {
@ -428,7 +426,6 @@ fn divider_unsigned(n: u32, d: u32) -> DivResult<u32> {
} }
} }
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
fn divider_signed(n: i32, d: i32) -> DivResult<i32> { fn divider_signed(n: i32, d: i32) -> DivResult<i32> {
let packed = unsafe { signed_divmod(n, d) }; let packed = unsafe { signed_divmod(n, d) };
// Double casts to avoid sign extension // Double casts to avoid sign extension
@ -439,7 +436,6 @@ fn divider_signed(n: i32, d: i32) -> DivResult<i32> {
} }
/// Result of divide/modulo operation /// Result of divide/modulo operation
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
struct DivResult<T> { struct DivResult<T> {
/// The quotient of divide/modulo operation /// The quotient of divide/modulo operation
pub quotient: T, pub quotient: T,
@ -447,7 +443,6 @@ struct DivResult<T> {
pub remainder: T, pub remainder: T,
} }
#[cfg(all(target_arch = "arm", feature = "intrinsics"))]
intrinsics! { intrinsics! {
extern "C" fn __udivsi3(n: u32, d: u32) -> u32 { extern "C" fn __udivsi3(n: u32, d: u32) -> u32 {
divider_unsigned(n, d).quotient divider_unsigned(n, d).quotient