Browse Source

remove the current test suite

master
Jorge Aparicio 5 years ago
parent
commit
cc0d8ba2d1
  1. 6
      Cargo.toml
  2. 25
      src/float/add.rs
  3. 109
      src/float/conv.rs
  4. 19
      src/float/pow.rs
  5. 25
      src/float/sub.rs
  6. 63
      src/int/mul.rs
  7. 117
      src/int/sdiv.rs
  8. 74
      src/int/shift.rs
  9. 117
      src/int/udiv.rs
  10. 17
      src/lib.rs

6
Cargo.toml

@ -11,12 +11,6 @@ rustc-cfg = "0.3.0"
optional = true
version = "0.3.36"
[dev-dependencies]
quickcheck = "0.3.1"
rand = "0.3.14"
gcc_s = { path = "gcc_s" }
compiler-rt = { path = "compiler-rt" }
[features]
# Build the missing intrinsics from compiler-rt C source code
c = ["gcc"]

25
src/float/add.rs

@ -192,28 +192,3 @@ add!("aapcs", __adddf3: f64);
#[cfg(not(target_arch = "arm"))]
add!("C", __adddf3: f64);
// NOTE(cfg) for some reason, on arm*-unknown-linux-gnueabi*, our implementation doesn't
// match the output of its gcc_s or compiler-rt counterpart. Until we investigate further, we'll
// just avoid testing against them on those targets. Do note that our implementation gives the
// correct answer; gcc_s and compiler-rt are incorrect in this case.
#[cfg(all(test, not(arm_linux)))]
mod tests {
use core::{f32, f64};
use qc::{F32, F64};
check! {
fn __addsf3(f: extern "C" fn(f32, f32) -> f32,
a: F32,
b: F32)
-> Option<F32> {
Some(F32(f(a.0, b.0)))
}
fn __adddf3(f: extern "C" fn(f64, f64) -> f64,
a: F64,
b: F64) -> Option<F64> {
Some(F64(f(a.0, b.0)))
}
}
}

109
src/float/conv.rs

@ -155,112 +155,3 @@ fp_fix!(__fixunssfsi: f32, u32);
fp_fix!(__fixunssfdi: f32, u64);
fp_fix!(__fixunsdfsi: f64, u32);
fp_fix!(__fixunsdfdi: f64, u64);
// NOTE(cfg) for some reason, on arm*-unknown-linux-gnueabihf, our implementation doesn't
// match the output of its gcc_s or compiler-rt counterpart. Until we investigate further, we'll
// just avoid testing against them on those targets. Do note that our implementation gives the
// correct answer; gcc_s and compiler-rt are incorrect in this case.
//
#[cfg(all(test, not(arm_linux)))]
mod tests {
use qc::{I32, U32, I64, U64, F32, F64};
check! {
fn __floatsisf(f: extern "C" fn(i32) -> f32,
a: I32)
-> Option<F32> {
Some(F32(f(a.0)))
}
fn __floatsidf(f: extern "C" fn(i32) -> f64,
a: I32)
-> Option<F64> {
Some(F64(f(a.0)))
}
fn __floatdidf(f: extern "C" fn(i64) -> f64,
a: I64)
-> Option<F64> {
Some(F64(f(a.0)))
}
fn __floatunsisf(f: extern "C" fn(u32) -> f32,
a: U32)
-> Option<F32> {
Some(F32(f(a.0)))
}
fn __floatunsidf(f: extern "C" fn(u32) -> f64,
a: U32)
-> Option<F64> {
Some(F64(f(a.0)))
}
fn __floatundidf(f: extern "C" fn(u64) -> f64,
a: U64)
-> Option<F64> {
Some(F64(f(a.0)))
}
fn __fixsfsi(f: extern "C" fn(f32) -> i32,
a: F32)
-> Option<I32> {
if (a.0 as f64) > (i32::max_value() as f64) ||
(a.0 as f64) < (i32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I32(f(a.0))) }
}
fn __fixsfdi(f: extern "C" fn(f32) -> i64,
a: F32)
-> Option<I64> {
if (a.0 as f64) > (i64::max_value() as f64) ||
(a.0 as f64) < (i64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I64(f(a.0))) }
}
fn __fixdfsi(f: extern "C" fn(f64) -> i32,
a: F64)
-> Option<I32> {
if a.0 > (i32::max_value() as f64) ||
a.0 < (i32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I32(f(a.0))) }
}
fn __fixdfdi(f: extern "C" fn(f64) -> i64,
a: F64)
-> Option<I64> {
if a.0 > (i64::max_value() as f64) ||
a.0 < (i64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(I64(f(a.0))) }
}
fn __fixunssfsi(f: extern "C" fn(f32) -> u32,
a: F32)
-> Option<U32> {
if (a.0 as f64) > (u32::max_value() as f64) ||
(a.0 as f64) < (u32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U32(f(a.0))) }
}
fn __fixunssfdi(f: extern "C" fn(f32) -> u64,
a: F32)
-> Option<U64> {
if (a.0 as f64) > (u64::max_value() as f64) ||
(a.0 as f64) < (u64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U64(f(a.0))) }
}
fn __fixunsdfsi(f: extern "C" fn(f64) -> u32,
a: F64)
-> Option<U32> {
if a.0 > (u32::max_value() as f64) ||
a.0 < (u32::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U32(f(a.0))) }
}
fn __fixunsdfdi(f: extern "C" fn(f64) -> u64,
a: F64)
-> Option<U64> {
if a.0 <= (u64::max_value() as f64) ||
a.0 >= (u64::min_value() as f64) || a.0.is_nan() {
None
} else { Some(U64(f(a.0))) }
}
}
}

