From d2cabf16295972b2397970e4154e0433dbd01a1a Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 30 Jun 1998 11:10:55 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 15 ++++++++++ gcc/acconfig.h | 6 ++++ gcc/aclocal.m4 | 7 +++-- gcc/config.in | 9 ++++++ gcc/configure | 77 ++++++++++++++++++++++++++++++++++++++++++++---- gcc/configure.in | 7 +++++ gcc/system.h | 16 ++++++++++ 7 files changed, 130 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e518d5859ef..913f9040e10 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +Tue Jun 30 14:03:34 1998 Kaveh R. Ghazi + + * 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 * rtl.texi: Don't say that RTX_INTEGRATED_P is unused. diff --git a/gcc/acconfig.h b/gcc/acconfig.h index 16e4ae5e470..74d378ea83b 100644 --- a/gcc/acconfig.h +++ b/gcc/acconfig.h @@ -65,6 +65,12 @@ /* Whether getwd must be declared even if is included. */ #undef NEED_DECLARATION_GETWD +/* Whether getrlimit must be declared even if is included. */ +#undef NEED_DECLARATION_GETRLIMIT + +/* Whether setrlimit must be declared even if is included. */ +#undef NEED_DECLARATION_SETRLIMIT + /* Define if you want expensive run-time checks. */ #undef ENABLE_CHECKING @TOP@ diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4 index 7149a2ab98a..fea020129d2 100644 --- a/gcc/aclocal.m4 +++ b/gcc/aclocal.m4 @@ -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 ]) diff --git a/gcc/config.in b/gcc/config.in index e4e4f2eb1de..5cb748a0430 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -66,6 +66,15 @@ /* Whether getwd must be declared even if is included. */ #undef NEED_DECLARATION_GETWD +/* Whether getrlimit must be declared even if is included. */ +#undef NEED_DECLARATION_GETRLIMIT + +/* Whether setrlimit must be declared even if 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 diff --git a/gcc/configure b/gcc/configure index 8508761fa19..e59c70d27e0 100755 --- a/gcc/configure +++ b/gcc/configure @@ -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: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 <&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 < +#ifdef HAVE_STRING_H +#include +#else +#ifdef HAVE_STRINGS_H +#include +#endif +#endif +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifndef HAVE_RINDEX +#define rindex strrchr +#endif +#ifndef HAVE_INDEX +#define index strchr +#endif +#include +#ifdef HAVE_SYS_RESOURCE_H +#include +#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: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 < #include @@ -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 diff --git a/gcc/configure.in b/gcc/configure.in index f13e94221b4..9a6ed54d6c6 100644 --- a/gcc/configure.in +++ b/gcc/configure.in @@ -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 +#ifdef HAVE_SYS_RESOURCE_H +#include +#endif +]) + AC_DECL_SYS_SIGLIST # File extensions diff --git a/gcc/system.h b/gcc/system.h index acb195f2e39..27b1fee6bdf 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -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) -- 2.30.2