about summary refs log tree commit diff
path: root/src/libstd/num
diff options
context:
space:
mode:
authorMathieu David <mathieudavid@mathieudavid.org>2015-07-27 20:46:01 +0200
committerMathieu David <mathieudavid@mathieudavid.org>2015-07-27 20:46:01 +0200
commitf6e9240a99e86d2c799dc29f179dd2870e51f71d (patch)
treea7e5ba20745b16949a45a4612b2708e262693a7b /src/libstd/num
parent003c3eaa62981b791f9eb7bcad015baa1e00d98c (diff)
parent3351afeecffcc9ebaeb1188a5cde976da8e4a5aa (diff)
downloadrust-f6e9240a99e86d2c799dc29f179dd2870e51f71d.tar.gz
rust-f6e9240a99e86d2c799dc29f179dd2870e51f71d.zip
Fix the relative path issue by including the files using include_bytes!
Diffstat (limited to 'src/libstd/num')
-rw-r--r--src/libstd/num/f32.rs101
-rw-r--r--src/libstd/num/f64.rs5
-rw-r--r--src/libstd/num/i16.rs5
-rw-r--r--src/libstd/num/i32.rs5
-rw-r--r--src/libstd/num/i64.rs5
-rw-r--r--src/libstd/num/i8.rs5
-rw-r--r--src/libstd/num/isize.rs5
-rw-r--r--src/libstd/num/u16.rs5
-rw-r--r--src/libstd/num/u32.rs5
-rw-r--r--src/libstd/num/u64.rs5
-rw-r--r--src/libstd/num/u8.rs5
-rw-r--r--src/libstd/num/uint_macros.rs1
-rw-r--r--src/libstd/num/usize.rs5
13 files changed, 110 insertions, 47 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs
index 0c40f6c1fc8..9d0b9c3bbb4 100644
--- a/src/libstd/num/f32.rs
+++ b/src/libstd/num/f32.rs
@@ -8,16 +8,17 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for 32-bits floats (`f32` type)
+//! The 32-bit floating point type.
+//!
+//! *[See also the `f32` primitive type](../primitive.f32.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
 #![allow(missing_docs)]
-#![allow(unsigned_negation)]
-#![doc(primitive = "f32")]
 
 use prelude::v1::*;
 
 use core::num;
+#[cfg(not(target_env = "msvc"))]
 use intrinsics;
 use libc::c_int;
 use num::{FpCategory, ParseFloatError};
