OSDN Git Service

PR libfortran/15960
[pf3gnuchains/gcc-fork.git] / libgfortran / libgfortran.h
index e73c00a..508a5df 100644 (file)
@@ -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  */