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 <iain@sandoe.co.uk>

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.
This commit is contained in:
Iain Sandoe 2021-08-23 17:27:25 +01:00
parent a88280cff3
commit fbb334a6ac
3 changed files with 35 additions and 25 deletions

43
libiberty/configure vendored
View File

@ -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

View File

@ -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])

View File

@ -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 */