diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2024-11-28 03:14:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-28 03:14:51 +0100 |
| commit | 82d4eaeafff45bad6c3d8b4210d37d1364b4b429 (patch) | |
| tree | a3b7e7d1432a564a92eaf60c2334d2db127a85ee /library/std/src/sys | |
| parent | 0cad2dcba6f65dce3b235cb761be690cdae37869 (diff) | |
| parent | 527b6065ba684f0f2702bb7f1066f76bf691a69c (diff) | |
| download | rust-82d4eaeafff45bad6c3d8b4210d37d1364b4b429.tar.gz rust-82d4eaeafff45bad6c3d8b4210d37d1364b4b429.zip | |
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`.
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/cmath.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/sys/cmath.rs b/library/std/src/sys/cmath.rs index 2997e908fa1..ee36127cfdf 100644 --- a/library/std/src/sys/cmath.rs +++ b/library/std/src/sys/cmath.rs @@ -26,6 +26,7 @@ extern "C" { pub fn tgamma(n: f64) -> f64; pub fn tgammaf(n: f32) -> f32; pub fn lgamma_r(n: f64, s: &mut i32) -> f64; + #[cfg(not(target_os = "aix"))] pub fn lgammaf_r(n: f32, s: &mut i32) -> f32; pub fn acosf128(n: f128) -> f128; @@ -56,6 +57,13 @@ extern "C" { }} } +// On AIX, we don't have lgammaf_r only the f64 version, so we can +// use the f64 version lgamma_r +#[cfg(target_os = "aix")] +pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 { + lgamma_r(n.into(), s) as f32 +} + // On 32-bit x86 MSVC these functions aren't defined, so we just define shims // which promote everything to f64, perform the calculation, and then demote // back to f32. While not precisely correct should be "correct enough" for now. |
