Add the ability to GCC_NEED_DECLARATION{S} for looking in arbitrary header...

Add the ability to GCC_NEED_DECLARATION{S} for looking in arbitrary
header files when searching for function declarations.  Use this
functionality to check for getrlimit/setrlimit.
        * aclocal.m4 (GCC_NEED_DECLARATION): Accept an optional second
        argument, which is typically preprocessor code used to draw in
        additional header files when looking for a function declaration.
        (GCC_NEED_DECLARATIONS): Likewise.
        * configure.in (GCC_NEED_DECLARATIONS): Add checks for getrlimit
        and setrlimit, search for them in sys/resource.h.
        * acconfig.h: Add stubs for NEED_DECLARATION_GETRLIMIT and
        NEED_DECLARATION_SETRLIMIT.
        * system.h: Prototype getrlimit/setrlimit if necessary.

From-SVN: r20831
This commit is contained in:
Kaveh R. Ghazi 1998-06-30 11:10:55 +00:00 committed by Kaveh Ghazi
parent 70198e3dd0
commit d2cabf1629
7 changed files with 130 additions and 7 deletions

View File

@ -1,3 +1,18 @@
Tue Jun 30 14:03:34 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* aclocal.m4 (GCC_NEED_DECLARATION): Accept an optional second
argument, which is typically preprocessor code used to draw in
additional header files when looking for a function declaration.
(GCC_NEED_DECLARATIONS): Likewise.
* configure.in (GCC_NEED_DECLARATIONS): Add checks for getrlimit
and setrlimit, search for them in sys/resource.h.
* acconfig.h: Add stubs for NEED_DECLARATION_GETRLIMIT and
NEED_DECLARATION_SETRLIMIT.
* system.h: Prototype getrlimit/setrlimit if necessary.
Tue Jun 30 10:54:48 1998 Mark Mitchell <mark@markmitchell.com>
* rtl.texi: Don't say that RTX_INTEGRATED_P is unused.

View File

@ -65,6 +65,12 @@
/* Whether getwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETWD
/* Whether getrlimit must be declared even if <sys/resource.h> is included. */
#undef NEED_DECLARATION_GETRLIMIT
/* Whether setrlimit must be declared even if <sys/resource.h> is included. */
#undef NEED_DECLARATION_SETRLIMIT
/* Define if you want expensive run-time checks. */
#undef ENABLE_CHECKING
@TOP@

7
gcc/aclocal.m4 vendored
View File

@ -1,4 +1,5 @@
dnl See whether we need a declaration for a function.
dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
AC_DEFUN(GCC_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(gcc_cv_decl_needed_$1,
@ -22,7 +23,8 @@ AC_CACHE_VAL(gcc_cv_decl_needed_$1,
#endif
#ifndef HAVE_INDEX
#define index strchr
#endif],
#endif
$2],
[char *(*pfn) = (char *(*)) $1],
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
@ -35,10 +37,11 @@ fi
])dnl
dnl Check multiple functions to see whether each needs a declaration.
dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
AC_DEFUN(GCC_NEED_DECLARATIONS,
[for ac_func in $1
do
GCC_NEED_DECLARATION($ac_func)
GCC_NEED_DECLARATION($ac_func, $2)
done
])

View File

@ -66,6 +66,15 @@
/* Whether getwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETWD
/* Whether getrlimit must be declared even if <sys/resource.h> is included. */
#undef NEED_DECLARATION_GETRLIMIT
/* Whether setrlimit must be declared even if <sys/resource.h> is included. */
#undef NEED_DECLARATION_SETRLIMIT
/* Define if you want expensive run-time checks. */
#undef ENABLE_CHECKING
/* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT

77
gcc/configure vendored
View File

@ -1976,11 +1976,78 @@ else
#ifndef HAVE_INDEX
#define index strchr
#endif
int main() {
char *(*pfn) = (char *(*)) $ac_func
; return 0; }
EOF
if { (eval echo configure:1984: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1985: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "gcc_cv_decl_needed_$ac_func=no"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "gcc_cv_decl_needed_$ac_func=yes"
fi
rm -f conftest*
fi
if eval "test \"`echo '$gcc_cv_decl_needed_'$ac_func`\" = yes"; then
echo "$ac_t""yes" 1>&6
gcc_tr_decl=NEED_DECLARATION_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >> confdefs.h <<EOF
#define $gcc_tr_decl 1
EOF
else
echo "$ac_t""no" 1>&6
fi
done
for ac_func in getrlimit setrlimit
do
echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6
echo "configure:2014: checking whether $ac_func must be declared" >&5
if eval "test \"`echo '$''{'gcc_cv_decl_needed_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2019 "configure"
#include "confdefs.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
#include <string.h>
#else
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifndef HAVE_RINDEX
#define rindex strrchr
#endif
#ifndef HAVE_INDEX
#define index strchr
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
int main() {
char *(*pfn) = (char *(*)) $ac_func
; return 0; }
EOF
if { (eval echo configure:2051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "gcc_cv_decl_needed_$ac_func=no"
else
@ -2007,12 +2074,12 @@ done
echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6
echo "configure:2011: checking for sys_siglist declaration in signal.h or unistd.h" >&5
echo "configure:2078: checking for sys_siglist declaration in signal.h or unistd.h" >&5
if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2016 "configure"
#line 2083 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@ -2024,7 +2091,7 @@ int main() {
char *msg = *(sys_siglist + 1);
; return 0; }
EOF
if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2095: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_decl_sys_siglist=yes
else
@ -5147,7 +5214,7 @@ fi
# Figure out what assembler alignment features are present.
echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6
echo "configure:5151: checking assembler alignment features" >&5
echo "configure:5218: checking assembler alignment features" >&5
gcc_cv_as=
gcc_cv_as_alignment_features=
if [ -x as$host_exeext ]; then

View File

@ -199,6 +199,13 @@ GCC_FUNC_PRINTF_PTR
GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof strerror getcwd getwd)
GCC_NEED_DECLARATIONS(getrlimit setrlimit, [
#include <sys/types.h>
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
])
AC_DECL_SYS_SIGLIST
# File extensions

View File

@ -235,6 +235,22 @@ extern int sys_nerr;
extern char *sys_errlist[];
#endif /* HAVE_STRERROR */
#ifdef HAVE_GETRLIMIT
# ifdef NEED_DECLARATION_GETRLIMIT
# ifndef getrlimit
extern int getrlimit ();
# endif
# endif
#endif
#ifdef HAVE_SETRLIMIT
# ifdef NEED_DECLARATION_SETRLIMIT
# ifndef setrlimit
extern int setrlimit ();
# endif
# endif
#endif
/* HAVE_VOLATILE only refers to the stage1 compiler. We also check
__STDC__ and assume gcc sets it and has volatile in stage >=2. */
#if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)