Skip to content

Commit

Permalink
More windows fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
est31 committed Dec 30, 2016
1 parent 9842d27 commit ee6256b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/libcompiler_builtins/lib.rs
Expand Up @@ -378,21 +378,21 @@ pub mod reimpls {
if b != 0 && b != 1 {
*overflow = 1;
}
return result.to_ret();
return result;
}
if b == <$ty>::min_value() {
if a != 0 && a != 1 {
*overflow = 1;
}
return result.to_ret();
return result;
}

let sa = a.signum();
let abs_a = a.iabs();
let sb = b.signum();
let abs_b = b.iabs();
if abs_a < 2 || abs_b < 2 {
return result.to_ret();
return result;
}
unsafe {
if sa == sb {
Expand All @@ -405,13 +405,14 @@ pub mod reimpls {
}
}
}
result.to_ret()
result
}}
}

// FIXME: i32 here should be c_int.
#[export_name="__muloti4"]
pub extern "C" fn i128_mul_oflow(a: i128_, b: i128_, o: &mut i32) -> i128ret {
#[cfg_attr(not(all(windows, target_pointer_width="64", not(stage0))),
export_name="__muloti4")]
pub extern "C" fn i128_mul_oflow(a: i128_, b: i128_, o: &mut i32) -> i128 {
mulo!(a, b, o, i128_)
}

Expand Down Expand Up @@ -696,7 +697,14 @@ pub mod reimpls {
#[cfg(all(windows, target_pointer_width="64"))]
mod windows_64_workarounds {
use super::{i128_, u128_, LargeInt};
use super::{i128_as_f64, i128_as_f32, u128_as_f64, u128_as_f32};
use super::{i128_as_f64, i128_as_f32, u128_as_f64, u128_as_f32, i128_mul_oflow};

#[export_name="__muloti4"]
pub extern "C" fn i128_mul_oflow_win(alow: u64, ahigh: i64,
blow: u64, bhigh: i64, o: &mut i32) -> i128 {
i128_mul_oflow(i128_::from_parts(alow, ahigh), i128_::from_parts(blow, bhigh), o)
}

#[export_name="__floattidf"]
pub extern "C" fn i128_as_f64_win(alow: u64, ahigh: i64) -> f64 {
i128_as_f64(i128_::from_parts(alow, ahigh))
Expand Down

0 comments on commit ee6256b

Please sign in to comment.