Skip to content

Commit 82d4eae

Browse files
Rollup merge of #133543 - mustartt:aix-lgammaf_r-shim, r=cuviper
[AIX] create shim for lgammaf_r On AIX, we don't have 32bit floating point for re-entrant `lgammaf_r` but we do have the 64bit floating point re-entrant `lgamma_r` so we can use the 64bit version instead and truncate back to a 32bit float. This solves the linker missing symbol for `.lgammaf_r` when testing and using these parts of the `std`.
2 parents 0cad2dc + 527b606 commit 82d4eae

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

library/std/src/sys/cmath.rs

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extern "C" {
2626
pub fn tgamma(n: f64) -> f64;
2727
pub fn tgammaf(n: f32) -> f32;
2828
pub fn lgamma_r(n: f64, s: &mut i32) -> f64;
29+
#[cfg(not(target_os = "aix"))]
2930
pub fn lgammaf_r(n: f32, s: &mut i32) -> f32;
3031

3132
pub fn acosf128(n: f128) -> f128;
@@ -56,6 +57,13 @@ extern "C" {
5657
}}
5758
}
5859

60+
// On AIX, we don't have lgammaf_r only the f64 version, so we can
61+
// use the f64 version lgamma_r
62+
#[cfg(target_os = "aix")]
63+
pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 {
64+
lgamma_r(n.into(), s) as f32
65+
}
66+
5967
// On 32-bit x86 MSVC these functions aren't defined, so we just define shims
6068
// which promote everything to f64, perform the calculation, and then demote
6169
// back to f32. While not precisely correct should be "correct enough" for now.

0 commit comments

Comments
 (0)