@@ -456,7 +456,7 @@ impl f64 {
456456 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
457457 #[ inline]
458458 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) } )
460460 }
461461
462462 /// Returns the logarithm of the number with respect to an arbitrary base.
@@ -500,12 +500,7 @@ impl f64 {
500500 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
501501 #[ inline]
502502 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)
509504 }
510505
511506 /// Returns the base 10 logarithm of the number.
@@ -525,7 +520,7 @@ impl f64 {
525520 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
526521 #[ inline]
527522 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) } )
529524 }
530525
531526 /// The positive difference of two numbers.
@@ -962,28 +957,4 @@ impl f64 {
962957 pub fn atanh ( self ) -> f64 {
963958 0.5 * ( ( 2.0 * self ) / ( 1.0 - self ) ) . ln_1p ( )
964959 }
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- }
989960}
0 commit comments