From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id E69451F61A for ; Mon, 12 Dec 2022 14:16:44 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kQybVoh8"; dkim-atps=neutral Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84BBD3856B41 for ; Mon, 12 Dec 2022 14:16:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84BBD3856B41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1670854603; bh=eh5AkMFzBw5V6r7NkdUv188mWeTgImxo7CG6QxBypHQ=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=kQybVoh8+bnhHhraJh1uBtv9/iZxoyJHyt/dGgEEFRCYtBLrusFmvNHyReSUPenrK XHLk3ax0RvyyhFUC9NowBBNmdpHYx4TPtwW7W3kKSEo0/eCBycWkT8hxfm522cLJBS xTkLocH18XMsk7TZPfXNDlLW4F+9J/Qw9JTFYQo4= Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id E6D803856B40 for ; Mon, 12 Dec 2022 14:16:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E6D803856B40 Received: by mail-ot1-x32a.google.com with SMTP id p10-20020a9d76ca000000b0066d6c6bce58so7342870otl.7 for ; Mon, 12 Dec 2022 06:16:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eh5AkMFzBw5V6r7NkdUv188mWeTgImxo7CG6QxBypHQ=; b=YLu9YIEK9pAMS9PvIBqaFQcocb9JboBUJvFFn+oTIkPBZCVRQNGtSCztzJ0pIoOPS3 jZGlLSpCae4ZTbOCzCWJMgHNXFuG0wunKpd5gLUotg/w3JDkJBMaTlCSy8uIx+DICx7a f4/cMIL/UTI4BAG/hNOj5PRrsG+T2jWXPtqx9wLrU6jyTZgnQMr3uYMKHRjVx3bWNds7 2UFLDSBQkNUHxeMVZIh9A0eLiY/A7lfNbtjYPMBA3rEM3lVngbplNO/UteOTsZlQQzVd UtvSexL+jpicbW15hD0AEHOg9KAbvGIdA+j1EDSgiJL48DQJR+fg4F3k1fKrEsVypa81 HpSw== X-Gm-Message-State: ANoB5pl9/yW7f/IQzsq9F85NX4ZjhrjiXiDLbA4PYRqt3qUdlevp+DYE R2g793Aqj6Nv8KDFvifZIc05mA== X-Google-Smtp-Source: AA0mqf5W9Gkdz1f1bBSZsiO9CoeoTWQG3x3DgFZTD2ZZTVlUnRPxTCG/BCt0dIC4aIqgEaL/6HbO8Q== X-Received: by 2002:a9d:7552:0:b0:670:98f6:67b6 with SMTP id b18-20020a9d7552000000b0067098f667b6mr1499373otl.23.1670854580158; Mon, 12 Dec 2022 06:16:20 -0800 (PST) Received: from [192.168.15.31] (201-92-181-161.dsl.telesp.net.br. [201.92.181.161]) by smtp.gmail.com with ESMTPSA id h26-20020a9d6f9a000000b00670641eb272sm4141086otq.20.2022.12.12.06.16.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Dec 2022 06:16:19 -0800 (PST) Message-ID: <0c14b424-af63-a5ec-5545-ef79bd323058@linaro.org> Date: Mon, 12 Dec 2022 11:16:16 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions Content-Language: en-US To: Florian Weimer Cc: Adhemerval Zanella via Libc-alpha , Fangrui Song References: <20221115193159.173838-1-adhemerval.zanella@linaro.org> <20221115193159.173838-5-adhemerval.zanella@linaro.org> <874ju0ubs0.fsf@oldenburg.str.redhat.com> <87iligsone.fsf@oldenburg.str.redhat.com> Organization: Linaro In-Reply-To: <87iligsone.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Adhemerval Zanella Netto via Libc-alpha Reply-To: Adhemerval Zanella Netto Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On 12/12/22 11:05, Florian Weimer wrote: > * Adhemerval Zanella Netto: > >>> I think you should consider introducing a call_free_static_weak that >>> does something like >>> >>> if (&ptr != NULL) >>> free (ptr); >>> >>> in the static case, and calls >>> >>> free (ptr); >>> >>> unconditionally for the dynamic case. And then add attribute_hidden >>> variable declarations to a suitable wrapper header under include/. >>> >>> This avoids writing all these little helper functions. >> >> We already have call_free_static_weak function that does exactly that, > > I don't see call_free_static_weak? > >> maybe you are proposing a something like: >> >> # ifdef SHARED >> # define declare_libc_freeres (name, ptr) \ >> static void name (void) { free (ptr); } >> # else >> # define declare_libc_freeres (name, ptr) \ >> static void name (void) { if (ptr != NULL) free (ptr); } >> # endif > > It has to be &ptr != NULL for the weak case, and you also need to create > a weak alias. Right, and do we really need a weak_alias in this fact? Wouldn't weak_function suffice in this case for !SHARED?