From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1720) id 5A1833858C74; Thu, 8 Sep 2022 19:21:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A1833858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662664890; bh=ITMf1dptW/i69XN8VTEAvoeINSWuuqabwy1kg8gpOOM=; h=From:To:Subject:Date:From; b=winzjg5JGhAhZJBinZxQJuc+EEzdJLodirDYv0M9PD+akOt9jA24+h1kRlfOG0RoD qGLQ4UHBofzK6nFeM56IdoW3Q3JtTYRXWw4u1S3fSEekvcW0eNopQP0yq4OGvE/fcs d8aXZCGWNF/IpKTYBl2uzSiHIlupBuW9P//M86a4= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: =?utf-8?b?RnJhbuCkpeCkiG9pcyBEdW1vbnQ=?= To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-2553] libstdc++: mallinfo deprecated, use mallinfo2 when glibc => 2.33 X-Act-Checkin: gcc X-Git-Author: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Git-Refname: refs/heads/master X-Git-Oldrev: 264deecb16abcfc8ca8efe9b94b0ad55febd55cc X-Git-Newrev: a0f83501182de68ff038f3c69da549e6c80bb6bd Message-Id: <20220908192130.5A1833858C74@sourceware.org> Date: Thu, 8 Sep 2022 19:21:30 +0000 (GMT) List-Id: https://gcc.gnu.org/g:a0f83501182de68ff038f3c69da549e6c80bb6bd commit r13-2553-ga0f83501182de68ff038f3c69da549e6c80bb6bd Author: François Dumont Date: Thu Sep 8 06:55:20 2022 +0200 libstdc++: mallinfo deprecated, use mallinfo2 when glibc => 2.33 glibc mallinfo is now deprecated resulting in make check-performance failure. When glibc => 2.33 prefer mallinfo2. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_performance.h (__gnu_test::MallocInfo): New. (__gnu_test::malloc_info): New, replace mallinfo on current platform supporting it and use mallinfo2 when glibc >= 2.33. Diff: --- .../testsuite/util/testsuite_performance.h | 63 +++++++++++----------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h index 2e05bef8460..4f8b1eab8b9 100644 --- a/libstdc++-v3/testsuite/util/testsuite_performance.h +++ b/libstdc++-v3/testsuite/util/testsuite_performance.h @@ -36,42 +36,39 @@ #include #if defined (__linux__) || defined (__GLIBC__) -#include -#elif defined (__FreeBSD__) -extern "C" -{ - struct mallinfo - { - int uordblks; - int hblkhd; - }; +#include // For mallinfo. +#endif - struct mallinfo - mallinfo(void) - { - struct mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 }; - return m; - } -} -#elif !defined (__hpux__) -extern "C" +namespace __gnu_test { - struct mallinfo + struct MallocInfo { - int uordblks; - int hblkhd; - }; + MallocInfo() : uordblks(0), hblkhd(0) { } + MallocInfo(std::size_t uordblocks, std::size_t hblockhd) + : uordblks(uordblocks), hblkhd(hblockhd) + { } - struct mallinfo empty = { 0, 0 }; + std::size_t uordblks; + std::size_t hblkhd; + }; - struct mallinfo - mallinfo(void) - { return empty; } -} + MallocInfo + malloc_info() + { +#if defined (__linux__) || defined (__hpux__) || defined (__GLIBC__) +#if __GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 33 + struct mallinfo2 mi = mallinfo2(); +#else + struct mallinfo mi = mallinfo(); +#endif + return MallocInfo(mi.uordblks, mi.hblkhd); +#elif defined (__FreeBSD__) + return MallocInfo((((std::size_t) sbrk (0) + 1023) / 1024), 0); +#else + return MallocInfo(); #endif + } -namespace __gnu_test -{ class time_counter { private: @@ -146,8 +143,8 @@ namespace __gnu_test int who; rusage rusage_begin; rusage rusage_end; - struct mallinfo allocation_begin; - struct mallinfo allocation_end; + MallocInfo allocation_begin; + MallocInfo allocation_end; public: resource_counter(int i = RUSAGE_SELF) : who(i) @@ -168,7 +165,7 @@ namespace __gnu_test if (getrusage(who, &rusage_begin) != 0 ) memset(&rusage_begin, 0, sizeof(rusage_begin)); void* p __attribute__((unused)) = malloc(0); // Needed for some implementations. - allocation_begin = mallinfo(); + allocation_begin = malloc_info(); } void @@ -176,7 +173,7 @@ namespace __gnu_test { if (getrusage(who, &rusage_end) != 0 ) memset(&rusage_end, 0, sizeof(rusage_end)); - allocation_end = mallinfo(); + allocation_end = malloc_info(); } int