From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id ECBDA385801A; Thu, 23 Sep 2021 20:15:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org ECBDA385801A Received: by mail-wr1-x433.google.com with SMTP id i24so4678172wrc.9; Thu, 23 Sep 2021 13:15:57 -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=aUEQ01XfmKTmb8zqXsZ1AT1Mlotzro7bJulC5d+bcMM=; b=1ChkULLXW9OMfXx8+ZBDs658KssOp8csC1mVHDPGNDe4REFlo1PybFjpRyRvOUhP0I KXWJ6LVuJf1fHkhbejyLo9Sn/9uxKhB1ayiCqXCVv9nEI6zPUUjg2PV+wF7Q7YhDMl+/ EDoZbKSbMDxVGuQlCXvGNL+vFHnDtOMGR4DeLxuXQVJ5f+evRMKLp08qVYeOjk0WYB9s gfsMZpQ83rYEitnLOG3YlccCMlFdd8yeEaZfv/SMSgBENxF/T18G6gQlOs8oPUIzWXio ByhQ8eH7DrzKHaAWPOvmkw4zK/LNMGjpN2189+iawKsJ6D821noQqddmpkoiTnBS1Izq G8HQ== X-Gm-Message-State: AOAM533A6tYXco98RINAYt4+nFp/LWoYtx8aWH5J0KFA+DkybUQLjF2a piicOO6ojL8QIOxhbp3BiXpqamTnAJ6OWcsDygA= X-Google-Smtp-Source: ABdhPJyXDs7A6jWnx6/PJSfoqWU1sP8TtFgggcHdR7+55rRpoYWuIWf5zRfPxh2CXR+yooPc+MqaI15Td09AAMNDd8g= X-Received: by 2002:a5d:4481:: with SMTP id j1mr7483300wrq.6.1632428157097; Thu, 23 Sep 2021 13:15:57 -0700 (PDT) MIME-Version: 1.0 References: <20210923180837.633173-1-rodgert@appliantology.com> <20210923190708.GM304296@tucnak> In-Reply-To: <20210923190708.GM304296@tucnak> From: Jonathan Wakely Date: Thu, 23 Sep 2021 21:15:41 +0100 Message-ID: Subject: Re: [PATCH] libstdc++: Clear padding bits in atomic compare_exchange To: Jakub Jelinek Cc: Thomas Rodgers , Thomas Rodgers , "libstdc++" , gcc-patches , Thomas Rodgers X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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:59 -0000 On Thu, 23 Sep 2021, 20:07 Jakub Jelinek via Libstdc++, < libstdc++@gcc.gnu.org> 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? > Yes. It can just use __has_builtin directly. All the compilers we care about support that now. 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 > >