summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-09-06 22:01:01 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-09-07 22:08:33 -0400
commitd67dac15a1bac6947d501164aa494adf160ff668 (patch)
treec1bce5828d6d384eff8ba48d286029cf588cf357 /numeric.c
parent4842dad7c256d1564348893cff3bfed08dadcbe4 (diff)
downloadperl-d67dac15a1bac6947d501164aa494adf160ff668.tar.gz
modfl emulation via truncl (C99) and copysignl.
(We've had emulation for broken modfl before, but it used aintl, which is not that common.)
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index b4ea8b2578..1716efb400 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1347,13 +1347,23 @@ Perl_isinfnan(NV nv)
return FALSE;
}
-#if ! defined(HAS_MODFL) && defined(HAS_AINTL) && defined(HAS_COPYSIGNL)
+#ifndef HAS_MODFL
+/* C99 has truncl, pre-C99 Solaris had aintl */
+# if defined(HAS_TRUNCL) && defined(HAS_COPYSIGNL)
+long double
+Perl_my_modfl(long double x, long double *ip)
+{
+ *ip = truncl(x);
+ return (x == *ip ? copysignl(0.0L, x) : x - *ip);
+}
+# elif defined(HAS_AINTL) && defined(HAS_COPYSIGNL)
long double
Perl_my_modfl(long double x, long double *ip)
{
*ip = aintl(x);
return (x == *ip ? copysignl(0.0L, x) : x - *ip);
}
+# endif
#endif
#if ! defined(HAS_FREXPL) && defined(HAS_ILOGBL) && defined(HAS_SCALBNL)