about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2015-08-27 10:06:54 +0200
committerAndrea Canciani <ranma42@gmail.com>2015-08-27 10:12:48 +0200
commit4653a8b3fd69dbab366a8ec67ae9cf68dc128c43 (patch)
tree085465ca309934fb6a7f524d29f505eea43556c2 /src
parent152c76ef0d62b2529b50356773ac6907a6db0f6e (diff)
downloadrust-4653a8b3fd69dbab366a8ec67ae9cf68dc128c43.tar.gz
rust-4653a8b3fd69dbab366a8ec67ae9cf68dc128c43.zip
Restore removed code and mark it for usage in stage0
The old code is temporarily needed in order to keep the MSVC build
working. It should be possible to remove this code after the bootstrap
compiler is updated to contain the MSVC workaround from #27875.
Diffstat (limited to 'src')
-rw-r--r--src/libcore/ops.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs
index ecf80d7e30a..3fb720ab6c8 100644
--- a/src/libcore/ops.rs
+++ b/src/libcore/ops.rs
@@ -441,6 +441,7 @@ macro_rules! rem_impl_integer {
 
 rem_impl_integer! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 }
 
+#[cfg(not(stage0))]
 macro_rules! rem_impl_float {
     ($($t:ty)*) => ($(
         #[stable(feature = "rust1", since = "1.0.0")]
@@ -455,8 +456,48 @@ macro_rules! rem_impl_float {
     )*)
 }
 
+#[cfg(not(stage0))]
 rem_impl_float! { f32 f64 }
 
+#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(stage0)]
+impl Rem for f32 {
+    type Output = f32;
+
+    // The builtin f32 rem operator is broken when targeting
+    // MSVC; see comment in std::f32::floor.
+    // FIXME: See also #27859.
+    #[inline]
+    #[cfg(target_env = "msvc")]
+    fn rem(self, other: f32) -> f32 {
+        (self as f64).rem(other as f64) as f32
+    }
+
+    #[inline]
+    #[cfg(not(target_env = "msvc"))]
+    fn rem(self, other: f32) -> f32 {
+        extern { fn fmodf(a: f32, b: f32) -> f32; }
+        unsafe { fmodf(self, other) }
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+#[cfg(stage0)]
+impl Rem for f64 {
+    type Output = f64;
+
+    #[inline]
+    fn rem(self, other: f64) -> f64 {
+        extern { fn fmod(a: f64, b: f64) -> f64; }
+        unsafe { fmod(self, other) }
+    }
+}
+
+#[cfg(stage0)]
+forward_ref_binop! { impl Rem, rem for f64, f64 }
+#[cfg(stage0)]
+forward_ref_binop! { impl Rem, rem for f32, f32 }
+
 /// The `Neg` trait is used to specify the functionality of unary `-`.
 ///
 /// # Examples