summaryrefslogtreecommitdiff
path: root/libgfortran/libgfortran.h
diff options
context:
space:
mode:
authordanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-23 02:02:38 +0000
committerdanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>2004-11-23 02:02:38 +0000
commitfd48ced8b9a7a458c52f8f35fe1cef0c154c4a45 (patch)
tree61d4ad0cd550c3f974a87cf3001edc98e1bbd22a /libgfortran/libgfortran.h
parentc1677a030eba247ac8509f1151e21bb977b4409b (diff)
downloadgcc-fd48ced8b9a7a458c52f8f35fe1cef0c154c4a45.tar.gz
PR libfortran/15960
* configure.ac: Check for finite in libm. * libgfortran.h: Define isfinite macro if not defined. * intrinsics/c99_functions.c: Use defined(fpclassify) instead of HAVE_FPCLASSIFY. * io/write.c (write_float): Use isfinite instead of finite. * configure, config.h.in: Rebuilt. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@91064 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/libgfortran.h')
-rw-r--r--libgfortran/libgfortran.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index e73c00a480c..508a5df019c 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -82,6 +82,24 @@ typedef off_t gfc_offset;
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *) 0)->MEMBER)
#endif
+/* The isfinite macro is only available with C99, but some non-C99
+ systems still provide fpclassify, and there is a `finite' function
+ in BSD. When isfinite is not available, try to use one of the
+ alternatives, or bail out. */
+#if !defined(isfinite)
+static inline int
+isfinite (double x)
+{
+#if defined(fpclassify)
+ return (fpclassify(x) != FP_NAN && fpclassify(x) != FP_INFINITE);
+#elif defined(HAVE_FINITE)
+ return finite (x);
+#else
+#error "libgfortran needs isfinite, fpclassify, or finite"
+#endif
+}
+#endif /* !defined(isfinite) */
+
/* TODO: find the C99 version of these an move into above ifdef. */
#define REALPART(z) (__real__(z))
#define IMAGPART(z) (__imag__(z))
@@ -441,5 +459,5 @@ typedef GFC_ARRAY_DESCRIPTOR (GFC_MAX_DIMENSIONS, void) array_t;
#define size0 prefix(size0)
index_type size0 (const array_t * array);
-#endif
+#endif /* LIBGFOR_H */