diff --git a/src/shims/foreign_items.rs b/src/shims/foreign_items.rs index 48d98141b8a..5edabf21566 100644 --- a/src/shims/foreign_items.rs +++ b/src/shims/foreign_items.rs @@ -496,7 +496,7 @@ fn emulate_foreign_item( } // math functions - "cbrtf" | "coshf" | "sinhf" | "tanf" => { + "cbrtf" | "coshf" | "sinhf" | "tanf" | "acosf" | "asinf" | "atanf" => { // FIXME: Using host floats. let f = f32::from_bits(this.read_scalar(args[0])?.to_u32()?); let f = match link_name { @@ -504,6 +504,9 @@ fn emulate_foreign_item( "coshf" => f.cosh(), "sinhf" => f.sinh(), "tanf" => f.tan(), + "acosf" => f.acos(), + "asinf" => f.asin(), + "atanf" => f.atan(), _ => bug!(), }; this.write_scalar(Scalar::from_u32(f.to_bits()), dest)?; @@ -521,7 +524,7 @@ fn emulate_foreign_item( this.write_scalar(Scalar::from_u32(n.to_bits()), dest)?; } - "cbrt" | "cosh" | "sinh" | "tan" => { + "cbrt" | "cosh" | "sinh" | "tan" | "acos" | "asin" | "atan" => { // FIXME: Using host floats. let f = f64::from_bits(this.read_scalar(args[0])?.to_u64()?); let f = match link_name { @@ -529,6 +532,9 @@ fn emulate_foreign_item( "cosh" => f.cosh(), "sinh" => f.sinh(), "tan" => f.tan(), + "acos" => f.acos(), + "asin" => f.asin(), + "atan" => f.atan(), _ => bug!(), }; this.write_scalar(Scalar::from_u64(f.to_bits()), dest)?; diff --git a/tests/run-pass/intrinsics-math.rs b/tests/run-pass/intrinsics-math.rs index f435611b2b6..98cb87ee934 100644 --- a/tests/run-pass/intrinsics-math.rs +++ b/tests/run-pass/intrinsics-math.rs @@ -92,6 +92,15 @@ pub fn main() { assert_approx_eq!(1.0f32.tan(), 1.557408f32); assert_approx_eq!(1.0f64.tan(), 1.557408f64); + assert_approx_eq!(f32::consts::FRAC_PI_4.cos().acos(), f32::consts::FRAC_PI_4); + assert_approx_eq!(f64::consts::FRAC_PI_4.cos().acos(), f64::consts::FRAC_PI_4); + + assert_approx_eq!(f32::consts::FRAC_PI_4.sin().asin(), f32::consts::FRAC_PI_4); + assert_approx_eq!(f64::consts::FRAC_PI_4.sin().asin(), f64::consts::FRAC_PI_4); + + assert_approx_eq!(1.0_f32, 1.0_f32.tan().atan()); + assert_approx_eq!(1.0_f64, 1.0_f64.tan().atan()); + assert_eq!(3.3_f32.round(), 3.0); assert_eq!(3.3_f64.round(), 3.0);