@@ -33,12 +34,7 @@ mod cmath {
     use libc::{c_float, c_int};
 
     extern {
-        pub fn acosf(n: c_float) -> c_float;
-        pub fn asinf(n: c_float) -> c_float;
-        pub fn atanf(n: c_float) -> c_float;
-        pub fn atan2f(a: c_float, b: c_float) -> c_float;
         pub fn cbrtf(n: c_float) -> c_float;
-        pub fn coshf(n: c_float) -> c_float;
         pub fn erff(n: c_float) -> c_float;
         pub fn erfcf(n: c_float) -> c_float;
         pub fn expm1f(n: c_float) -> c_float;
@@ -51,32 +47,77 @@ mod cmath {
         pub fn log1pf(n: c_float) -> c_float;
         pub fn ilogbf(n: c_float) -> c_int;
         pub fn modff(n: c_float, iptr: &mut c_float) -> c_float;
-        pub fn sinhf(n: c_float) -> c_float;
-        pub fn tanf(n: c_float) -> c_float;
-        pub fn tanhf(n: c_float) -> c_float;
         pub fn tgammaf(n: c_float) -> c_float;
 
         #[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_attr(all(windows, target_env = "msvc"), link_name = "_hypotf")]
         pub fn hypotf(x: c_float, y: c_float) -> c_float;
+    }
 
-        #[cfg(any(unix, all(windows, not(target_env = "msvc"))))]
+    // See the comments in `core::float::Float::floor` for why MSVC is special
+    // here.
+    #[cfg(not(target_env = "msvc"))]
+    extern {
+        pub fn acosf(n: c_float) -> c_float;
+        pub fn asinf(n: c_float) -> c_float;
+        pub fn atan2f(a: c_float, b: c_float) -> c_float;
+        pub fn atanf(n: c_float) -> c_float;
+        pub fn coshf(n: c_float) -> c_float;
         pub fn frexpf(n: c_float, value: &mut c_int) -> c_float;
-        #[cfg(any(unix, all(windows, not(target_env = "msvc"))))]
         pub fn ldexpf(x: c_float, n: c_int) -> c_float;
+        pub fn sinhf(n: c_float) -> c_float;
+        pub fn tanf(n: c_float) -> c_float;
+        pub fn tanhf(n: c_float) -> 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(target_env = "msvc")]
+    pub use self::shims::*;
+    #[cfg(target_env = "msvc")]
+    mod shims {
+        use libc::{c_float, c_int};
+
+        pub unsafe fn acosf(n: c_float) -> c_float {
+            f64::acos(n as f64) as c_float
+        }
+
+        pub unsafe fn asinf(n: c_float) -> c_float {
+            f64::asin(n as f64) as c_float
+        }
+
+        pub unsafe fn atan2f(n: c_float, b: c_float) -> c_float {
+            f64::atan2(n as f64, b as f64) as c_float
+        }
+
+        pub unsafe fn atanf(n: c_float) -> c_float {
+            f64::atan(n as f64) as c_float
+        }
+
+        pub unsafe fn coshf(n: c_float) -> c_float {
+            f64::cosh(n as f64) as c_float
+        }
+
+        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
+        }
+
+        pub unsafe fn ldexpf(x: c_float, n: c_int) -> c_float {
+            f64::ldexp(x as f64, n as isize) as c_float
+        }
+
+        pub unsafe fn sinhf(n: c_float) -> c_float {
+            f64::sinh(n as f64) 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
+        pub unsafe fn tanf(n: c_float) -> c_float {
+            f64::tan(n as f64) as c_float
+        }
+
+        pub unsafe fn tanhf(n: c_float) -> c_float {
+            f64::tanh(n as f64) as c_float
+        }
     }
 }
 
@@ -761,7 +802,13 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn sin(self) -> f32 {
-        unsafe { intrinsics::sinf32(self) }
+        return sinf(self);
+
+        // see notes in `core::f32::Float::floor`
+        #[cfg(target_env = "msvc")]
+        fn sinf(f: f32) -> f32 { (f as f64).sin() as f32 }
+        #[cfg(not(target_env = "msvc"))]
+        fn sinf(f: f32) -> f32 { unsafe { intrinsics::sinf32(f) } }
     }
 
     /// Computes the cosine of a number (in radians).
@@ -778,7 +825,13 @@ impl f32 {
     #[stable(feature = "rust1", since = "1.0.0")]
     #[inline]
     pub fn cos(self) -> f32 {
-        unsafe { intrinsics::cosf32(self) }
+        return cosf(self);
+
+        // see notes in `core::f32::Float::floor`
+        #[cfg(target_env = "msvc")]
+        fn cosf(f: f32) -> f32 { (f as f64).cos() as f32 }
+        #[cfg(not(target_env = "msvc"))]
+        fn cosf(f: f32) -> f32 { unsafe { intrinsics::cosf32(f) } }
     }
 
     /// Computes the tangent of a number (in radians).
diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs
index 41c0fcb9797..4f2f59659ac 100644
--- a/src/libstd/num/f64.rs
+++ b/src/libstd/num/f64.rs
@@ -8,11 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for 64-bits floats (`f64` type)
+//! The 64-bit floating point type.
+//!
+//! *[See also the `f64` primitive type](../primitive.f64.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
 #![allow(missing_docs)]
-#![doc(primitive = "f64")]
 
 use prelude::v1::*;
 
diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs
index 498f19b9b83..eb53e0821f2 100644
--- a/src/libstd/num/i16.rs
+++ b/src/libstd/num/i16.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for signed 16-bits integers (`i16` type)
+//! The 16-bit signed integer type.
+//!
+//! *[See also the `i16` primitive type](../primitive.i16.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "i16")]
 
 pub use core::i16::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs
index aea1e92117b..3c9eedf38c7 100644
--- a/src/libstd/num/i32.rs
+++ b/src/libstd/num/i32.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for signed 32-bits integers (`i32` type)
+//! The 32-bit signed integer type.
+//!
+//! *[See also the `i32` primitive type](../primitive.i32.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "i32")]
 
 pub use core::i32::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs
index 43794345fe7..2df7478a820 100644
--- a/src/libstd/num/i64.rs
+++ b/src/libstd/num/i64.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for signed 64-bits integers (`i64` type)
+//! The 64-bit signed integer type.
+//!
+//! *[See also the `i64` primitive type](../primitive.i64.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "i64")]
 
 pub use core::i64::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs
index 1b03bf6f4f0..4e4bee8a791 100644
--- a/src/libstd/num/i8.rs
+++ b/src/libstd/num/i8.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for signed 8-bits integers (`i8` type)
+//! The 8-bit signed integer type.
+//!
+//! *[See also the `i8` primitive type](../primitive.i8.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "i8")]
 
 pub use core::i8::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/isize.rs b/src/libstd/num/isize.rs
index aa89f858f6f..d46b6b80d0d 100644
--- a/src/libstd/num/isize.rs
+++ b/src/libstd/num/isize.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for pointer-sized signed integers (`isize` type)
+//! The pointer-sized signed integer type.
+//!
+//! *[See also the `isize` primitive type](../primitive.isize.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "isize")]
 
 pub use core::isize::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs
index 3fda77fb69c..893618aeffa 100644
--- a/src/libstd/num/u16.rs
+++ b/src/libstd/num/u16.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for unsigned 16-bits integers (`u16` type)
+//! The 16-bit unsigned integer type.
+//!
+//! *[See also the `u16` primitive type](../primitive.u16.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "u16")]
 
 pub use core::u16::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs
index 8610f0c0147..2da25519696 100644
--- a/src/libstd/num/u32.rs
+++ b/src/libstd/num/u32.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for unsigned 32-bits integers (`u32` type)
+//! The 32-bit unsigned integer type.
+//!
+//! *[See also the `u32` primitive type](../primitive.u32.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "u32")]
 
 pub use core::u32::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs
index 3587b069656..26a8b537394 100644
--- a/src/libstd/num/u64.rs
+++ b/src/libstd/num/u64.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for unsigned 64-bits integer (`u64` type)
+//! The 64-bit unsigned integer type.
+//!
+//! *[See also the `u64` primitive type](../primitive.u64.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "u64")]
 
 pub use core::u64::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs
index 6a285e8299c..385754b93a0 100644
--- a/src/libstd/num/u8.rs
+++ b/src/libstd/num/u8.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for unsigned 8-bits integers (`u8` type)
+//! The 8-bit unsigned integer type.
+//!
+//! *[See also the `u8` primitive type](../primitive.u8.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "u8")]
 
 pub use core::u8::{BITS, BYTES, MIN, MAX};
 
diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs
index 555a5cc3e20..902c78c0a46 100644
--- a/src/libstd/num/uint_macros.rs
+++ b/src/libstd/num/uint_macros.rs
@@ -9,7 +9,6 @@
 // except according to those terms.
 
 #![doc(hidden)]
-#![allow(unsigned_negation)]
 
 macro_rules! uint_module { ($T:ident) => (
 
diff --git a/src/libstd/num/usize.rs b/src/libstd/num/usize.rs
index b54d8ae96c5..6960ba3b829 100644
--- a/src/libstd/num/usize.rs
+++ b/src/libstd/num/usize.rs
@@ -8,10 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-//! Operations and constants for pointer-sized unsigned integers (`usize` type)
+//! The pointer-sized unsigned integer type.
+//!
+//! *[See also the `usize` primitive type](../primitive.usize.html).*
 
 #![stable(feature = "rust1", since = "1.0.0")]
-#![doc(primitive = "usize")]
 
 pub use core::usize::{BITS, BYTES, MIN, MAX};