/* 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>
#endif
#include "config.h"
+#include "c99_protos.h"
#if HAVE_COMPLEX_H
# include <complex.h>
#define complex __complex__
#endif
+#if HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
+
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#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
#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))
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)
#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 */
#define size0 prefix(size0)
index_type size0 (const array_t * array);
-#endif
+#endif /* LIBGFOR_H */