Auto merge of #877 - christianpoveda:ldexp-shim, r=RalfJung
Add shim for ldexp Fixes https://github.com/rust-lang/miri/issues/821 r? @RalfJung
This commit is contained in:
commit
d0e8850267
@ -602,6 +602,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
};
|
||||
this.write_scalar(Scalar::from_u64(n.to_bits()), dest)?;
|
||||
}
|
||||
// underscore case for windows
|
||||
"_ldexp" | "ldexp" => {
|
||||
// FIXME: Using host floats.
|
||||
let x = f64::from_bits(this.read_scalar(args[0])?.to_u64()?);
|
||||
let exp = this.read_scalar(args[1])?.to_i32()?;
|
||||
// FIXME: We should use cmath if there are any imprecisions.
|
||||
let n = x * 2.0f64.powi(exp);
|
||||
this.write_scalar(Scalar::from_u64(n.to_bits()), dest)?;
|
||||
}
|
||||
|
||||
// Some things needed for `sys::thread` initialization to go through.
|
||||
"signal" | "sigaction" | "sigaltstack" => {
|
||||
@ -974,4 +983,4 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
}
|
||||
return Ok(None);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,4 +85,8 @@ pub fn main() {
|
||||
assert_approx_eq!(1.0f32.tan(), 1.557408f32);
|
||||
assert_approx_eq!(1.0f64.tan(), 1.557408f64);
|
||||
|
||||
extern {
|
||||
fn ldexp(x: f64, n: i32) -> f64;
|
||||
}
|
||||
unsafe { assert_approx_eq!(ldexp(0.65f64, 3i32), 5.2f64); }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user