/* The compiler is not a multi-threaded application and therefore we
do not have to use the locking functions.
- NEED_DECLARATION_PUTC_UNLOCKED actually indicates whether or not
- the IO code is multi-thread safe by default. If it is not declared,
- then do not worry about using the _unlocked functions.
+ HAVE_DECL_PUTC_UNLOCKED actually indicates whether or not the IO
+ code is multi-thread safe by default. If it is set to 0, then do
+ not worry about using the _unlocked functions.
fputs_unlocked is an extension and needs to be prototyped specially. */
-#if defined HAVE_PUTC_UNLOCKED && !defined NEED_DECLARATION_PUTC_UNLOCKED
+#if defined HAVE_PUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
# undef putc
# define putc(C, Stream) putc_unlocked (C, Stream)
#endif
-#if defined HAVE_FPUTC_UNLOCKED && !defined NEED_DECLARATION_PUTC_UNLOCKED
+#if defined HAVE_FPUTC_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
# undef fputc
# define fputc(C, Stream) fputc_unlocked (C, Stream)
#endif
-#if defined HAVE_FPUTS_UNLOCKED && !defined NEED_DECLARATION_PUTC_UNLOCKED
+#if defined HAVE_FPUTS_UNLOCKED && (defined (HAVE_DECL_PUTC_UNLOCKED) && HAVE_DECL_PUTC_UNLOCKED)
# undef fputs
# define fputs(String, Stream) fputs_unlocked (String, Stream)
-# ifdef NEED_DECLARATION_FPUTS_UNLOCKED
+# if defined (HAVE_DECL_FPUTS_UNLOCKED) && !HAVE_DECL_FPUTS_UNLOCKED
extern int fputs_unlocked PARAMS ((const char *, FILE *));
# endif
#endif
# endif /* defined(HOST_BITS_PER_LONG) && defined(HOST_BITS_PER_LONGLONG) */
#endif /* ! HOST_WIDEST_INT */
+/* Infrastructure for defining missing _MAX and _MIN macros. Note that
+ macros defined with these cannot be used in #if. */
+
+/* The extra casts work around common compiler bugs. */
+#define INTTYPE_SIGNED(t) (! ((t) 0 < (t) -1))
+/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
+ It is necessary at least when t == time_t. */
+#define INTTYPE_MINIMUM(t) ((t) (INTTYPE_SIGNED (t) \
+ ? ~ (t) 0 << (sizeof(t) * CHAR_BIT - 1) : (t) 0))
+#define INTTYPE_MAXIMUM(t) ((t) (~ (t) 0 - INTTYPE_MINIMUM (t)))
+
+/* Use that infrastructure to provide a few constants. */
+#ifndef UCHAR_MAX
+# define UCHAR_MAX INTTYPE_MAXIMUM (unsigned char)
+#endif
+
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#define WSTOPSIG WEXITSTATUS
#endif
-
+/* The HAVE_DECL_* macros are three-state, undefined, 0 or 1. If they
+ are defined to 0 then we must provide the relevant declaration
+ here. These checks will be in the undefined state while configure
+ is running so be careful to test "defined (HAVE_DECL_*)". */
#ifndef bcopy
# ifdef HAVE_BCOPY
-# ifdef NEED_DECLARATION_BCOPY
+# if defined (HAVE_DECL_BCOPY) && !HAVE_DECL_BCOPY
extern void bcopy PARAMS ((const PTR, PTR, size_t));
# endif
# else /* ! HAVE_BCOPY */
#ifndef bcmp
# ifdef HAVE_BCMP
-# ifdef NEED_DECLARATION_BCMP
+# if defined (HAVE_DECL_BCMP) && !HAVE_DECL_BCMP
extern int bcmp PARAMS ((const PTR, const PTR, size_t));
# endif
# else /* ! HAVE_BCMP */
#ifndef bzero
# ifdef HAVE_BZERO
-# ifdef NEED_DECLARATION_BZERO
+# if defined (HAVE_DECL_BZERO) && !HAVE_DECL_BZERO
extern void bzero PARAMS ((PTR, size_t));
# endif
# else /* ! HAVE_BZERO */
#ifndef index
# ifdef HAVE_INDEX
-# ifdef NEED_DECLARATION_INDEX
+# if defined (HAVE_DECL_INDEX) && !HAVE_DECL_INDEX
extern char *index PARAMS ((const char *, int));
# endif
# else /* ! HAVE_INDEX */
#ifndef rindex
# ifdef HAVE_RINDEX
-# ifdef NEED_DECLARATION_RINDEX
+# if defined (HAVE_DECL_RINDEX) && !HAVE_DECL_RINDEX
extern char *rindex PARAMS ((const char *, int));
# endif
# else /* ! HAVE_RINDEX */
# endif
#endif
-#ifdef NEED_DECLARATION_ATOF
+#if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
extern double atof PARAMS ((const char *));
#endif
-#ifdef NEED_DECLARATION_ATOL
+#if defined (HAVE_DECL_ATOL) && !HAVE_DECL_ATOL
extern long atol PARAMS ((const char *));
#endif
-#ifdef NEED_DECLARATION_FREE
+#if defined (HAVE_DECL_FREE) && !HAVE_DECL_FREE
extern void free PARAMS ((PTR));
#endif
-#ifdef NEED_DECLARATION_GETCWD
+#if defined (HAVE_DECL_GETCWD) && !HAVE_DECL_GETCWD
extern char *getcwd PARAMS ((char *, size_t));
#endif
-#ifdef NEED_DECLARATION_GETENV
+#if defined (HAVE_DECL_GETENV) && !HAVE_DECL_GETENV
extern char *getenv PARAMS ((const char *));
#endif
-#ifdef NEED_DECLARATION_GETWD
+#if defined (HAVE_DECL_GETWD) && !HAVE_DECL_GETWD
extern char *getwd PARAMS ((char *));
#endif
-#ifdef NEED_DECLARATION_SBRK
+#if defined (HAVE_DECL_SBRK) && !HAVE_DECL_SBRK
extern PTR sbrk PARAMS ((int));
#endif
-#ifdef NEED_DECLARATION_STRSTR
+#if defined (HAVE_DECL_STRSTR) && !HAVE_DECL_STRSTR
extern char *strstr PARAMS ((const char *, const char *));
#endif
#include <malloc.h>
#endif
-#ifdef NEED_DECLARATION_MALLOC
+#if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
extern PTR malloc PARAMS ((size_t));
#endif
-#ifdef NEED_DECLARATION_CALLOC
+#if defined (HAVE_DECL_CALLOC) && !HAVE_DECL_CALLOC
extern PTR calloc PARAMS ((size_t, size_t));
#endif
-#ifdef NEED_DECLARATION_REALLOC
+#if defined (HAVE_DECL_REALLOC) && !HAVE_DECL_REALLOC
extern PTR realloc PARAMS ((PTR, size_t));
#endif
/* If the system doesn't provide strsignal, we get it defined in
libiberty but no declaration is supplied. */
-#ifdef NEED_DECLARATION_STRSIGNAL
+#if defined (HAVE_DECL_STRSIGNAL) && !HAVE_DECL_STRSIGNAL
# ifndef strsignal
extern const char *strsignal PARAMS ((int));
# endif
#endif
#ifdef HAVE_GETRLIMIT
-# ifdef NEED_DECLARATION_GETRLIMIT
+# if defined (HAVE_DECL_GETRLIMIT) && !HAVE_DECL_GETRLIMIT
# ifndef getrlimit
# ifdef ANSI_PROTOTYPES
struct rlimit;
#endif
#ifdef HAVE_SETRLIMIT
-# ifdef NEED_DECLARATION_SETRLIMIT
+# if defined (HAVE_DECL_SETRLIMIT) && !HAVE_DECL_SETRLIMIT
# ifndef setrlimit
# ifdef ANSI_PROTOTYPES
struct rlimit;
#define volatile
#endif
-#ifdef NEED_DECLARATION_ABORT
+#if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
extern void abort PARAMS ((void));
#endif
#define ENUM_BITFIELD(TYPE) unsigned int
#endif
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+/* Traditional C cannot initialize union members of structs. Provide
+ a macro which expands appropriately to handle it. This only works
+ if you intend to initalize the union member to zero since it relies
+ on default initialization to zero in the traditional C case. */
+#ifdef __STDC__
+#define UNION_INIT_ZERO , {0}
+#else
+#define UNION_INIT_ZERO
+#endif
+
+/* GCC now gives implicit declaration warnings for undeclared builtins. */
+#if defined(__GNUC__) && defined (__SIZE_TYPE__)
+extern void *alloca (__SIZE_TYPE__);
+#endif
+
+/* Various error reporting routines want to use __FUNCTION__. */
+#if (GCC_VERSION < 2007)
+#ifndef __FUNCTION__
+#define __FUNCTION__ "?"
+#endif /* ! __FUNCTION__ */
+#endif
#endif /* __GCC_SYSTEM_H__ */