@@ -456,7 +456,7 @@ impl f64 {
456
456
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
457
457
#[ inline]
458
458
pub fn ln ( self ) -> f64 {
459
- self . log_wrapper ( |n| unsafe { intrinsics:: logf64 ( n) } )
459
+ crate :: sys :: log_wrapper ( self , |n| unsafe { intrinsics:: logf64 ( n) } )
460
460
}
461
461
462
462
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -500,12 +500,7 @@ impl f64 {
500
500
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
501
501
#[ inline]
502
502
pub fn log2 ( self ) -> f64 {
503
- self . log_wrapper ( |n| {
504
- #[ cfg( target_os = "android" ) ]
505
- return crate :: sys:: android:: log2f64 ( n) ;
506
- #[ cfg( not( target_os = "android" ) ) ]
507
- return unsafe { intrinsics:: log2f64 ( n) } ;
508
- } )
503
+ crate :: sys:: log_wrapper ( self , crate :: sys:: log2f64)
509
504
}
510
505
511
506
/// Returns the base 10 logarithm of the number.
@@ -525,7 +520,7 @@ impl f64 {
525
520
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
526
521
#[ inline]
527
522
pub fn log10 ( self ) -> f64 {
528
- self . log_wrapper ( |n| unsafe { intrinsics:: log10f64 ( n) } )
523
+ crate :: sys :: log_wrapper ( self , |n| unsafe { intrinsics:: log10f64 ( n) } )
529
524
}
530
525
531
526
/// The positive difference of two numbers.
@@ -962,28 +957,4 @@ impl f64 {
962
957
pub fn atanh ( self ) -> f64 {
963
958
0.5 * ( ( 2.0 * self ) / ( 1.0 - self ) ) . ln_1p ( )
964
959
}
965
-
966
- // Solaris/Illumos requires a wrapper around log, log2, and log10 functions
967
- // because of their non-standard behavior (e.g., log(-n) returns -Inf instead
968
- // of expected NaN).
969
- #[ rustc_allow_incoherent_impl]
970
- fn log_wrapper < F : Fn ( f64 ) -> f64 > ( self , log_fn : F ) -> f64 {
971
- if !cfg ! ( any( target_os = "solaris" , target_os = "illumos" ) ) {
972
- log_fn ( self )
973
- } else if self . is_finite ( ) {
974
- if self > 0.0 {
975
- log_fn ( self )
976
- } else if self == 0.0 {
977
- Self :: NEG_INFINITY // log(0) = -Inf
978
- } else {
979
- Self :: NAN // log(-n) = NaN
980
- }
981
- } else if self . is_nan ( ) {
982
- self // log(NaN) = NaN
983
- } else if self > 0.0 {
984
- self // log(Inf) = Inf
985
- } else {
986
- Self :: NAN // log(-Inf) = NaN
987
- }
988
- }
989
960
}
0 commit comments