@@ -44,23 +44,7 @@ impl f32 {
44
44
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
45
45
#[ inline]
46
46
pub fn floor ( self ) -> f32 {
47
- // On MSVC LLVM will lower many math intrinsics to a call to the
48
- // corresponding function. On MSVC, however, many of these functions
49
- // aren't actually available as symbols to call, but rather they are all
50
- // `static inline` functions in header files. This means that from a C
51
- // perspective it's "compatible", but not so much from an ABI
52
- // perspective (which we're worried about).
53
- //
54
- // The inline header functions always just cast to a f64 and do their
55
- // operation, so we do that here as well, but only for MSVC targets.
56
- //
57
- // Note that there are many MSVC-specific float operations which
58
- // redirect to this comment, so `floorf` is just one case of a missing
59
- // function on MSVC, but there are many others elsewhere.
60
- #[ cfg( target_env = "msvc" ) ]
61
- return ( self as f64 ) . floor ( ) as f32 ;
62
- #[ cfg( not( target_env = "msvc" ) ) ]
63
- return unsafe { intrinsics:: floorf32 ( self ) } ;
47
+ unsafe { intrinsics:: floorf32 ( self ) }
64
48
}
65
49
66
50
/// Returns the smallest integer greater than or equal to a number.
@@ -78,11 +62,7 @@ impl f32 {
78
62
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
79
63
#[ inline]
80
64
pub fn ceil ( self ) -> f32 {
81
- // see notes above in `floor`
82
- #[ cfg( target_env = "msvc" ) ]
83
- return ( self as f64 ) . ceil ( ) as f32 ;
84
- #[ cfg( not( target_env = "msvc" ) ) ]
85
- return unsafe { intrinsics:: ceilf32 ( self ) } ;
65
+ unsafe { intrinsics:: ceilf32 ( self ) }
86
66
}
87
67
88
68
/// Returns the nearest integer to a number. Round half-way cases away from
@@ -348,11 +328,7 @@ impl f32 {
348
328
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
349
329
#[ inline]
350
330
pub fn powf ( self , n : f32 ) -> f32 {
351
- // see notes above in `floor`
352
- #[ cfg( target_env = "msvc" ) ]
353
- return ( self as f64 ) . powf ( n as f64 ) as f32 ;
354
- #[ cfg( not( target_env = "msvc" ) ) ]
355
- return unsafe { intrinsics:: powf32 ( self , n) } ;
331
+ unsafe { intrinsics:: powf32 ( self , n) }
356
332
}
357
333
358
334
/// Returns the square root of a number.
@@ -399,11 +375,7 @@ impl f32 {
399
375
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
400
376
#[ inline]
401
377
pub fn exp ( self ) -> f32 {
402
- // see notes above in `floor`
403
- #[ cfg( target_env = "msvc" ) ]
404
- return ( self as f64 ) . exp ( ) as f32 ;
405
- #[ cfg( not( target_env = "msvc" ) ) ]
406
- return unsafe { intrinsics:: expf32 ( self ) } ;
378
+ unsafe { intrinsics:: expf32 ( self ) }
407
379
}
408
380
409
381
/// Returns `2^(self)`.
@@ -447,11 +419,7 @@ impl f32 {
447
419
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
448
420
#[ inline]
449
421
pub fn ln ( self ) -> f32 {
450
- // see notes above in `floor`
451
- #[ cfg( target_env = "msvc" ) ]
452
- return ( self as f64 ) . ln ( ) as f32 ;
453
- #[ cfg( not( target_env = "msvc" ) ) ]
454
- return unsafe { intrinsics:: logf32 ( self ) } ;
422
+ unsafe { intrinsics:: logf32 ( self ) }
455
423
}
456
424
457
425
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -521,11 +489,7 @@ impl f32 {
521
489
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
522
490
#[ inline]
523
491
pub fn log10 ( self ) -> f32 {
524
- // see notes above in `floor`
525
- #[ cfg( target_env = "msvc" ) ]
526
- return ( self as f64 ) . log10 ( ) as f32 ;
527
- #[ cfg( not( target_env = "msvc" ) ) ]
528
- return unsafe { intrinsics:: log10f32 ( self ) } ;
492
+ unsafe { intrinsics:: log10f32 ( self ) }
529
493
}
530
494
531
495
/// The positive difference of two numbers.
@@ -625,11 +589,7 @@ impl f32 {
625
589
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
626
590
#[ inline]
627
591
pub fn sin ( self ) -> f32 {
628
- // see notes in `core::f32::Float::floor`
629
- #[ cfg( target_env = "msvc" ) ]
630
- return ( self as f64 ) . sin ( ) as f32 ;
631
- #[ cfg( not( target_env = "msvc" ) ) ]
632
- return unsafe { intrinsics:: sinf32 ( self ) } ;
592
+ unsafe { intrinsics:: sinf32 ( self ) }
633
593
}
634
594
635
595
/// Computes the cosine of a number (in radians).
@@ -649,11 +609,7 @@ impl f32 {
649
609
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
650
610
#[ inline]
651
611
pub fn cos ( self ) -> f32 {
652
- // see notes in `core::f32::Float::floor`
653
- #[ cfg( target_env = "msvc" ) ]
654
- return ( self as f64 ) . cos ( ) as f32 ;
655
- #[ cfg( not( target_env = "msvc" ) ) ]
656
- return unsafe { intrinsics:: cosf32 ( self ) } ;
612
+ unsafe { intrinsics:: cosf32 ( self ) }
657
613
}
658
614
659
615
/// Computes the tangent of a number (in radians).
0 commit comments