about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-05-08 14:44:17 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-05-12 14:50:36 -0700
commit4cc025d83c5e3e54130dff08987982a0926e4cfa (patch)
treeeb585e4661c73071ccffd27a005f90524f0da4f1 /src/libstd/num
parent315750ac92a8114a96b35352ec88f82d21d5fbec (diff)
downloadrust-4cc025d83c5e3e54130dff08987982a0926e4cfa.tar.gz
rust-4cc025d83c5e3e54130dff08987982a0926e4cfa.zip
Scale back changes made
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/f32.rs40
-rw-r--r--src/libstd/num/f64.rs11
2 files changed, 17 insertions, 34 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 934cf056ec1..e31d97b3240 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -31,10 +31,7 @@ pub use core::f32::consts;
 #[allow(dead_code)]
 mod cmath {
     use libc::{c_float, c_int};
-    #[cfg(windows)]
-    use libc::c_double;
 
-    #[link_name = "m"]
     extern {
         pub fn acosf(n: c_float) -> c_float;
         pub fn asinf(n: c_float) -> c_float;
@@ -59,35 +56,28 @@ mod cmath {
         pub fn tanhf(n: c_float) -> c_float;
         pub fn tgammaf(n: c_float) -> c_float;
 
-        #[cfg(unix)]
+        #[cfg_attr(all(windows, target_env = "msvc"), link_name = "__lgammaf_r")]
         pub fn lgammaf_r(n: c_float, sign: &mut c_int) -> c_float;
-        #[cfg(unix)]
+        #[cfg_attr(all(windows, target_env = "msvc"), link_name = "_hypotf")]
         pub fn hypotf(x: c_float, y: c_float) -> c_float;
-        #[cfg(unix)]
+
+        #[cfg(any(unix, all(windows, not(target_env = "msvc"))))]
         pub fn frexpf(n: c_float, value: &mut c_int) -> c_float;
-        #[cfg(unix)]
+        #[cfg(any(unix, all(windows, not(target_env = "msvc"))))]
         pub fn ldexpf(x: c_float, n: c_int) -> c_float;
-
-        #[cfg(windows)]
-        #[link_name="__lgammaf_r"]
-        pub fn lgammaf_r(n: c_float, sign: &mut c_int) -> c_float;
-
-        #[cfg(windows)]
-        #[link_name="_hypotf"]
-        pub fn hypotf(x: c_float, y: c_float) -> c_float;
-
-        #[cfg(windows)]
-        fn frexp(n: c_double, value: &mut c_int) -> c_double;
-
-        #[cfg(windows)]
-        fn ldexp(x: c_double, n: c_int) -> c_double;
     }
 
-    #[cfg(windows)]
-    pub unsafe fn ldexpf(x: c_float, n: c_int) -> c_float { return ldexp(x as c_double, n) as c_float; }
+    #[cfg(all(windows, target_env = "msvc"))]
+    pub unsafe fn ldexpf(x: c_float, n: c_int) -> c_float {
+        f64::ldexp(x as f64, n as isize) as c_float
+    }
 
-    #[cfg(windows)]
-    pub unsafe fn frexpf(x: c_float, value: &mut c_int) -> c_float { return frexp(x as c_double, value) as c_float; }
+    #[cfg(all(windows, target_env = "msvc"))]
+    pub unsafe fn frexpf(x: c_float, value: &mut c_int) -> c_float {
+        let (a, b) = f64::frexp(x as f64);
+        *value = b as c_int;
+        a as c_float
+    }
 }
 
 #[cfg(not(test))]
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index a09a82b8552..e87855ffd4e 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -68,17 +68,10 @@ mod cmath {
         pub fn y1(n: c_double) -> c_double;
         pub fn yn(i: c_int, n: c_double) -> c_double;
 
-        #[cfg(unix)]
+        #[cfg_attr(all(windows, target_env = "msvc"), link_name = "__lgamma_r")]
         pub fn lgamma_r(n: c_double, sign: &mut c_int) -> c_double;
-        #[cfg(windows)]
-        #[link_name="__lgamma_r"]
-        pub fn lgamma_r(n: c_double, sign: &mut c_int) -> c_double;
-
-        #[cfg(unix)]
-        pub fn hypot(x: c_double, y: c_double) -> c_double;
 
-        #[cfg(windows)]
-        #[link_name="_hypot"]
+        #[cfg_attr(all(windows, target_env = "msvc"), link_name = "_hypot")]
         pub fn hypot(x: c_double, y: c_double) -> c_double;
     }
 }