OSDN Git Service

* configure.ac: Check for ieeefp.h. Check for fabsf in libm.
[pf3gnuchains/gcc-fork.git] / libgfortran / libgfortran.h
index e73c00a..3732707 100644 (file)
@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 #include "config.h"
+#include "c99_protos.h"
 
 #if HAVE_COMPLEX_H
 # include <complex.h>
@@ -39,6 +40,10 @@ Boston, MA 02111-1307, USA.  */
 #define complex __complex__
 #endif
 
+#if HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
 #if HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -82,6 +87,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 +464,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  */