From 18528c416f23be7dafe4a9bf631c91b6cbb3e0cb Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 2 Sep 2020 15:17:25 +0200 Subject: [PATCH] mallinfo2: add missing bits The patch adds the function to Versions and both tests now test the function. The function is also mentioned in NEWS. --- NEWS | 5 ++++- malloc/Versions | 3 +++ malloc/tst-malloc-tcache-leak.c | 17 +++++------------ malloc/tst-mxfast.c | 12 ++---------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/NEWS b/NEWS index 06e43e0453..b21e5244ab 100644 --- a/NEWS +++ b/NEWS @@ -20,9 +20,12 @@ Major new features: The 32-bit RISC-V port requires at least Linux 5.4, GCC 7.1 and binutils 2.28. +* A new function mallinfo2 (replaces mallinfo) uses size_t for values returned + in mallinfo2 struct. + Deprecated and removed features, and other changes affecting compatibility: - [Add deprecations, removals and changes affecting compatibility here] +* Function mallinfo is deprecated. Changes to build and runtime requirements: diff --git a/malloc/Versions b/malloc/Versions index 2357cff3da..94c8ba8040 100644 --- a/malloc/Versions +++ b/malloc/Versions @@ -64,6 +64,9 @@ libc { GLIBC_2.26 { reallocarray; } + GLIBC_2.33 { + mallinfo2; + } GLIBC_PRIVATE { # Internal startup hook for libpthread. __libc_malloc_pthread_startup; diff --git a/malloc/tst-malloc-tcache-leak.c b/malloc/tst-malloc-tcache-leak.c index 2a7a0646c5..ae5e1fd252 100644 --- a/malloc/tst-malloc-tcache-leak.c +++ b/malloc/tst-malloc-tcache-leak.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -61,7 +60,7 @@ static int do_test (void) { pthread_t *thread; - struct mallinfo info_before, info_after; + struct mallinfo2 info_before, info_after; void *retval; /* This is an arbitrary choice. We choose a total of THREADS @@ -73,15 +72,11 @@ do_test (void) pthread_t required to run the test. */ thread = (pthread_t *) xcalloc (1, sizeof (pthread_t)); - /* The test below covers the deprecated mallinfo function. */ - DIAG_PUSH_NEEDS_COMMENT; - DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); - - info_before = mallinfo (); + info_before = mallinfo2 (); assert (info_before.uordblks != 0); - printf ("INFO: %d (bytes) are in use before starting threads.\n", + printf ("INFO: %ld (bytes) are in use before starting threads.\n", info_before.uordblks); for (int loop = 0; loop < threads; loop++) @@ -91,8 +86,8 @@ do_test (void) free (retval); } - info_after = mallinfo (); - printf ("INFO: %d (bytes) are in use after all threads joined.\n", + info_after = mallinfo2 (); + printf ("INFO: %ld (bytes) are in use after all threads joined.\n", info_after.uordblks); /* We need to compare the memory in use before and the memory in use @@ -109,8 +104,6 @@ do_test (void) if (info_after.uordblks > (info_before.uordblks + threads)) FAIL_EXIT1 ("Memory usage after threads is too high.\n"); - DIAG_POP_NEEDS_COMMENT; - /* Did not detect excessive memory usage. */ free (thread); exit (0); diff --git a/malloc/tst-mxfast.c b/malloc/tst-mxfast.c index 8afee0f9d5..0a41e1112c 100644 --- a/malloc/tst-mxfast.c +++ b/malloc/tst-mxfast.c @@ -21,13 +21,12 @@ the fast bins. */ #include -#include #include int do_test (void) { - struct mallinfo m; + struct mallinfo2 m; char *volatile p1; char *volatile p2; @@ -37,14 +36,7 @@ do_test (void) p2 = malloc (512); free (p1); - /* The test below covers the deprecated mallinfo function. */ - DIAG_PUSH_NEEDS_COMMENT; - DIAG_IGNORE_NEEDS_COMMENT (4.9, "-Wdeprecated-declarations"); - - m = mallinfo (); - - DIAG_POP_NEEDS_COMMENT; - + m = mallinfo2 (); /* This will fail if there are any blocks in the fastbins. */ TEST_COMPARE (m.smblks, 0); -- 2.28.0