Skip to content

Commit 57085be

Browse files
author
Jorge Aparicio
committed
ARM: keep some non-aeabi symbols around
- multi3: there's no aeabi equivalent - divmod{s,d}i4: these are directly called by __aeabi_{l,i}divmod - add{s,d}f3: required by the C sub{s,d}f3 implementation but make sure they also use the AAPCS calling convention
1 parent dfa7b16 commit 57085be

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

src/float/add.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ use core::num::Wrapping;
44
use float::Float;
55

66
macro_rules! add {
7-
($intrinsic:ident: $ty:ty) => {
7+
($abi:tt, $intrinsic:ident: $ty:ty) => {
88
/// Returns `a + b`
99
#[allow(unused_parens)]
10-
#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
11-
#[cfg_attr(all(not(test), target_arch = "arm"), inline(always))]
12-
pub extern fn $intrinsic(a: $ty, b: $ty) -> $ty {
10+
#[cfg_attr(not(test), no_mangle)]
11+
pub extern $abi fn $intrinsic(a: $ty, b: $ty) -> $ty {
1312
let one = Wrapping(1 as <$ty as Float>::Int);
1413
let zero = Wrapping(0 as <$ty as Float>::Int);
1514

@@ -182,8 +181,17 @@ macro_rules! add {
182181
}
183182
}
184183

185-
add!(__addsf3: f32);
186-
add!(__adddf3: f64);
184+
#[cfg(target_arch = "arm")]
185+
add!("aapcs", __addsf3: f32);
186+
187+
#[cfg(not(target_arch = "arm"))]
188+
add!("C", __addsf3: f32);
189+
190+
#[cfg(target_arch = "arm")]
191+
add!("aapcs", __adddf3: f64);
192+
193+
#[cfg(not(target_arch = "arm"))]
194+
add!("C", __adddf3: f64);
187195

188196
// NOTE(cfg) for some reason, on arm*-unknown-linux-gnueabi*, our implementation doesn't
189197
// match the output of its gcc_s or compiler-rt counterpart. Until we investigate further, we'll

src/int/mul.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use int::LargeInt;
22
use int::Int;
33

44
macro_rules! mul {
5-
($intrinsic:ident: $ty:ty) => {
5+
($(#[$attr:meta])+ |
6+
$abi:tt, $intrinsic:ident: $ty:ty) => {
67
/// Returns `a * b`
7-
#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
8-
#[cfg_attr(all(not(test), target_arch = "arm"), inline(always))]
9-
pub extern "C" fn $intrinsic(a: $ty, b: $ty) -> $ty {
8+
$(#[$attr])+
9+
pub extern $abi fn $intrinsic(a: $ty, b: $ty) -> $ty {
1010
let half_bits = <$ty>::bits() / 4;
1111
let lower_mask = !0 >> half_bits;
1212
let mut low = (a.low() & lower_mask).wrapping_mul(b.low() & lower_mask);
@@ -74,9 +74,17 @@ macro_rules! mulo {
7474
}
7575

7676
#[cfg(not(all(feature = "c", target_arch = "x86")))]
77-
mul!(__muldi3: u64);
77+
mul!(#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
78+
#[cfg_attr(all(not(test), target_arch = "arm"), inline(always))]
79+
| "C", __muldi3: u64);
80+
81+
#[cfg(not(target_arch = "arm"))]
82+
mul!(#[cfg_attr(not(test), no_mangle)]
83+
| "C", __multi3: i128);
7884

79-
mul!(__multi3: i128);
85+
#[cfg(target_arch = "arm")]
86+
mul!(#[cfg_attr(not(test), no_mangle)]
87+
| "aapcs", __multi3: i128);
8088

8189
mulo!(__mulosi4: i32);
8290
mulo!(__mulodi4: i64);

src/int/sdiv.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ macro_rules! mod_ {
4040
}
4141

4242
macro_rules! divmod {
43-
($intrinsic:ident, $div:ident: $ty:ty) => {
43+
($abi:tt, $intrinsic:ident, $div:ident: $ty:ty) => {
4444
/// Returns `a / b` and sets `*rem = n % d`
45-
#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
46-
#[cfg_attr(all(not(test), target_arch = "arm"), inline(always))]
47-
pub extern "C" fn $intrinsic(a: $ty, b: $ty, rem: &mut $ty) -> $ty {
45+
#[cfg_attr(not(test), no_mangle)]
46+
pub extern $abi fn $intrinsic(a: $ty, b: $ty, rem: &mut $ty) -> $ty {
4847
#[cfg(all(feature = "c", any(target_arch = "x86")))]
4948
extern {
5049
fn $div(a: $ty, b: $ty) -> $ty;
@@ -87,9 +86,13 @@ mod_!(__modti3: i128, u128);
8786
mod_!(__modti3: i128, u128, ::U64x2, ::sconv);
8887

8988
#[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"))))]
90-
divmod!(__divmodsi4, __divsi3: i32);
89+
divmod!("C", __divmodsi4, __divsi3: i32);
90+
91+
#[cfg(target_arch = "arm")]
92+
divmod!("aapcs", __divmoddi4, __divdi3: i64);
9193

92-
divmod!(__divmoddi4, __divdi3: i64);
94+
#[cfg(not(target_arch = "arm"))]
95+
divmod!("C", __divmoddi4, __divdi3: i64);
9396

9497
#[cfg(test)]
9598
mod tests {

src/int/udiv.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ pub extern "C" fn __umodsi3(n: u32, d: u32) -> u32 {
8080
#[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"), not(thumbv6m))))]
8181
#[cfg_attr(not(test), no_mangle)]
8282
pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 {
83-
#[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios")))]
83+
#[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios"), not(thumbv6m)))]
8484
extern "C" {
8585
fn __udivsi3(n: u32, d: u32) -> u32;
8686
}
8787

8888
let q = match () {
89-
#[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios")))]
89+
#[cfg(all(feature = "c", target_arch = "arm", not(target_os = "ios"), not(thumbv6m)))]
9090
() => unsafe { __udivsi3(n, d) },
91-
#[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"))))]
91+
#[cfg(not(all(feature = "c", target_arch = "arm", not(target_os = "ios"), not(thumbv6m))))]
9292
() => __udivsi3(n, d),
9393
};
9494
if let Some(rem) = rem {

0 commit comments

Comments
 (0)