19
src/float/pow.rs

@ -28,22 +28,3 @@ macro_rules! pow {
pow!(__powisf2: f32, i32);
pow!(__powidf2: f64, i32);
#[cfg(test)]
mod tests {
use qc::{I32, F32, F64};
check! {
fn __powisf2(f: extern "C" fn(f32, i32) -> f32,
a: F32,
b: I32) -> Option<F32> {
Some(F32(f(a.0, b.0)))
}
fn __powidf2(f: extern "C" fn(f64, i32) -> f64,
a: F64,
b: I32) -> Option<F64> {
Some(F64(f(a.0, b.0)))
}
}
}

25
src/float/sub.rs

@ -18,28 +18,3 @@ sub!(#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
sub!(#[cfg_attr(all(not(test), not(target_arch = "arm")), no_mangle)]
#[cfg_attr(all(not(test), target_arch = "arm"), inline(always))]
| __subdf3: f64);
// NOTE(cfg) for some reason, on arm*-unknown-linux-gnueabi*, our implementation doesn't
// match the output of its gcc_s or compiler-rt counterpart. Until we investigate further, we'll
// just avoid testing against them on those targets. Do note that our implementation gives the
// correct answer; gcc_s and compiler-rt are incorrect in this case.
#[cfg(all(test, not(arm_linux)))]
mod tests {
use core::{f32, f64};
use qc::{F32, F64};
check! {
fn __subsf3(f: extern "C" fn(f32, f32) -> f32,
a: F32,
b: F32)
-> Option<F32> {
Some(F32(f(a.0, b.0)))
}
fn __subdf3(f: extern "C" fn(f64, f64) -> f64,
a: F64,
b: F64) -> Option<F64> {
Some(F64(f(a.0, b.0)))
}
}
}

63
src/int/mul.rs

@ -93,66 +93,3 @@ mulo!(__mulodi4: i64);
mulo!(__muloti4: i128, "unadjusted");
#[cfg(not(all(windows, target_pointer_width="64")))]
mulo!(__muloti4: i128);
#[cfg(test)]
mod tests {
use qc::{I32, I64, U64};
check! {
fn __muldi3(f: extern "C" fn(u64, u64) -> u64, a: U64, b: U64)
-> Option<u64> {
Some(f(a.0, b.0))
}
fn __mulosi4(f: extern "C" fn(i32, i32, &mut i32) -> i32,
a: I32,
b: I32) -> Option<(i32, i32)> {
let (a, b) = (a.0, b.0);
let mut overflow = 2;
let r = f(a, b, &mut overflow);
if overflow != 0 && overflow != 1 {
panic!("Invalid value {} for overflow", overflow);
}
Some((r, overflow))
}
fn __mulodi4(f: extern "C" fn(i64, i64, &mut i32) -> i64,
a: I64,
b: I64) -> Option<(i64, i32)> {
let (a, b) = (a.0, b.0);
let mut overflow = 2;
let r = f(a, b, &mut overflow);
if overflow != 0 && overflow != 1 {
panic!("Invalid value {} for overflow", overflow);
}
Some((r, overflow))
}
}
}
#[cfg(test)]
#[cfg(all(not(windows),
not(target_arch = "mips64"),
not(target_arch = "mips64el"),
target_pointer_width="64"))]
mod tests_i128 {
use qc::I128;
check! {
fn __multi3(f: extern "C" fn(i128, i128) -> i128, a: I128, b: I128)
-> Option<i128> {
Some(f(a.0, b.0))
}
fn __muloti4(f: extern "C" fn(i128, i128, &mut i32) -> i128,
a: I128,
b: I128) -> Option<(i128, i32)> {
let (a, b) = (a.0, b.0);
let mut overflow = 2;
let r = f(a, b, &mut overflow);
if overflow != 0 && overflow != 1 {
panic!("Invalid value {} for overflow", overflow);
}
Some((r, overflow))
}
}
}

