Skip to content

Commit 46085a2

Browse files
author
Jorge Aparicio
committed
i128 test: transmute intrinsic output before comparing
on Windows, these intrinsics return a U64x2 type because of ABI requirements
1 parent aa553fe commit 46085a2

File tree

1 file changed

+71
-15
lines changed

1 file changed

+71
-15
lines changed

build.rs

+71-15
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ use core::mem;
189189
target_os = "linux",
190190
test)))]
191191
use std::mem;
192+
192193
use compiler_builtins::float::add::__adddf3;
193194
194195
fn mk_f64(x: u64) -> f64 {
@@ -828,11 +829,22 @@ fn divsi3() {
828829
}
829830

830831
fn prologue() -> &'static str {
831-
"
832+
r#"
833+
#[cfg(all(target_arch = "arm",
834+
not(any(target_env = "gnu", target_env = "musl")),
835+
target_os = "linux",
836+
test))]
837+
use core::mem;
838+
#[cfg(not(all(target_arch = "arm",
839+
not(any(target_env = "gnu", target_env = "musl")),
840+
target_os = "linux",
841+
test)))]
842+
use std::mem;
843+
832844
use compiler_builtins::int::sdiv::__divti3;
833845
834846
static TEST_CASES: &[((i128, i128), i128)] = &[
835-
"
847+
"#
836848
}
837849

838850
fn epilogue() -> &'static str {
@@ -842,7 +854,7 @@ static TEST_CASES: &[((i128, i128), i128)] = &[
842854
#[test]
843855
fn divti3() {
844856
for &((a, b), c) in TEST_CASES {
845-
let c_ = __divti3(a, b);
857+
let c_: i128 = unsafe { mem::transmute(__divti3(a, b)) };
846858
assert_eq!(((a, b), c), ((a, b), c_));
847859
}
848860
}
@@ -1895,11 +1907,22 @@ fn modsi3() {
18951907
}
18961908

18971909
fn prologue() -> &'static str {
1898-
"
1910+
r#"
1911+
#[cfg(all(target_arch = "arm",
1912+
not(any(target_env = "gnu", target_env = "musl")),
1913+
target_os = "linux",
1914+
test))]
1915+
use core::mem;
1916+
#[cfg(not(all(target_arch = "arm",
1917+
not(any(target_env = "gnu", target_env = "musl")),
1918+
target_os = "linux",
1919+
test)))]
1920+
use std::mem;
1921+
18991922
use compiler_builtins::int::sdiv::__modti3;
19001923
19011924
static TEST_CASES: &[((i128, i128), i128)] = &[
1902-
"
1925+
"#
19031926
}
19041927

19051928
fn epilogue() -> &'static str {
@@ -1909,7 +1932,7 @@ static TEST_CASES: &[((i128, i128), i128)] = &[
19091932
#[test]
19101933
fn modti3() {
19111934
for &((a, b), c) in TEST_CASES {
1912-
let c_ = __modti3(a, b);
1935+
let c_: i128 = unsafe { mem::transmute(__modti3(a, b)) };
19131936
assert_eq!(((a, b), c), ((a, b), c_));
19141937
}
19151938
}
@@ -2913,11 +2936,22 @@ fn udivmodsi4() {
29132936
}
29142937

29152938
fn prologue() -> &'static str {
2916-
"
2939+
r#"
2940+
#[cfg(all(target_arch = "arm",
2941+
not(any(target_env = "gnu", target_env = "musl")),
2942+
target_os = "linux",
2943+
test))]
2944+
use core::mem;
2945+
#[cfg(not(all(target_arch = "arm",
2946+
not(any(target_env = "gnu", target_env = "musl")),
2947+
target_os = "linux",
2948+
test)))]
2949+
use std::mem;
2950+
29172951
use compiler_builtins::int::udiv::__udivmodti4;
29182952
29192953
static TEST_CASES: &[((u128, u128), (u128, u128))] = &[
2920-
"
2954+
"#
29212955
}
29222956

29232957
fn epilogue() -> &'static str {
@@ -2928,7 +2962,7 @@ static TEST_CASES: &[((u128, u128), (u128, u128))] = &[
29282962
fn udivmodti4() {
29292963
for &((a, b), (c, rem)) in TEST_CASES {
29302964
let mut rem_ = 0;
2931-
let c_ = __udivmodti4(a, b, Some(&mut rem_));
2965+
let c_: u128 = unsafe { mem::transmute(__udivmodti4(a, b, Some(&mut rem_))) };
29322966
assert_eq!(((a, b), (c, rem)), ((a, b), (c_, rem_)));
29332967
}
29342968
}
@@ -3036,11 +3070,22 @@ fn udivsi3() {
30363070
}
30373071

30383072
fn prologue() -> &'static str {
3039-
"
3073+
r#"
3074+
#[cfg(all(target_arch = "arm",
3075+
not(any(target_env = "gnu", target_env = "musl")),
3076+
target_os = "linux",
3077+
test))]
3078+
use core::mem;
3079+
#[cfg(not(all(target_arch = "arm",
3080+
not(any(target_env = "gnu", target_env = "musl")),
3081+
target_os = "linux",
3082+
test)))]
3083+
use std::mem;
3084+
30403085
use compiler_builtins::int::udiv::__udivti3;
30413086
30423087
static TEST_CASES: &[((u128, u128), u128)] = &[
3043-
"
3088+
"#
30443089
}
30453090

30463091
fn epilogue() -> &'static str {
@@ -3050,7 +3095,7 @@ static TEST_CASES: &[((u128, u128), u128)] = &[
30503095
#[test]
30513096
fn udivti3() {
30523097
for &((a, b), c) in TEST_CASES {
3053-
let c_ = __udivti3(a, b);
3098+
let c_: u128 = unsafe { mem::transmute(__udivti3(a, b)) };
30543099
assert_eq!(((a, b), c), ((a, b), c_));
30553100
}
30563101
}
@@ -3219,11 +3264,22 @@ fn umodsi3() {
32193264
}
32203265

32213266
fn prologue() -> &'static str {
3222-
"
3267+
r#"
3268+
#[cfg(all(target_arch = "arm",
3269+
not(any(target_env = "gnu", target_env = "musl")),
3270+
target_os = "linux",
3271+
test))]
3272+
use core::mem;
3273+
#[cfg(not(all(target_arch = "arm",
3274+
not(any(target_env = "gnu", target_env = "musl")),
3275+
target_os = "linux",
3276+
test)))]
3277+
use std::mem;
3278+
32233279
use compiler_builtins::int::udiv::__umodti3;
32243280
32253281
static TEST_CASES: &[((u128, u128), u128)] = &[
3226-
"
3282+
"#
32273283
}
32283284

32293285
fn epilogue() -> &'static str {
@@ -3233,7 +3289,7 @@ static TEST_CASES: &[((u128, u128), u128)] = &[
32333289
#[test]
32343290
fn umodti3() {
32353291
for &((a, b), c) in TEST_CASES {
3236-
let c_ = __umodti3(a, b);
3292+
let c_: u128 = unsafe { mem::transmute(__umodti3(a, b)) };
32373293
assert_eq!(((a, b), c), ((a, b), c_));
32383294
}
32393295
}

0 commit comments

Comments
 (0)