OSDN Git Service

* configure.ac: Check for ieeefp.h. Check for fabsf in libm.
[pf3gnuchains/gcc-fork.git] / libgfortran / libgfortran.h
index 2819703..3732707 100644 (file)
@@ -1,5 +1,5 @@
 /* Common declarations for all of libgfor.
-   Copyright 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Paul Brook <paul@nowt.org>, and
    Andy Vaught <andy@xena.eas.asu.edu>
 
@@ -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
@@ -47,6 +52,17 @@ Boston, MA 02111-1307, USA.  */
 #include <inttypes.h>
 #endif
 
+#if !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H) && defined(TARGET_ILP32)
+typedef char int8_t;
+typedef short int16_t;
+typedef int int32_t;
+typedef long long int64_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long uint64_t;
+#endif
+
 #if HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -71,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))
@@ -91,8 +125,8 @@ typedef complex double GFC_COMPLEX_8;
    by the compiler.  */
 /* The type used of array indices, amongst other things.  */
 typedef size_t index_type;
-/* The type used for string lengths.  Nothing to do with strlen(3).  */
-typedef GFC_INTEGER_4 gfc_strlen_type;
+/* The type used for the lengths of character variables.  */
+typedef GFC_INTEGER_4 gfc_charlen_type;
 
 /* This will be 0 on little-endian machines and one on big-endian machines.  */
 #define l8_to_l4_offset prefix(l8_to_l4_offset)
@@ -237,6 +271,11 @@ extern unsigned line;              /* Location of the current libray call (optional).  */
 #define filename prefix(filename)
 extern char *filename;
 
+/* Avoid conflicting prototypes of alloca() in system headers by using 
+   GCC's builtin alloca().  */
+
+#define gfc_alloca(x)  __builtin_alloca(x)
+
 
 /* main.c */
 
@@ -425,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  */