117
src/int/sdiv.rs

@ -100,120 +100,3 @@ divmod!("aapcs", __divmoddi4, __divdi3: i64);
#[cfg(not(target_arch = "arm"))]
divmod!("C", __divmoddi4, __divdi3: i64);
#[cfg(test)]
mod tests {
use qc::{U32, U64};
check! {
fn __divdi3(f: extern "C" fn(i64, i64) -> i64, n: U64, d: U64) -> Option<i64> {
let (n, d) = (n.0 as i64, d.0 as i64);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __moddi3(f: extern "C" fn(i64, i64) -> i64, n: U64, d: U64) -> Option<i64> {
let (n, d) = (n.0 as i64, d.0 as i64);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
#[cfg(target_arch = "arm")]
fn __divmoddi4(f: extern "aapcs" fn(i64, i64, &mut i64) -> i64,
n: U64,
d: U64) -> Option<(i64, i64)> {
let (n, d) = (n.0 as i64, d.0 as i64);
if d == 0 {
None
} else {
let mut r = 0;
let q = f(n, d, &mut r);
Some((q, r))
}
}
#[cfg(not(target_arch = "arm"))]
fn __divmoddi4(f: extern "C" fn(i64, i64, &mut i64) -> i64,
n: U64,
d: U64) -> Option<(i64, i64)> {
let (n, d) = (n.0 as i64, d.0 as i64);
if d == 0 {
None
} else {
let mut r = 0;
let q = f(n, d, &mut r);
Some((q, r))
}
}
fn __divsi3(f: extern "C" fn(i32, i32) -> i32,
n: U32,
d: U32) -> Option<i32> {
let (n, d) = (n.0 as i32, d.0 as i32);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __modsi3(f: extern "C" fn(i32, i32) -> i32,
n: U32,
d: U32) -> Option<i32> {
let (n, d) = (n.0 as i32, d.0 as i32);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __divmodsi4(f: extern "C" fn(i32, i32, &mut i32) -> i32,
n: U32,
d: U32) -> Option<(i32, i32)> {
let (n, d) = (n.0 as i32, d.0 as i32);
if d == 0 {
None
} else {
let mut r = 0;
let q = f(n, d, &mut r);
Some((q, r))
}
}
}
}
#[cfg(test)]
#[cfg(all(not(windows),
not(target_arch = "mips64"),
not(target_arch = "mips64el"),
target_pointer_width="64"))]
mod tests_i128 {
use qc::U128;
check! {
fn __divti3(f: extern "C" fn(i128, i128) -> i128, n: U128, d: U128) -> Option<i128> {
let (n, d) = (n.0 as i128, d.0 as i128);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __modti3(f: extern "C" fn(i128, i128) -> i128, n: U128, d: U128) -> Option<i128> {
let (n, d) = (n.0 as i128, d.0 as i128);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
}
}

74
src/int/shift.rs

@ -72,77 +72,3 @@ ashr!(__ashrti3: i128);
lshr!(__lshrdi3: u64);
lshr!(__lshrti3: u128);
#[cfg(test)]
mod tests {
use qc::{I64, U64};
// NOTE We purposefully stick to `u32` for `b` here because we want "small" values (b < 64)
check! {
fn __ashldi3(f: extern "C" fn(u64, u32) -> u64, a: U64, b: u32) -> Option<u64> {
let a = a.0;
if b >= 64 {
None
} else {
Some(f(a, b))
}
}
fn __ashrdi3(f: extern "C" fn(i64, u32) -> i64, a: I64, b: u32) -> Option<i64> {
let a = a.0;
if b >= 64 {
None
} else {
Some(f(a, b))
}
}
fn __lshrdi3(f: extern "C" fn(u64, u32) -> u64, a: U64, b: u32) -> Option<u64> {
let a = a.0;
if b >= 64 {
None
} else {
Some(f(a, b))
}
}
}
}
#[cfg(test)]
#[cfg(all(not(windows),
not(target_arch = "mips64"),
not(target_arch = "mips64el"),
target_pointer_width="64"))]
mod tests_i128 {
use qc::{I128, U128};
// NOTE We purposefully stick to `u32` for `b` here because we want "small" values (b < 64)
check! {
fn __ashlti3(f: extern "C" fn(u128, u32) -> u128, a: U128, b: u32) -> Option<u128> {
let a = a.0;
if b >= 64 {
None
} else {
Some(f(a, b))
}
}
fn __ashrti3(f: extern "C" fn(i128, u32) -> i128, a: I128, b: u32) -> Option<i128> {
let a = a.0;
if b >= 64 {
None
} else {
Some(f(a, b))
}
}
fn __lshrti3(f: extern "C" fn(u128, u32) -> u128, a: U128, b: u32) -> Option<u128> {
let a = a.0;
if b >= 128 {
None
} else {
Some(f(a, b))
}
}
}
}

