@@ -560,18 +560,56 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
560
560
let n = this. memory ( ) . get ( ptr. alloc_id ) ?. read_c_str ( tcx, ptr) ?. len ( ) ;
561
561
this. write_scalar ( Scalar :: from_uint ( n as u64 , dest. layout . size ) , dest) ?;
562
562
}
563
- "cbrt" => {
563
+
564
+ // math functions
565
+
566
+ "cbrtf" | "coshf" | "sinhf" |"tanf" => {
567
+ // FIXME: Using host floats.
568
+ let f = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
569
+ let f = match link_name {
570
+ "cbrtf" => f. cbrt ( ) ,
571
+ "coshf" => f. cosh ( ) ,
572
+ "sinhf" => f. sinh ( ) ,
573
+ "tanf" => f. tan ( ) ,
574
+ _ => bug ! ( ) ,
575
+ } ;
576
+ this. write_scalar ( Scalar :: from_u32 ( f. to_bits ( ) ) , dest) ?;
577
+ }
578
+ // underscore case for windows
579
+ "_hypotf" | "hypotf" | "atan2f" => {
580
+ // FIXME: Using host floats.
581
+ let f1 = f32:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u32 ( ) ?) ;
582
+ let f2 = f32:: from_bits ( this. read_scalar ( args[ 1 ] ) ?. to_u32 ( ) ?) ;
583
+ let n = match link_name {
584
+ "_hypotf" | "hypotf" => f1. hypot ( f2) ,
585
+ "atan2f" => f1. atan2 ( f2) ,
586
+ _ => bug ! ( ) ,
587
+ } ;
588
+ this. write_scalar ( Scalar :: from_u32 ( n. to_bits ( ) ) , dest) ?;
589
+ }
590
+
591
+ "cbrt" | "cosh" | "sinh" | "tan" => {
564
592
// FIXME: Using host floats.
565
593
let f = f64:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u64 ( ) ?) ;
566
- let n = f. cbrt ( ) ;
567
- this. write_scalar ( Scalar :: from_u64 ( n. to_bits ( ) ) , dest) ?;
594
+ let f = match link_name {
595
+ "cbrt" => f. cbrt ( ) ,
596
+ "cosh" => f. cosh ( ) ,
597
+ "sinh" => f. sinh ( ) ,
598
+ "tan" => f. tan ( ) ,
599
+ _ => bug ! ( ) ,
600
+ } ;
601
+ this. write_scalar ( Scalar :: from_u64 ( f. to_bits ( ) ) , dest) ?;
568
602
}
569
603
// underscore case for windows
570
- "_hypot" | "hypot" => {
604
+ "_hypot" | "hypot" | "atan2" => {
571
605
// FIXME: Using host floats.
572
606
let f1 = f64:: from_bits ( this. read_scalar ( args[ 0 ] ) ?. to_u64 ( ) ?) ;
573
607
let f2 = f64:: from_bits ( this. read_scalar ( args[ 1 ] ) ?. to_u64 ( ) ?) ;
574
- let n = f1. hypot ( f2) ;
608
+ let n = match link_name {
609
+ "_hypot" | "hypot" => f1. hypot ( f2) ,
610
+ "atan2" => f1. atan2 ( f2) ,
611
+ _ => bug ! ( ) ,
612
+ } ;
575
613
this. write_scalar ( Scalar :: from_u64 ( n. to_bits ( ) ) , dest) ?;
576
614
}
577
615
0 commit comments