summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-08-31 15:40:51 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-08-31 17:53:09 -0400
commit1ae5100030ec267efa29f70a313efdf024dd4dd7 (patch)
tree4152793523052b47dadd7dc089afcee07697830e
parent85c93440df5753bca10d1a8ecf801379133d71d5 (diff)
downloadperl-1ae5100030ec267efa29f70a313efdf024dd4dd7.tar.gz
POSIX math: fpclassify continues.
-rw-r--r--ext/POSIX/POSIX.xs22
-rw-r--r--perl.h2
2 files changed, 18 insertions, 6 deletions
diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs
index 201f354ceb..0a7add6ac9 100644
--- a/ext/POSIX/POSIX.xs
+++ b/ext/POSIX/POSIX.xs
@@ -407,7 +407,7 @@ static NV my_copysign(NV x, NV y)
# define c99_copysign my_copysign
#endif
-/* XXX cosh */
+/* XXX cosh (though c89) */
/* XXX erf -- non-trivial */
/* XXX erfc -- non-trivial */
@@ -466,10 +466,20 @@ static NV my_fmin(NV x, NV y)
# define c99_fmin my_fmin
#endif
-#ifndef HAS_FPCLASSIFY
+#if !(defined(HAS_FPCLASSIFY) && defined(FP_INFINITE))
static NV my_fpclassify(NV x)
{
-#if (defined(HAS_FPCLASS) || defined(HAS_FPCLASSL)) && defined(FP_CLASS_SNAN)
+#if defined(HAS_FPCLASSIFY) && defined(FP_PLUS_INF)
+ switch (Perl_fp_class(x)) {
+ case FP_PLUS_INF: case FP_MINUS_INF: return FP_INFINITE;
+ case FP_SNAN: case FP_QNAN: return FP_NAN;
+ case FP_PLUS_NORM: case FP_MINUS_NORM: return FP_NORMAL;
+ case FP_PLUS_DENORM: case FP_MINUS_DENORM: return FP_SUBNORMAL;
+ case FP_PLUS_ZERO: case FP_MINUS_PZERO: return FP_ZERO;
+ default: return -1;
+ }
+# define c99_fpclassify my_fpclassify
+#elif (defined(HAS_FPCLASS) || defined(HAS_FPCLASSL)) && defined(FP_CLASS_SNAN)
switch (Perl_fp_class(x)) {
case FP_CLASS_NINF: case FP_CLASS_PINF: return FP_INFINITE;
case FP_CLASS_SNAN: case FP_CLASS_QNAN: return FP_NAN;
@@ -521,6 +531,8 @@ static NV my_fpclassify(NV x)
if (Perl_fp_class_zero(x)) return FP_ZERO;
return -1;
# define c99_fpclassify my_fpclassify
+#else
+ return -1;
#endif
}
#endif
@@ -653,7 +665,7 @@ static NV my_scalbn(NV x)
# endif
#endif
-/* XXX sinh */
+/* XXX sinh (though c89) */
#ifndef c99_tgamma
# ifdef c99_lgamma
@@ -667,7 +679,7 @@ static NV my_tgamma(NV x)
# endif
#endif
-/* XXX tanh */
+/* XXX tanh (though c89) */
#ifndef c99_trunc
static NV my_trunc(NV x)
diff --git a/perl.h b/perl.h
index 5c296dc34b..5f71489e28 100644
--- a/perl.h
+++ b/perl.h
@@ -2027,7 +2027,7 @@ EXTERN_C long double modfl(long double, long double *);
# define Perl_fp_class_snan(x) (Perl_fp_class(x)==FP_QNAN)
# define Perl_fp_class_qnan(x) (Perl_fp_class(x)==FP_QNAN)
# define Perl_fp_class_pnorm(x) (Perl_fp_class(x)==FP_PLUS_NORM)
-# define Perl_fp_class_nnorm(x) (Perl_fp_class(x)==FP_MINUIS_NORM)
+# define Perl_fp_class_nnorm(x) (Perl_fp_class(x)==FP_MINUS_NORM)
# define Perl_fp_class_pdenorm(x) (Perl_fp_class(x)==FP_PLUS_DENORM)
# define Perl_fp_class_ndenorm(x) (Perl_fp_class(x)==FP_MINUS_DENORM)
# define Perl_fp_class_pzero(x) (Perl_fp_class(x)==FP_PLUS_ZERO)