diff options
author | Duncan Simpson <dr.duncan.p.simpson@gmail.com> | 2021-03-19 14:22:08 -0700 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2021-03-19 14:22:08 -0700 |
commit | 4ee60495054b362530a7471d363e00143ecb5cbe (patch) | |
tree | 3d4c8ce6e35c58fc1cbfb8edec25e1eb59ccd909 /gold | |
parent | 5cde809b7b9da3ad3aa0d65f0e5e92ab199d64f0 (diff) | |
download | gdb-4ee60495054b362530a7471d363e00143ecb5cbe.zip gdb-4ee60495054b362530a7471d363e00143ecb5cbe.tar.gz gdb-4ee60495054b362530a7471d363e00143ecb5cbe.tar.bz2 |
Fix gold to use mallinfo2 if available instead of deprecated mallinfo.
gold/
PR gold/26585
* configure.ac: Add check for mallinfo2.
* configure: Regenerate.
* main.cc (main): Use mallinfo2 if available.
Diffstat (limited to 'gold')
-rw-r--r-- | gold/ChangeLog | 7 | ||||
-rwxr-xr-x | gold/configure | 2 | ||||
-rw-r--r-- | gold/configure.ac | 2 | ||||
-rw-r--r-- | gold/main.cc | 9 |
4 files changed, 16 insertions, 4 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index 09e1fc5..bd23e15 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,10 @@ +2021-03-19 Duncan Simpson <dr.duncan.p.simpson@gmail.com> + + PR gold/26585 + * configure.ac: Add check for mallinfo2. + * configure: Regenerate. + * main.cc (main): Use mallinfo2 if available. + 2021-03-19 Cary Coutant <ccoutant@gmail.com> PR gold/27246 diff --git a/gold/configure b/gold/configure index e264a65..b9f062b 100755 --- a/gold/configure +++ b/gold/configure @@ -9967,7 +9967,7 @@ case "$ac_cv_search_dlopen" in esac -for ac_func in mallinfo posix_fallocate fallocate readv sysconf times mkdtemp +for ac_func in mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_cxx_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --git a/gold/configure.ac b/gold/configure.ac index eed4566..1716a77 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -636,7 +636,7 @@ case "$ac_cv_search_dlopen" in esac AC_SUBST(DLOPEN_LIBS) -AC_CHECK_FUNCS(mallinfo posix_fallocate fallocate readv sysconf times mkdtemp) +AC_CHECK_FUNCS(mallinfo mallinfo2 posix_fallocate fallocate readv sysconf times mkdtemp) AC_CHECK_DECLS([basename, ffs, asprintf, vasprintf, snprintf, vsnprintf, strverscmp, strndup, memmem]) # Use of ::std::tr1::unordered_map::rehash causes undefined symbols diff --git a/gold/main.cc b/gold/main.cc index ea77ca3..89bc40b 100644 --- a/gold/main.cc +++ b/gold/main.cc @@ -25,7 +25,7 @@ #include <cstdio> #include <cstring> -#ifdef HAVE_MALLINFO +#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) #include <malloc.h> #endif @@ -290,11 +290,16 @@ main(int argc, char** argv) elapsed.sys / 1000, (elapsed.sys % 1000) * 1000, elapsed.wall / 1000, (elapsed.wall % 1000) * 1000); -#ifdef HAVE_MALLINFO +#if defined(HAVE_MALLINFO2) + struct mallinfo m = mallinfo2(); + fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"), + program_name, static_cast<long long>(m.arena)); +#elif defined(HAVE_MALLINFO) struct mallinfo m = mallinfo(); fprintf(stderr, _("%s: total space allocated by malloc: %lld bytes\n"), program_name, static_cast<long long>(m.arena)); #endif + File_read::print_stats(); Archive::print_stats(); Lib_group::print_stats(); |