From patchwork Wed Sep 7 17:02:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 1675356 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=NZfVmmgr; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MN7rJ4XP8z1yhd for ; Thu, 8 Sep 2022 03:03:44 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9335D384D181 for ; Wed, 7 Sep 2022 17:03:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9335D384D181 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662570222; bh=VcP4zpTrhpSVkoBKxk8UGI69DuM+tn2iM8+9ClSntRc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=NZfVmmgrnqhCf373eDyZ+QY4wn7mld6gWtSdQlkrpxU9vxfE5QxhJqVoEBPQYyHqj YAPUjuYiisP9H9nPcuJlxggrNGxox7pQpwF02cA51ZfCBqt/h0XL/UNoTGv1aQ+KKt qU1rQgNheWiEo075gOSR3rBBwNXjV2XL+NsmmJiI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 311FE3858D28; Wed, 7 Sep 2022 17:02:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 311FE3858D28 Received: by mail-ed1-x530.google.com with SMTP id r4so20644091edi.8; Wed, 07 Sep 2022 10:02:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=subject:from:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=VcP4zpTrhpSVkoBKxk8UGI69DuM+tn2iM8+9ClSntRc=; b=DQFWtG71hKZkGZmSmO9Mp5VFE7mMBepD2Bp1WfsZIV2VfF8qyOpZ67zd09Czo/DXB1 OFkjCEuyq8MLIJnV1OnLOd3OiPDpRRKrJXMiVDEXev/g0LAa/tCpwsyy5QOp3xgJQMos KmEvahdgLyVeGb2UN8/sonZUYnb9EntTxztlkOW8Pe9/om94B64bJK1mKwyAPjCY0uJF 9SBuAOfoB/sSh9313n65m7fwDirkwhI5emMpgf1+Ogs+Bex2+vwCMGrtelGsE3ixgiT1 lfWlXjx1JSnWA+nYhde0VGG9R3miZUVPRajYhoQKzExp5nCoZHQBb+yqbpztS70VwzPA kx7Q== X-Gm-Message-State: ACgBeo040/5Ec8/GmLRszQWPO+3N9TReYKiAHoQ4ljQcpWzuZzvJh/bO YZfpenT3sipl3iZtxfYGG60l5BvCk5l3ig== X-Google-Smtp-Source: AA6agR7hGJn4k5r0CypUd8ZYO3RwRsMRy9T4C+AGlQra9Id7J9iVKa3QymDpdOeeWZXjOL/T2rXgPA== X-Received: by 2002:a05:6402:1771:b0:44e:e4ec:1b1c with SMTP id da17-20020a056402177100b0044ee4ec1b1cmr3899352edb.231.1662570164544; Wed, 07 Sep 2022 10:02:44 -0700 (PDT) Received: from [10.49.1.93] ([109.190.253.15]) by smtp.googlemail.com with ESMTPSA id fi5-20020a170906da0500b0076f0ab594e9sm2916768ejb.73.2022.09.07.10.02.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Sep 2022 10:02:43 -0700 (PDT) Message-ID: Date: Wed, 7 Sep 2022 19:02:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: fr To: "libstdc++@gcc.gnu.org" Subject: [PATCH] Use mallinfo2 with glibc >= 2.33 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fran=C3=A7ois_Dumont_via_Gcc-patches?= From: =?utf-8?q?Fran=C3=A7ois_Dumont?= Reply-To: =?utf-8?q?Fran=C3=A7ois_Dumont?= Cc: gcc-patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" libstdc++: Use glibc >= 2.33 mallinfo2 function mallinfo started to be deprecated which makes performance tests failed to build, just adopt mallinfo2. libstdcxx-v3/ChangeLog:         * testsuite/util/testsuite_performance.h (__mallinfo): New, our own mallinfo         struct with just what we need. When using glibc >= 2.33 use mallinfo2 to         populate it. Tested under Linux x86_64, Ok to commit ? François diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h index 2e05bef8460..dc002b8c390 100644 --- a/libstdc++-v3/testsuite/util/testsuite_performance.h +++ b/libstdc++-v3/testsuite/util/testsuite_performance.h @@ -35,37 +35,49 @@ #include #include -#if defined (__linux__) || defined (__GLIBC__) -#include -#elif defined (__FreeBSD__) extern "C" { - struct mallinfo + struct __mallinfo { - int uordblks; - int hblkhd; + size_t uordblks; + size_t hblkhd; }; +} - struct mallinfo - mallinfo(void) +#if defined (__linux__) || defined (__GLIBC__) +#include +extern "C" +{ + struct __mallinfo + __mallinfo(void) + { +#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 33 + struct mallinfo2 mi = mallinfo2(); + struct __mallinfo m = { mi.uordblks, mi.hblkhd }; +#else + struct mallinfo mi = mallinfo(); + struct __mallinfo m = { mi.uordblks, mi.hblkhd }; +#endif + return m; + } +} +#elif defined (__FreeBSD__) +extern "C" +{ + struct __mallinfo + __mallinfo(void) { - struct mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 }; + struct __mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 }; return m; } } #elif !defined (__hpux__) extern "C" { - struct mallinfo - { - int uordblks; - int hblkhd; - }; - - struct mallinfo empty = { 0, 0 }; + struct __mallinfo empty = { 0, 0 }; - struct mallinfo - mallinfo(void) + struct __mallinfo + __mallinfo(void) { return empty; } } #endif @@ -146,8 +158,8 @@ namespace __gnu_test int who; rusage rusage_begin; rusage rusage_end; - struct mallinfo allocation_begin; - struct mallinfo allocation_end; + struct __mallinfo allocation_begin; + struct __mallinfo allocation_end; public: resource_counter(int i = RUSAGE_SELF) : who(i) @@ -168,7 +180,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 = __mallinfo(); } void @@ -176,7 +188,7 @@ namespace __gnu_test { if (getrusage(who, &rusage_end) != 0 ) memset(&rusage_end, 0, sizeof(rusage_end)); - allocation_end = mallinfo(); + allocation_end = __mallinfo(); } int