Skip to content

Commit c31a097

Browse files
committed
aix: create shim for lgammaf_r
1 parent a475551 commit c31a097

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

library/std/src/sys/cmath.rs

+9-1
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,13 +57,20 @@ 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.
6270
cfg_if::cfg_if! {
6371
if #[cfg(all(target_os = "windows", target_env = "msvc", target_arch = "x86"))] {
6472
#[inline]
65-
pub unsafe fn acosf(n: f32) -> f32 {
73+
pub unsafe fn acosf(n: f32) -> f32 {
6674
f64::acos(n as f64) as f32
6775
}
6876

0 commit comments

Comments
 (0)