about summary refs log tree commit diff
path: root/src/libcoretest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-08-18 04:23:25 +0000
committerbors <bors@rust-lang.org>2015-08-18 04:23:25 +0000
commit4c0ffc0e38f1a00925935dce859262cb4e4d6f55 (patch)
tree0a6b813b76397ec1d6acba8e8d7c9a3d7514d119 /src/libcoretest
parentde67d62c6b7e76ca53b66b3796258238348b3c96 (diff)
parent1ddee8070d3cb83609b1f71c29e3deda3d30fd51 (diff)
downloadrust-4c0ffc0e38f1a00925935dce859262cb4e4d6f55.tar.gz
rust-4c0ffc0e38f1a00925935dce859262cb4e4d6f55.zip
Auto merge of #27823 - eefriedman:float-dep-core, r=alexcrichton
There wasn't any particular reason the functions needed to be there
anyway, so just get rid of them, and adjust libstd to compensate.

With this change, libcore depends on exactly two floating-point functions:
fmod and fmodf.  They are implicitly referenced because they are used to
implement "%".

Dependencies of libcore on Linux x86-x64 with this patch:
```
0000000000000000         *UND*	0000000000000000 __powidf2
0000000000000000         *UND*	0000000000000000 __powisf2
0000000000000000         *UND*	0000000000000000 fmod
0000000000000000         *UND*	0000000000000000 fmodf
0000000000000000         *UND*	0000000000000000 memcmp
0000000000000000         *UND*	0000000000000000 memcpy
0000000000000000         *UND*	0000000000000000 memset
0000000000000000         *UND*	0000000000000000 rust_begin_unwind
0000000000000000         *UND*	0000000000000000 rust_eh_personality
```
Diffstat (limited to 'src/libcoretest')
-rw-r--r--src/libcoretest/num/flt2dec/mod.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libcoretest/num/flt2dec/mod.rs b/src/libcoretest/num/flt2dec/mod.rs
index 488cd3a779c..8ae33a44202 100644
--- a/src/libcoretest/num/flt2dec/mod.rs
+++ b/src/libcoretest/num/flt2dec/mod.rs
@@ -164,12 +164,26 @@ fn check_exact<F, T>(mut f: F, v: T, vstr: &str, expected: &[u8], expectedk: i16
     }
 }
 
+trait TestableFloat : DecodableFloat + fmt::Display {
+    /// Returns `x * 2^exp`. Almost same to `std::{f32,f64}::ldexp`.
+    /// This is used for testing.
+    fn ldexpi(f: i64, exp: isize) -> Self;
+}
+
+impl TestableFloat for f32 {
+    fn ldexpi(f: i64, exp: isize) -> Self { f as Self * (exp as Self).exp2() }
+}
+
+impl TestableFloat for f64 {
+    fn ldexpi(f: i64, exp: isize) -> Self { f as Self * (exp as Self).exp2() }
+}
+
 fn check_exact_one<F, T>(mut f: F, x: i64, e: isize, tstr: &str, expected: &[u8], expectedk: i16)
-        where T: DecodableFloat + fmt::Display,
+        where T: TestableFloat,
               F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) {
     // use a large enough buffer
     let mut buf = [b'_'; 1024];
-    let v: T = DecodableFloat::ldexpi(x, e);
+    let v: T = TestableFloat::ldexpi(x, e);
     let decoded = decode_finite(v);
 
     try_exact!(f(&decoded) => &mut buf, &expected, expectedk;