117
src/int/udiv.rs

@ -312,120 +312,3 @@ udivmodti4!(::U64x2, ::conv);
#[cfg(not(all(windows, target_pointer_width="64")))]
udivmodti4!(u128, |i|{ i });
#[cfg(test)]
mod tests {
use qc::{U32, U64};
check! {
fn __udivdi3(f: extern "C" fn(u64, u64) -> u64, n: U64, d: U64) -> Option<u64> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __umoddi3(f: extern "C" fn(u64, u64) -> u64, n: U64, d: U64) -> Option<u64> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __udivmoddi4(f: extern "C" fn(u64, u64, Option<&mut u64>) -> u64,
n: U64,
d: U64) -> Option<(u64, u64)> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
let mut r = 0;
let q = f(n, d, Some(&mut r));
Some((q, r))
}
}
fn __udivsi3(f: extern "C" fn(u32, u32) -> u32, n: U32, d: U32) -> Option<u32> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __umodsi3(f: extern "C" fn(u32, u32) -> u32, n: U32, d: U32) -> Option<u32> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __udivmodsi4(f: extern "C" fn(u32, u32, Option<&mut u32>) -> u32,
n: U32,
d: U32) -> Option<(u32, u32)> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
let mut r = 0;
let q = f(n, d, Some(&mut r));
Some((q, r))
}
}
}
}
#[cfg(test)]
#[cfg(all(not(windows),
not(target_arch = "mips64"),
not(target_arch = "mips64el"),
target_pointer_width="64"))]
mod tests_i128 {
use qc::U128;
check! {
fn __udivti3(f: extern "C" fn(u128, u128) -> u128,
n: U128,
d: U128) -> Option<u128> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __umodti3(f: extern "C" fn(u128, u128) -> u128,
n: U128,
d: U128) -> Option<u128> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
Some(f(n, d))
}
}
fn __udivmodti4(f: extern "C" fn(u128, u128, Option<&mut u128>) -> u128,
n: U128,
d: U128) -> Option<u128> {
let (n, d) = (n.0, d.0);
if d == 0 {
None
} else {
// FIXME fix the segfault when the remainder is requested
/*let mut r = 0;
let q = f(n, d, Some(&mut r));
Some((q, r))*/
Some(f(n, d, None))
}
}
}
}

17
src/lib.rs

@ -111,26 +111,9 @@ fn sconv(i: i128) -> U64x2 {
U64x2(j.low(), j.high())
}
#[cfg(test)]
#[cfg_attr(target_arch = "arm", macro_use)]
extern crate quickcheck;
#[cfg(test)]
extern crate core;
#[cfg(test)]
extern crate gcc_s;
#[cfg(test)]
extern crate compiler_rt;
#[cfg(test)]
extern crate rand;
#[cfg(test)]
#[macro_use]
mod qc;
pub mod int;
pub mod float;

Loading…
Cancel
Save