summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2017-05-29 09:28:30 +0300
committerJarkko Hietaniemi <jhi@iki.fi>2017-05-30 09:43:40 +0300
commite77299d3416e7e737523afdc0642734205e46d59 (patch)
treee28e4d55ea3240890381cf78ba837a5007ce7af6
parent390ae6f9aa25246d462b235923fe012cf40d157a (diff)
downloadperl-e77299d3416e7e737523afdc0642734205e46d59.tar.gz
Fallbacks for Perl_fp_class_denorm().
These may be needed if the compiler doesn't expose the C99 math without some special switches.
-rw-r--r--perl.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/perl.h b/perl.h
index 70e12bd722..8c4d776791 100644
--- a/perl.h
+++ b/perl.h
@@ -6867,6 +6867,26 @@ extern void moncontrol(int);
# endif
#endif
+/* We have somehow managed not to define the denormal/subnormal
+ * detection.
+ *
+ * This may happen if the compiler doesn't expose the C99 math like
+ * the fpclassify() without some special switches. Perl tries to
+ * stay C89, so for example -std=c99 is not an option.
+ *
+ * The Perl_isinf() and Perl_isnan() should have been defined even if
+ * the C99 isinf() and isnan() are unavailable, and the NV_MIN becomes
+ * from the C89 DBL_MIN or moral equivalent. */
+#if !defined(Perl_fp_class_denorm) && defined(Perl_isinf) && defined(Perl_isnan) && defined(NV_MIN)
+# define Perl_fp_class_denorm(x) ((x) != 0.0 && !Perl_isinf(x) && !Perl_isnan(x) && PERL_ABS(x) < NV_MIN)
+#endif
+
+/* This is not a great fallback: subnormals tests will fail,
+ * but at least Perl will link and 99.999% of tests will work. */
+#if !defined(Perl_fp_class_denorm)
+# define Perl_fp_class_denorm(x) FALSE
+#endif
+
#ifdef DOUBLE_IS_IEEE_FORMAT
# define DOUBLE_HAS_INF
# define DOUBLE_HAS_NAN