From: Kaveh R. Ghazi Date: Thu, 3 Sep 1998 06:52:00 +0000 (+0000) Subject: aclocal.m4 (GCC_HEADER_STRING): New macro to detect if it is safe to include both... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ccc7d11a0bf6b47ce22cdf1d0ca37eb454edbe87;p=gcc.git aclocal.m4 (GCC_HEADER_STRING): New macro to detect if it is safe to include both string.h and strings.h together. * aclocal.m4 (GCC_HEADER_STRING): New macro to detect if it is safe to include both string.h and strings.h together. (GCC_NEED_DECLARATION): Test STRING_WITH_STRINGS when deciding which headers to search for function declarations. Continue to prefer string.h over strings.h when both are not acceptable. * acconfig.h (STRING_WITH_STRINGS): Add stub. * configure.in: Call GCC_HEADER_STRING. * system.h: Test STRING_WITH_STRINGS when deciding which headers to include. Continue to prefer string.h over strings.h when both are not acceptable. From-SVN: r22204 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7519b871429..9bf58169908 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +Thu Sep 3 09:47:31 1998 Kaveh R. Ghazi + + * aclocal.m4 (GCC_HEADER_STRING): New macro to detect if it is + safe to include both string.h and strings.h together. + (GCC_NEED_DECLARATION): Test STRING_WITH_STRINGS when deciding + which headers to search for function declarations. Continue to + prefer string.h over strings.h when both are not acceptable. + + * acconfig.h (STRING_WITH_STRINGS): Add stub. + + * configure.in: Call GCC_HEADER_STRING. + + * system.h: Test STRING_WITH_STRINGS when deciding which headers + to include. Continue to prefer string.h over strings.h when both + are not acceptable. + Wed Sep 2 23:56:29 1998 David S. Miller * config/sparc/sparc.c (output_double_int): If V9 and MEDLOW, do diff --git a/gcc/acconfig.h b/gcc/acconfig.h index e1ac38442f0..4aac693381a 100644 --- a/gcc/acconfig.h +++ b/gcc/acconfig.h @@ -1,3 +1,6 @@ +/* Define if you can safely include both and . */ +#undef STRING_WITH_STRINGS + /* Define if printf supports "%p". */ #undef HAVE_PRINTF_PTR diff --git a/gcc/aclocal.m4 b/gcc/aclocal.m4 index febe8a70054..ce44ba19eb9 100644 --- a/gcc/aclocal.m4 +++ b/gcc/aclocal.m4 @@ -1,3 +1,14 @@ +dnl See whether we can include both string.h and strings.h. +AC_DEFUN(GCC_HEADER_STRING, +[AC_CACHE_CHECK([whether string.h and strings.h may both be included], + gcc_cv_header_string, +[AC_TRY_COMPILE([#include +#include ], , gcc_cv_header_string=yes, gcc_cv_header_string=no)]) +if test $gcc_cv_header_string = yes; then + AC_DEFINE(STRING_WITH_STRINGS) +fi +]) + dnl See whether we need a declaration for a function. dnl GCC_NEED_DECLARATION(FUNCTION [, EXTRA-HEADER-FILES]) AC_DEFUN(GCC_NEED_DECLARATION, @@ -5,12 +16,17 @@ AC_DEFUN(GCC_NEED_DECLARATION, AC_CACHE_VAL(gcc_cv_decl_needed_$1, [AC_TRY_COMPILE([ #include -#ifdef HAVE_STRING_H -#include +#ifdef STRING_WITH_STRINGS +# include +# include #else -#ifdef HAVE_STRINGS_H -#include -#endif +# ifdef HAVE_STRING_H +# include +# else +# ifdef HAVE_STRINGS_H +# include +# endif +# endif #endif #ifdef HAVE_STDLIB_H #include diff --git a/gcc/config.in b/gcc/config.in index b4e989842db..3cd381ae5a6 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1,4 +1,7 @@ /* config.in. Generated automatically from configure.in by autoheader. */ +/* Define if you can safely include both and . */ +#undef STRING_WITH_STRINGS + /* Define if printf supports "%p". */ #undef HAVE_PRINTF_PTR diff --git a/gcc/configure b/gcc/configure index 758b52e819b..1baa04d64bb 100755 --- a/gcc/configure +++ b/gcc/configure @@ -1613,21 +1613,55 @@ EOF fi +echo $ac_n "checking whether string.h and strings.h may both be included""... $ac_c" 1>&6 +echo "configure:1618: checking whether string.h and strings.h may both be included" >&5 +if eval "test \"`echo '$''{'gcc_cv_header_string'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +#include +int main() { + +; return 0; } +EOF +if { (eval echo configure:1631: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + gcc_cv_header_string=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + gcc_cv_header_string=no +fi +rm -f conftest* +fi + +echo "$ac_t""$gcc_cv_header_string" 1>&6 +if test $gcc_cv_header_string = yes; then + cat >> confdefs.h <<\EOF +#define STRING_WITH_STRINGS 1 +EOF + +fi + for ac_hdr in limits.h stddef.h string.h strings.h stdlib.h time.h fcntl.h unistd.h stab.h sys/file.h sys/time.h sys/resource.h sys/param.h sys/times.h wait.h sys/wait.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1621: checking for $ac_hdr" >&5 +echo "configure:1655: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1631: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1665: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1657,17 +1691,17 @@ done # Check for thread headers. ac_safe=`echo "thread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for thread.h""... $ac_c" 1>&6 -echo "configure:1661: checking for thread.h" >&5 +echo "configure:1695: checking for thread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1671: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1691,17 +1725,17 @@ fi ac_safe=`echo "pthread.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for pthread.h""... $ac_c" 1>&6 -echo "configure:1695: checking for pthread.h" >&5 +echo "configure:1729: checking for pthread.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1739: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1727,12 +1761,12 @@ fi # See if the system preprocessor understands the ANSI C preprocessor # stringification operator. echo $ac_n "checking whether cpp understands the stringify operator""... $ac_c" 1>&6 -echo "configure:1731: checking whether cpp understands the stringify operator" >&5 +echo "configure:1765: checking whether cpp understands the stringify operator" >&5 if eval "test \"`echo '$''{'gcc_cv_c_have_stringify'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1778: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* gcc_cv_c_have_stringify=yes else @@ -1763,12 +1797,12 @@ fi # Use only if it exists, # doesn't clash with , and declares intmax_t. echo $ac_n "checking for inttypes.h""... $ac_c" 1>&6 -echo "configure:1767: checking for inttypes.h" >&5 +echo "configure:1801: checking for inttypes.h" >&5 if eval "test \"`echo '$''{'gcc_cv_header_inttypes_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -1776,7 +1810,7 @@ int main() { intmax_t i = -1; ; return 0; } EOF -if { (eval echo configure:1780: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1814: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <&6 -echo "configure:1803: checking for $ac_func" >&5 +echo "configure:1837: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1865: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -1856,12 +1890,12 @@ done #AC_CHECK_TYPE(wchar_t, unsigned int) echo $ac_n "checking for vprintf""... $ac_c" 1>&6 -echo "configure:1860: checking for vprintf" >&5 +echo "configure:1894: checking for vprintf" >&5 if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1922: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func_vprintf=yes" else @@ -1908,12 +1942,12 @@ fi if test "$ac_cv_func_vprintf" != yes; then echo $ac_n "checking for _doprnt""... $ac_c" 1>&6 -echo "configure:1912: checking for _doprnt" >&5 +echo "configure:1946: checking for _doprnt" >&5 if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:1974: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* eval "ac_cv_func__doprnt=yes" else @@ -1972,7 +2006,7 @@ fi echo $ac_n "checking whether the printf functions support %p""... $ac_c" 1>&6 -echo "configure:1976: checking whether the printf functions support %p" >&5 +echo "configure:2010: checking whether the printf functions support %p" >&5 if eval "test \"`echo '$''{'gcc_cv_func_printf_ptr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1980,7 +2014,7 @@ else gcc_cv_func_printf_ptr=no else cat > conftest.$ac_ext < @@ -1993,7 +2027,7 @@ main() exit (p != q); } EOF -if { (eval echo configure:1997: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2031: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then gcc_cv_func_printf_ptr=yes else @@ -2021,21 +2055,26 @@ for ac_func in malloc realloc calloc free bcopy bzero bcmp \ index rindex getenv atol sbrk abort atof strerror getcwd getwd do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:2025: checking whether $ac_func must be declared" >&5 +echo "configure:2059: 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 +#ifdef STRING_WITH_STRINGS +# include +# include #else -#ifdef HAVE_STRINGS_H -#include -#endif +# ifdef HAVE_STRING_H +# include +# else +# ifdef HAVE_STRINGS_H +# include +# endif +# endif #endif #ifdef HAVE_STDLIB_H #include @@ -2054,7 +2093,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:2058: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2097: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -2083,21 +2122,26 @@ done for ac_func in getrlimit setrlimit do echo $ac_n "checking whether $ac_func must be declared""... $ac_c" 1>&6 -echo "configure:2087: checking whether $ac_func must be declared" >&5 +echo "configure:2126: 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 +#ifdef STRING_WITH_STRINGS +# include +# include #else -#ifdef HAVE_STRINGS_H -#include -#endif +# ifdef HAVE_STRING_H +# include +# else +# ifdef HAVE_STRINGS_H +# include +# endif +# endif #endif #ifdef HAVE_STDLIB_H #include @@ -2120,7 +2164,7 @@ int main() { char *(*pfn) = (char *(*)) $ac_func ; return 0; } EOF -if { (eval echo configure:2124: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2168: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* eval "gcc_cv_decl_needed_$ac_func=no" else @@ -2147,12 +2191,12 @@ done echo $ac_n "checking for sys_siglist declaration in signal.h or unistd.h""... $ac_c" 1>&6 -echo "configure:2151: checking for sys_siglist declaration in signal.h or unistd.h" >&5 +echo "configure:2195: 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 @@ -2164,7 +2208,7 @@ int main() { char *msg = *(sys_siglist + 1); ; return 0; } EOF -if { (eval echo configure:2168: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2212: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_decl_sys_siglist=yes else @@ -5322,7 +5366,7 @@ fi # Figure out what assembler alignment features are present. echo $ac_n "checking assembler alignment features""... $ac_c" 1>&6 -echo "configure:5326: checking assembler alignment features" >&5 +echo "configure:5370: checking assembler alignment features" >&5 gcc_cv_as= gcc_cv_as_alignment_features= gcc_cv_as_gas_srcdir=`echo $srcdir | sed -e 's,gcc$,gas,'` @@ -5582,7 +5626,7 @@ fi # Warn if using init_priority. echo $ac_n "checking whether to enable init_priority by default""... $ac_c" 1>&6 -echo "configure:5586: checking whether to enable init_priority by default" >&5 +echo "configure:5630: checking whether to enable init_priority by default" >&5 if test x$enable_init_priority != xyes; then enable_init_priority=no fi diff --git a/gcc/configure.in b/gcc/configure.in index 7c281cacc1f..6ba1b86b7bb 100644 --- a/gcc/configure.in +++ b/gcc/configure.in @@ -213,6 +213,7 @@ EGCS_PROG_INSTALL AC_HEADER_STDC AC_HEADER_TIME +GCC_HEADER_STRING AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h fcntl.h unistd.h stab.h sys/file.h sys/time.h sys/resource.h sys/param.h sys/times.h wait.h sys/wait.h) # Check for thread headers. diff --git a/gcc/system.h b/gcc/system.h index e16cd2ea312..541b30de793 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -88,11 +88,16 @@ extern int errno; #endif -#ifdef HAVE_STRING_H +#ifdef STRING_WITH_STRINGS # include +# include #else -# ifdef HAVE_STRINGS_H -# include +# ifdef HAVE_STRING_H +# include +# else +# ifdef HAVE_STRINGS_H +# include +# endif # endif #endif