From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id D71C53858D34 for ; Thu, 23 Sep 2021 20:15:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D71C53858D34 Received: from mail-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-15-HjNWzJQKNpWI-ST-Hmq8QQ-1; Thu, 23 Sep 2021 16:15:21 -0400 X-MC-Unique: HjNWzJQKNpWI-ST-Hmq8QQ-1 Received: by mail-il1-f199.google.com with SMTP id o5-20020a92c685000000b0023832088b13so6460272ilg.13 for ; Thu, 23 Sep 2021 13:15:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mSgTGw6x83kkiX+bgwrek2qCET79AzMabzia8cly6+0=; b=vDQSISjLvj77+Pl3pOIn/OKOBPGigF+VtFfF5g/n/Sp5mPoFVeUo+5JxSYMR+Vk5bV TOiEon46WgJwMCqlIOwRN2X7jCtG91eFOx1CvfgUFL3RejFCBSsGG87mHjVqSfm+WQ5+ VTncuxO3Gw1fyc5fhhRFK0nlvzPGV38leDOiS4ocpQ1BzROuG5P+hAjpLN+Oq6q+gTQM qlW/KonxIrtNWTQ8LdyiW+Mo53wAT6UzdON8jK6OYppIX9UHfkKkHM1ofDI1GSAZL+yD D0+JdEb2NllqQN3SL5iG+s1bmKbRUS3aJNkzlyXwzidNVgZzr/iu+uuDPe8v4NJIn1Mh lQCw== X-Gm-Message-State: AOAM532gty+T2MoXLhYjAvLcAEVzdMeD08PGnIUM8VJaqluUrALoEbZR vDlF9ESS3iWxx7R075btaj7/u7mCsBhti75+IpyNFlrOS3/ifgPJJoyvXSTRDOIkXSR3khUlPBi /185JFVx+O2ppFeONSbCHjRCVkkE5t18= X-Received: by 2002:a05:6e02:1065:: with SMTP id q5mr5224066ilj.14.1632428120455; Thu, 23 Sep 2021 13:15:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSBm5Brxq9CyW9rcpJ1U3IakhiB3/W206AeGIIsVrc19MhwX8G9j7/NPflhgrJY7feL+cACKY+MX168u1H3qQ= X-Received: by 2002:a05:6e02:1065:: with SMTP id q5mr5224046ilj.14.1632428120247; Thu, 23 Sep 2021 13:15:20 -0700 (PDT) MIME-Version: 1.0 References: <20210923180837.633173-1-rodgert@appliantology.com> <20210923190708.GM304296@tucnak> In-Reply-To: <20210923190708.GM304296@tucnak> From: Thomas Rodgers Date: Thu, 23 Sep 2021 13:15:09 -0700 Message-ID: Subject: Re: [PATCH] libstdc++: Clear padding bits in atomic compare_exchange To: Jakub Jelinek Cc: Thomas Rodgers , gcc Patches , "libstdc++" , Thomas Rodgers X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2021 20:15:24 -0000 Agreed, I'll revise the patch to do so. On Thu, Sep 23, 2021 at 12:07 PM Jakub Jelinek wrote: > On Thu, Sep 23, 2021 at 11:08:37AM -0700, Thomas Rodgers wrote: > > From: Thomas Rodgers > > > > This change implements P0528 which requires that padding bits not > > participate in atomic compare exchange operations. All arguments to the > > Thanks for working on this. > > > generic template are 'sanitized' by the __builtin_clear_padding intrinsic > > before they are used in atomic compare_exchange. This alrequires that any > > stores also sanitize the incoming value. > > Not a review, just random nit. > Shouldn't the __builtin_clear_padding calls be guarded with > #if __has_builtin(__builtin_clear_padding) > or #ifdef _GLIBCXX_HAVE_BUILTIN_CLEAR_PADDING defined based on that? > I think clang doesn't support it (yet?), and it doesn't support the MSVC > __builtin_zero_non_value_bits (with very similar, but slightly different, > behavior). > > > Signed-off-by: Thomas Rodgers > > > > libstdc++=v3/ChangeLog: > > > > * include/std/atomic (atomic::atomic(_Tp) clear padding for > > __cplusplus > 201703L. > > (atomic::store()) Clear padding. > > (atomic::exchange()) Likewise. > > (atomic::compare_exchange_weak()) Likewise. > > (atomic::compare_exchange_strong()) Likewise. > > * testsuite/29_atomics/atomic/compare_exchange_padding.cc: New > > test. > > Jakub > >