Skip to content

Commit 337bd7e

Browse files
author
Jorge Aparicio
committed
armhf: don't compare our impls against gcc_s
1 parent 225d4c9 commit 337bd7e

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[package]
22
authors = ["Jorge Aparicio <[email protected]>"]
3+
build = "build.rs"
34
name = "rustc_builtins"
45
version = "0.1.0"
56

build.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::env;
2+
3+
fn main() {
4+
if env::var("TARGET").unwrap().ends_with("hf") {
5+
println!("cargo:rustc-cfg=gnueabihf")
6+
}
7+
}

src/float/add.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -216,21 +216,28 @@ mod tests {
216216
let (a, b) = (f32::from_repr(a.0), f32::from_repr(b.0));
217217
let x = super::__addsf3(a, b);
218218

219-
if let Some(addsf3) = gcc_s::addsf3() {
220-
x.eq_repr(unsafe { addsf3(a, b) })
221-
} else {
222-
x.eq_repr(a + b)
219+
match gcc_s::addsf3() {
220+
// NOTE(cfg) for some reason, on hard float targets, our implementation doesn't
221+
// match the output of its gcc_s counterpart. Until we investigate further, we'll
222+
// just avoid testing against gcc_s on those targets. Do note that our
223+
// implementation matches the output of the FPU instruction on *hard* float targets
224+
// and matches its gcc_s counterpart on *soft* float targets.
225+
#[cfg(not(gnueabihf))]
226+
Some(addsf3) => x.eq_repr(unsafe { addsf3(a, b) }),
227+
_ => x.eq_repr(a + b),
223228
}
224229
}
225230

226231
fn adddf3(a: U64, b: U64) -> bool {
227232
let (a, b) = (f64::from_repr(a.0), f64::from_repr(b.0));
228233
let x = super::__adddf3(a, b);
229234

230-
if let Some(adddf3) = gcc_s::adddf3() {
231-
x.eq_repr(unsafe { adddf3(a, b) })
232-
} else {
233-
x.eq_repr(a + b)
235+
match gcc_s::adddf3() {
236+
// NOTE(cfg) See NOTE above
237+
#[cfg(not(gnueabihf))]
238+
Some(adddf3) => x.eq_repr(unsafe { adddf3(a, b) }),
239+
_ => x.eq_repr(a + b),
240+
234241
}
235242
}
236243
}

0 commit comments

Comments
 (0)