Commit f31e826b by Kaveh R. Ghazi Committed by Kaveh Ghazi

getopt.h (getopt): Also check HAVE_DECL_* when prototyping.

include:
	* getopt.h (getopt): Also check HAVE_DECL_* when prototyping.

	* libiberty.h (basename): Likewise.

gcc:
	* aclocal.m4 (gcc_AC_CHECK_DECL, gcc_AC_CHECK_DECLS): New macros
	rewritten from the internals of gcc_AC_NEED_DECLARATION{S}.

	* configure.in (gcc_AC_CHECK_DECLS): Call this instead of
	gcc_AC_NEED_DECLARATIONS.

	* dwarfout.c: Don't prototype time().

	* gcc.c: Check HAVE_DECL_* instead of NEED_DECLARATION_*.

	* system.h: Likewise.

	* toplev.c: Likewise.

From-SVN: r34108
parent 04de7314
2000-05-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (gcc_AC_CHECK_DECL, gcc_AC_CHECK_DECLS): New macros
rewritten from the internals of gcc_AC_NEED_DECLARATION{S}.
* configure.in (gcc_AC_CHECK_DECLS): Call this instead of
gcc_AC_NEED_DECLARATIONS.
* dwarfout.c: Don't prototype time().
* gcc.c: Check HAVE_DECL_* instead of NEED_DECLARATION_*.
* system.h: Likewise.
* toplev.c: Likewise.
2000-05-23 Zack Weinberg <zack@wolery.cumb.org>
* c-decl.c (pushdecl): Invert sense of test for non-global types.
......@@ -13,40 +13,43 @@ dnl See whether we need a declaration for a function.
dnl The result is highly dependent on the INCLUDES passed in, so make sure
dnl to use a different cache variable name in this macro if it is invoked
dnl in a different context somewhere else.
dnl gcc_AC_NEED_DECLARATION(FUNCTION, INCLUDES,
dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
AC_DEFUN(gcc_AC_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(gcc_cv_decl_needed_$1,
[AC_TRY_COMPILE([$2],
dnl gcc_AC_CHECK_DECL(SYMBOL,
dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
AC_DEFUN(gcc_AC_CHECK_DECL,
[AC_MSG_CHECKING([whether $1 is declared])
AC_CACHE_VAL(gcc_cv_have_decl_$1,
[AC_TRY_COMPILE([$4],
[#ifndef $1
char *(*pfn) = (char *(*)) $1 ;
#endif], eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")])
if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
AC_MSG_RESULT(yes) ; ifelse([$3], , :, [$3])
#endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
else
AC_MSG_RESULT(no) ; ifelse([$4], , :, [$4])
AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
fi
])dnl
dnl Check multiple functions to see whether each needs a declaration.
dnl Arrange to define NEED_DECLARATION_<FUNCTION> if appropriate.
dnl gcc_AC_NEED_DECLARATIONS(FUNCTION... , INCLUDES,
dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED]])
AC_DEFUN(gcc_AC_NEED_DECLARATIONS,
dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
dnl gcc_AC_CHECK_DECLS(SYMBOLS,
dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
AC_DEFUN(gcc_AC_CHECK_DECLS,
[for ac_func in $1
do
gcc_AC_NEED_DECLARATION($ac_func, [$2],
[changequote(, )dnl
ac_tr_decl=NEED_DECLARATION_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
changequote(, )dnl
ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
changequote([, ])dnl
AC_DEFINE_UNQUOTED($ac_tr_decl) $3], $4)
gcc_AC_CHECK_DECL($ac_func,
[AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
[AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
$4
)
done
dnl Automatically generate config.h entries via autoheader.
if test x = y ; then
patsubst(translit([$1], [a-z], [A-Z]), [\w+],
AC_DEFINE([NEED_DECLARATION_\&], 1,
[Define if you need to provide a declaration for this function.]))dnl
AC_DEFINE([HAVE_DECL_\&], 1,
[Define to 1 if we found this declaration otherwise define to 0.]))dnl
fi
])
......
......@@ -316,77 +316,83 @@
/* Define if read-only mmap of a plain file works. */
#undef HAVE_MMAP_FILE
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_BCOPY
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_BCOPY
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_BZERO
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_BZERO
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_BCMP
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_BCMP
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_INDEX
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_INDEX
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_RINDEX
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_RINDEX
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_GETENV
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETENV
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_ATOL
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_ATOL
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_SBRK
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_SBRK
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_ABORT
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_ABORT
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_ATOF
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_ATOF
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_GETCWD
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETCWD
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_GETWD
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETWD
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_STRSIGNAL
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_STRSIGNAL
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_PUTC_UNLOCKED
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_PUTC_UNLOCKED
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_FPUTS_UNLOCKED
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_FPUTS_UNLOCKED
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_STRSTR
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_STRSTR
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_ENVIRON
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_ENVIRON
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_MALLOC
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_MALLOC
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_REALLOC
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_REALLOC
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_CALLOC
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_CALLOC
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_FREE
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_FREE
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_GETRLIMIT
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_BASENAME
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_SETRLIMIT
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETOPT
/* Define if you need to provide a declaration for this function. */
#undef NEED_DECLARATION_GETRUSAGE
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETRLIMIT
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_SETRLIMIT
/* Define to 1 if we found this declaration otherwise define to 0. */
#undef HAVE_DECL_GETRUSAGE
/* Define if host mkdir takes a single argument. */
#undef MKDIR_TAKES_ONE_ARG
......
......@@ -479,14 +479,14 @@ AC_FUNC_MMAP_FILE
# We will need to find libiberty.h and ansidecl.h
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I${srcdir} -I${srcdir}/../include"
gcc_AC_NEED_DECLARATIONS(bcopy bzero bcmp \
gcc_AC_CHECK_DECLS(bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof getcwd getwd \
strsignal putc_unlocked fputs_unlocked strstr environ \
malloc realloc calloc free, [
malloc realloc calloc free basename getopt, , ,[
#include "gansidecl.h"
#include "system.h"])
gcc_AC_NEED_DECLARATIONS(getrlimit setrlimit getrusage, [
gcc_AC_CHECK_DECLS(getrlimit setrlimit getrusage, , ,[
#include "gansidecl.h"
#include "system.h"
#ifdef HAVE_SYS_RESOURCE_H
......
......@@ -37,12 +37,6 @@ Boston, MA 02111-1307, USA. */
#include "toplev.h"
#include "tm_p.h"
#if defined(DWARF_TIMESTAMPS)
#if !defined(POSIX)
extern time_t time PARAMS ((time_t *)); /* FIXME: use NEED_DECLARATION_TIME */
#endif /* !defined(POSIX) */
#endif /* defined(DWARF_TIMESTAMPS) */
/* We cannot use <assert.h> in GCC source, since that would include
GCC's assert.h, which may not be compatible with the host compiler. */
#undef assert
......
......@@ -48,7 +48,7 @@ compilation is specified by a string called a "spec". */
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
#ifdef NEED_DECLARATION_GETRUSAGE
#if defined (HAVE_DECL_GETRUSAGE) && !HAVE_DECL_GETRUSAGE
extern int getrusage PARAMS ((int, struct rusage *));
#endif
......
......@@ -53,24 +53,24 @@ Boston, MA 02111-1307, USA. */
/* 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
......@@ -305,11 +305,14 @@ extern int errno;
#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 */
......@@ -319,7 +322,7 @@ extern void bcopy PARAMS ((const PTR, PTR, size_t));
#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 */
......@@ -329,7 +332,7 @@ extern int bcmp PARAMS ((const PTR, const PTR, size_t));
#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 */
......@@ -339,7 +342,7 @@ extern void bzero PARAMS ((PTR, size_t));
#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 */
......@@ -349,7 +352,7 @@ extern char *index PARAMS ((const char *, int));
#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 */
......@@ -357,35 +360,35 @@ extern char *rindex PARAMS ((const char *, int));
# 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
......@@ -393,28 +396,28 @@ extern char *strstr PARAMS ((const char *, const char *));
#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;
......@@ -425,7 +428,7 @@ extern int getrlimit PARAMS ((int, 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;
......@@ -441,7 +444,7 @@ extern int setrlimit PARAMS ((int, const struct rlimit *));
#define volatile
#endif
#ifdef NEED_DECLARATION_ABORT
#if defined (HAVE_DECL_ABORT) && !HAVE_DECL_ABORT
extern void abort PARAMS ((void));
#endif
......
......@@ -145,7 +145,7 @@ You Lose! You must define PREFERRED_DEBUGGING_TYPE!
#define PREFERRED_DEBUGGING_TYPE NO_DEBUG
#endif
#ifdef NEED_DECLARATION_ENVIRON
#if defined (HAVE_DECL_ENVIRON) && !HAVE_DECL_ENVIRON
extern char **environ;
#endif
......
2000-05-23 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* getopt.h (getopt): Also check HAVE_DECL_* when prototyping.
* libiberty.h (basename): Likewise.
2000-05-06 Zack Weinberg <zack@wolery.cumb.org>
* ansidecl.h: #define __extension__ to nothing if
......
......@@ -99,13 +99,20 @@ struct option
#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
undefined, we haven't run the autoconf check so provide the
declaration without arguments. If it is 0, we checked and failed
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
/* Many other libraries have conflicting prototypes for getopt, with
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
# if !defined (HAVE_DECL_GETOPT)
extern int getopt ();
# endif
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
......
......@@ -36,10 +36,17 @@ extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
across different systems, sometimes as "char *" and sometimes as
"const char *" */
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__)
/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is
undefined, we haven't run the autoconf check so provide the
declaration without arguments. If it is 0, we checked and failed
to find the declaration so provide a fully prototyped one. If it
is 1, we found it so don't provide any declaration at all. */
#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || (defined (HAVE_DECL_BASENAME) && !HAVE_DECL_BASENAME)
extern char *basename PARAMS ((const char *));
#else
# if !defined (HAVE_DECL_BASENAME)
extern char *basename ();
# endif
#endif
/* Concatenate an arbitrary number of strings, up to (char *) NULL.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment