summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numeric.c12
-rw-r--r--perl.h4
2 files changed, 12 insertions, 4 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)
diff --git a/perl.h b/perl.h
index f3ae3eb6aa..f94c6175cf 100644
--- a/perl.h
+++ b/perl.h
@@ -1912,11 +1912,9 @@ typedef NVTYPE NV;
# ifndef HAS_MODFL_PROTO
EXTERN_C long double modfl(long double, long double *);
# endif
-# else
-# if defined(HAS_AINTL) && defined(HAS_COPYSIGNL)
+# elif (defined(HAS_TRUNCL) || defined(HAS_AINTL)) && defined(HAS_COPYSIGNL)
extern long double Perl_my_modfl(long double x, long double *ip);
# define Perl_modf(x,y) Perl_my_modfl(x,y)
-# endif
# endif
# ifdef HAS_FREXPL
# define Perl_frexp(x,y) frexpl(x,y)