Skip to content

Commit 9fc6710

Browse files
committed
Auto merge of rust-lang#127719 - devnexen:math_log_fix_solill, r=Amanieu
std: removes logarithms family function edge cases handling for solaris. Issue had been fixed over time with solaris, 11.x behaves correctly (and we support it as minimum), illumos works correctly too.
2 parents d7aa7cf + 009660d commit 9fc6710

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

std/src/f64.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ impl f64 {
520520
#[stable(feature = "rust1", since = "1.0.0")]
521521
#[inline]
522522
pub fn ln(self) -> f64 {
523-
crate::sys::log_wrapper(self, |n| unsafe { intrinsics::logf64(n) })
523+
unsafe { intrinsics::logf64(self) }
524524
}
525525

526526
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -574,7 +574,7 @@ impl f64 {
574574
#[stable(feature = "rust1", since = "1.0.0")]
575575
#[inline]
576576
pub fn log2(self) -> f64 {
577-
crate::sys::log_wrapper(self, crate::sys::log2f64)
577+
crate::sys::log2f64(self)
578578
}
579579

580580
/// Returns the base 10 logarithm of the number.
@@ -599,7 +599,7 @@ impl f64 {
599599
#[stable(feature = "rust1", since = "1.0.0")]
600600
#[inline]
601601
pub fn log10(self) -> f64 {
602-
crate::sys::log_wrapper(self, |n| unsafe { intrinsics::log10f64(n) })
602+
unsafe { intrinsics::log10f64(self) }
603603
}
604604

605605
/// The positive difference of two numbers.

std/src/sys/pal/mod.rs

-31
Original file line numberDiff line numberDiff line change
@@ -94,36 +94,5 @@ cfg_if::cfg_if! {
9494
}
9595
}
9696

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-
12897
#[cfg(not(target_os = "uefi"))]
12998
pub type RawOsError = i32;

0 commit comments

Comments
 (0)