Auto merge of #127719 - devnexen:math_log_fix_solill, r=Amanieu · model-checking/verify-rust-std@9fc6710 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -520,7 +520,7 @@ impl f64 {
520 520 #[stable(feature = "rust1", since = "1.0.0")]
521 521 #[inline]
522 522 pub fn ln(self) -> f64 {
523 -crate::sys::log_wrapper(self, |n
523 +unsafe { intrinsics::logf64(self) }
524 524 }
525 525
526 526 /// Returns the logarithm of the number with respect to an arbitrary base.
@@ -574,7 +574,7 @@ impl f64 {
574 574 #[stable(feature = "rust1", since = "1.0.0")]
575 575 #[inline]
576 576 pub fn log2(self) -> f64 {
577 -crate::sys::log_wrapper(self, crate::sys::log2f64)
577 +crate::sys::log2f64(self)
578 578 }
579 579
580 580 /// Returns the base 10 logarithm of the number.
@@ -599,7 +599,7 @@ impl f64 {
599 599 #[stable(feature = "rust1", since = "1.0.0")]
600 600 #[inline]
601 601 pub fn log10(self) -> f64 {
602 -crate::sys::log_wrapper(self, |n
602 +unsafe { intrinsics::log10f64(self) }
603 603 }
604 604
605 605 /// The positive difference of two numbers.
Original file line number Diff line number Diff line change
@@ -94,36 +94,5 @@ cfg_if::cfg_if! {
94 94 }
95 95 }
96 96
97 -// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
98 -// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
99 -// of expected NaN).
100 -#[cfg(not(test))]
101 -#[cfg(any(target_os = "solaris", target_os = "illumos"))]
102 -#[inline]
103 -pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
104 -if n.is_finite() {
105 -if n > 0.0 {
106 -log_fn(n)
107 -} else if n == 0.0 {
108 - f64::NEG_INFINITY // log(0) = -Inf
109 -} else {
110 - f64::NAN // log(-n) = NaN
111 -}
112 -} else if n.is_nan() {
113 - n // log(NaN) = NaN
114 -} else if n > 0.0 {
115 - n // log(Inf) = Inf
116 -} else {
117 - f64::NAN // log(-Inf) = NaN
118 -}
119 -}
120 -
121 -#[cfg(not(test))]
122 -#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
123 -#[inline]
124 -pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
125 -log_fn(n)
126 -}
127 -
128 97 #[cfg(not(target_os = "uefi"))]
129 98 pub type RawOsError = i32;