From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id 5A1D63857C60; Wed, 1 Sep 2021 18:35:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A1D63857C60 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3296] libiberty, configure, Darwin: Avoid detecting deprecated sbrk. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: a88280cff3436d0b6ab454514e5a3b97a543e9a5 X-Git-Newrev: fbb334a6acc5cc5d8944712daeda8089ef1d7fd2 Message-Id: <20210901183515.5A1D63857C60@sourceware.org> Date: Wed, 1 Sep 2021 18:35:15 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 18:35:15 -0000 https://gcc.gnu.org/g:fbb334a6acc5cc5d8944712daeda8089ef1d7fd2 commit r12-3296-gfbb334a6acc5cc5d8944712daeda8089ef1d7fd2 Author: Iain Sandoe Date: Mon Aug 23 17:27:25 2021 +0100 libiberty, configure, Darwin: Avoid detecting deprecated sbrk. Darwin provides an implementation of sbrk, which is detected by the configuration process. However, it is deprecated which leads to build warnings. The malloc-based implementation is more suitable. This patch removes sbrk from the functions searched for Darwin. Signed-off-by: Iain Sandoe libiberty/ChangeLog: * configure: Regenerate. * configure.ac: Do not search for sbrk on Darwin. * xmalloc.c: Do not declare sbrk unless it has been found by configure. Diff: --- libiberty/configure | 43 ++++++++++++++++++++----------------------- libiberty/configure.ac | 15 +++++++++++++-- libiberty/xmalloc.c | 2 ++ 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/libiberty/configure b/libiberty/configure index f7449d6a368..3c7e588b16b 100755 --- a/libiberty/configure +++ b/libiberty/configure @@ -681,7 +681,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -761,7 +760,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -1014,15 +1012,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1160,7 +1149,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1313,7 +1302,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -4295,7 +4283,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4341,7 +4329,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4365,7 +4353,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4410,7 +4398,7 @@ else We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4434,7 +4422,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -6029,9 +6017,16 @@ vars="sys_errlist sys_nerr sys_siglist" checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \ getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \ - realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \ + realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \ sysmp table times wait3 wait4" +# Darwin has sbrk, but it is deprecated and that produces build-time warnings +# so do not check for it. +case "${host}" in + *-*-darwin*) ;; + *) checkfuncs="$checkfuncs sbrk" +esac + # These are neither executed nor required, but they help keep # autoheader happy without adding a bunch of text to acconfig.h. if test "x" = "y"; then @@ -7260,7 +7255,10 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_REALLOC $ac_have_decl _ACEOF -ac_fn_c_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default" + + case "${host}" in + *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated. + *) ac_fn_c_check_decl "$LINENO" "sbrk" "ac_cv_have_decl_sbrk" "$ac_includes_default" if test "x$ac_cv_have_decl_sbrk" = xyes; then : ac_have_decl=1 else @@ -7270,7 +7268,8 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_SBRK $ac_have_decl _ACEOF - +;; + esac ac_fn_c_check_decl "$LINENO" "strtol" "ac_cv_have_decl_strtol" "$ac_includes_default" if test "x$ac_cv_have_decl_strtol" = xyes; then : ac_have_decl=1 @@ -7575,8 +7574,6 @@ main () if (*(data + i) != *(data3 + i)) return 14; close (fd); - free (data); - free (data3); return 0; } _ACEOF diff --git a/libiberty/configure.ac b/libiberty/configure.ac index a85ff25501a..4b78c1830c7 100644 --- a/libiberty/configure.ac +++ b/libiberty/configure.ac @@ -395,9 +395,16 @@ vars="sys_errlist sys_nerr sys_siglist" checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \ getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \ - realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \ + realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \ sysmp table times wait3 wait4" +# Darwin has sbrk, but it is deprecated and that produces build-time warnings +# so do not check for it. +case "${host}" in + *-*-darwin*) ;; + *) checkfuncs="$checkfuncs sbrk" +esac + # These are neither executed nor required, but they help keep # autoheader happy without adding a bunch of text to acconfig.h. if test "x" = "y"; then @@ -695,7 +702,11 @@ if test -z "${setobjs}"; then AC_CHECK_FUNCS($checkfuncs) AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf]) - AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc, sbrk]) + AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc]) + case "${host}" in + *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated. + *) AC_CHECK_DECLS([sbrk]);; + esac AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull]) AC_CHECK_DECLS([strverscmp]) AC_CHECK_DECLS([strnlen]) diff --git a/libiberty/xmalloc.c b/libiberty/xmalloc.c index 85826c1e10f..b9e23c38643 100644 --- a/libiberty/xmalloc.c +++ b/libiberty/xmalloc.c @@ -87,7 +87,9 @@ extern "C" { void *malloc (size_t); void *realloc (void *, size_t); void *calloc (size_t, size_t); +#ifdef HAVE_SBRK void *sbrk (ptrdiff_t); +#endif # ifdef __cplusplus } # endif /* __cplusplus */