lgamma(NaN) should produce NaN, but on older versions of AIX
it reports an ERANGE error. While that's been fixed in the latest
version of libm, it'll take awhile for the fix to propagate. This
workaround is harmless even when the underlying bug does get fixed.
Discussion: https://postgr.es/m/
3603369.
1771877682@sss.pgh.pa.us
float8 arg1 = PG_GETARG_FLOAT8(0);
float8 result;
+ /* On some versions of AIX, lgamma(NaN) fails with ERANGE */
+#if defined(_AIX)
+ if (isnan(arg1))
+ PG_RETURN_FLOAT8(arg1);
+#endif
+
/*
* Note: lgamma may not be thread-safe because it may write to a global
* variable signgam, which may not be thread-local. However, this doesn't