Commit d2cabf16 by Kaveh R. Ghazi Committed by Kaveh Ghazi

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
parent 70198e3d
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> Tue Jun 30 10:54:48 1998 Mark Mitchell <mark@markmitchell.com>
* rtl.texi: Don't say that RTX_INTEGRATED_P is unused. * rtl.texi: Don't say that RTX_INTEGRATED_P is unused.
......
...@@ -65,6 +65,12 @@ ...@@ -65,6 +65,12 @@
/* Whether getwd must be declared even if <unistd.h> is included. */ /* Whether getwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETWD #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. */ /* Define if you want expensive run-time checks. */
#undef ENABLE_CHECKING #undef ENABLE_CHECKING
@TOP@ @TOP@
dnl See whether we need a declaration for a function. dnl See whether we need a declaration for a function.
dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES])
AC_DEFUN(GCC_NEED_DECLARATION, AC_DEFUN(GCC_NEED_DECLARATION,
[AC_MSG_CHECKING([whether $1 must be declared]) [AC_MSG_CHECKING([whether $1 must be declared])
AC_CACHE_VAL(gcc_cv_decl_needed_$1, AC_CACHE_VAL(gcc_cv_decl_needed_$1,
...@@ -22,7 +23,8 @@ AC_CACHE_VAL(gcc_cv_decl_needed_$1, ...@@ -22,7 +23,8 @@ AC_CACHE_VAL(gcc_cv_decl_needed_$1,
#endif #endif
#ifndef HAVE_INDEX #ifndef HAVE_INDEX
#define index strchr #define index strchr
#endif], #endif
$2],
[char *(*pfn) = (char *(*)) $1], [char *(*pfn) = (char *(*)) $1],
eval "gcc_cv_decl_needed_$1=no", eval "gcc_cv_decl_needed_$1=yes")]) 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 if eval "test \"`echo '$gcc_cv_decl_needed_'$1`\" = yes"; then
...@@ -35,10 +37,11 @@ fi ...@@ -35,10 +37,11 @@ fi
])dnl ])dnl
dnl Check multiple functions to see whether each needs a declaration. dnl Check multiple functions to see whether each needs a declaration.
dnl GCC_NEED_DECLARATIONS(FUNCTION... [, EXTRA-HEADER-FILES])
AC_DEFUN(GCC_NEED_DECLARATIONS, AC_DEFUN(GCC_NEED_DECLARATIONS,
[for ac_func in $1 [for ac_func in $1
do do
GCC_NEED_DECLARATION($ac_func) GCC_NEED_DECLARATION($ac_func, $2)
done done
]) ])
......
...@@ -66,6 +66,15 @@ ...@@ -66,6 +66,15 @@
/* Whether getwd must be declared even if <unistd.h> is included. */ /* Whether getwd must be declared even if <unistd.h> is included. */
#undef NEED_DECLARATION_GETWD #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. */ /* Define if you don't have vprintf but do have _doprnt. */
#undef HAVE_DOPRNT #undef HAVE_DOPRNT
......
...@@ -1976,11 +1976,78 @@ else ...@@ -1976,11 +1976,78 @@ else
#ifndef HAVE_INDEX #ifndef HAVE_INDEX
#define index strchr #define index strchr
#endif #endif
int main() {
char *(*pfn) = (char *(*)) $ac_func
; return 0; }
EOF
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() { int main() {
char *(*pfn) = (char *(*)) $ac_func char *(*pfn) = (char *(*)) $ac_func
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1984: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then if { (eval echo configure:2051: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest* rm -rf conftest*
eval "gcc_cv_decl_needed_$ac_func=no" eval "gcc_cv_decl_needed_$ac_func=no"
else else
...@@ -2007,12 +2074,12 @@ done ...@@ -2007,12 +2074,12 @@ done
echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_decl_sys_siglist'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 2016 "configure" #line 2083 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <sys/types.h> #include <sys/types.h>
#include <signal.h> #include <signal.h>
...@@ -2024,7 +2091,7 @@ int main() { ...@@ -2024,7 +2091,7 @@ int main() {
char *msg = *(sys_siglist + 1); char *msg = *(sys_siglist + 1);
; return 0; } ; return 0; }
EOF 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* rm -rf conftest*
ac_cv_decl_sys_siglist=yes ac_cv_decl_sys_siglist=yes
else else
...@@ -5147,7 +5214,7 @@ fi ...@@ -5147,7 +5214,7 @@ fi
# Figure out what assembler alignment features are present. # Figure out what assembler alignment features are present.
echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6 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=
gcc_cv_as_alignment_features= gcc_cv_as_alignment_features=
if [ -x as$host_exeext ]; then if [ -x as$host_exeext ]; then
......
...@@ -199,6 +199,13 @@ GCC_FUNC_PRINTF_PTR ...@@ -199,6 +199,13 @@ GCC_FUNC_PRINTF_PTR
GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \ GCC_NEED_DECLARATIONS(malloc realloc calloc free bcopy bzero bcmp \
index rindex getenv atol sbrk abort atof strerror getcwd getwd) 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 AC_DECL_SYS_SIGLIST
# File extensions # File extensions
......
...@@ -235,6 +235,22 @@ extern int sys_nerr; ...@@ -235,6 +235,22 @@ extern int sys_nerr;
extern char *sys_errlist[]; extern char *sys_errlist[];
#endif /* HAVE_STRERROR */ #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 /* HAVE_VOLATILE only refers to the stage1 compiler. We also check
__STDC__ and assume gcc sets it and has volatile in stage >=2. */ __STDC__ and assume gcc sets it and has volatile in stage >=2. */
#if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile) #if !defined(HAVE_VOLATILE) && !defined(__STDC__) && !defined(volatile)
......
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