From c31a097d7533a1df9435119e40f649b88a0d387e Mon Sep 17 00:00:00 2001
From: Henry Jiang <henry.jiang1@ibm.com>
Date: Fri, 22 Nov 2024 17:47:15 -0500
Subject: [PATCH 1/2] aix: create shim for lgammaf_r

---
 library/std/src/sys/cmath.rs | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/library/std/src/sys/cmath.rs b/library/std/src/sys/cmath.rs
index 2997e908fa1b2..829042381a24c 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,13 +57,20 @@ 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.
 cfg_if::cfg_if! {
 if #[cfg(all(target_os = "windows", target_env = "msvc", target_arch = "x86"))] {
     #[inline]
-    pub unsafe fn acosf(n: f32) -> f32 {
+   pub unsafe fn acosf(n: f32) -> f32 {
         f64::acos(n as f64) as f32
     }
 

From 527b6065ba684f0f2702bb7f1066f76bf691a69c Mon Sep 17 00:00:00 2001
From: Henry Jiang <h243jian@uwaterloo.ca>
Date: Wed, 27 Nov 2024 12:02:02 -0500
Subject: [PATCH 2/2] fmt

---
 library/std/src/sys/cmath.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/library/std/src/sys/cmath.rs b/library/std/src/sys/cmath.rs
index 829042381a24c..ee36127cfdf1e 100644
--- a/library/std/src/sys/cmath.rs
+++ b/library/std/src/sys/cmath.rs
@@ -70,7 +70,7 @@ pub unsafe fn lgammaf_r(n: f32, s: &mut i32) -> f32 {
 cfg_if::cfg_if! {
 if #[cfg(all(target_os = "windows", target_env = "msvc", target_arch = "x86"))] {
     #[inline]
-   pub unsafe fn acosf(n: f32) -> f32 {
+    pub unsafe fn acosf(n: f32) -> f32 {
         f64::acos(n as f64) as f32
     }