summaryrefslogtreecommitdiff
path: root/floatmagic.h
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:52:31 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:52:31 +0300
commit3ba50a15ebd976f7a88393e2e45dc14b6478b9a9 (patch)
tree6a6bbe6bed1141051fefe94b2d39eacd4854235a /floatmagic.h
parent6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f (diff)
downloadgawk-3ba50a15ebd976f7a88393e2e45dc14b6478b9a9.tar.gz
Move to gawk-3.1.7.gawk-3.1.7
Diffstat (limited to 'floatmagic.h')
-rw-r--r--floatmagic.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/floatmagic.h b/floatmagic.h
new file mode 100644
index 00000000..c6aabd92
--- /dev/null
+++ b/floatmagic.h
@@ -0,0 +1,54 @@
+/*
+ * floatmagic.h -- Definitions of isnan and isinf for gawk.
+ */
+
+/*
+ * Copyright (C) 2009 the Free Software Foundation, Inc.
+ *
+ * This file is part of GAWK, the GNU implementation of the
+ * AWK Programming Language.
+ *
+ * GAWK is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GAWK is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+/*
+ * NOTE: <math.h> MUST be included before this file. Also <config.h>.
+ *
+ * These definitions are taken from the Autoconf 2.63 manual. Not pretty.
+ */
+
+#ifndef HAVE_ISNAN
+#ifndef isnan
+# define isnan(x) \
+ (sizeof (x) == sizeof (long double) ? isnan_ld (x) \
+ : sizeof (x) == sizeof (double) ? isnan_d (x) \
+ : isnan_f (x))
+static inline int isnan_f (float x) { return x != x; }
+static inline int isnan_d (double x) { return x != x; }
+static inline int isnan_ld (long double x) { return x != x; }
+#endif
+#endif
+
+#ifndef HAVE_ISINF
+#ifndef isinf
+# define isinf(x) \
+ (sizeof (x) == sizeof (long double) ? isinf_ld (x) \
+ : sizeof (x) == sizeof (double) ? isinf_d (x) \
+ : isinf_f (x))
+static inline int isinf_f (float x) { return isnan (x - x); }
+static inline int isinf_d (double x) { return isnan (x - x); }
+static inline int isinf_ld (long double x) { return isnan (x - x); }
+#endif
+#endif