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.133.124]) by sourceware.org (Postfix) with ESMTPS id B7EA13858D35 for ; Thu, 12 Jan 2023 11:02:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7EA13858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673521326; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8lXK+x5sbTw5XUllCI35Kkn/7Yi4acdmxhmV8ISobYY=; b=iCDCca7KY1peNA0J+LaibcBmLgY3GLL0mnqt8814xy8vsdN5Gyn6ZI8UlHkTUexZQ5EfzE 2S4p3oyaGDzHoqVzsoraAoygJAcGk/v6ovy/15tuQCGJJwVYKJZdSobYmGB6SFWoXOHxU9 hsXER1lpSkWEkLFCGswU4BKKQ8GiRm4= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-18-PDD1tktiOA6D0gR3Sb8ebw-1; Thu, 12 Jan 2023 06:02:03 -0500 X-MC-Unique: PDD1tktiOA6D0gR3Sb8ebw-1 Received: by mail-lj1-f199.google.com with SMTP id b11-20020a05651c0b0b00b0028248aa29a5so4464983ljr.19 for ; Thu, 12 Jan 2023 03:02:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8lXK+x5sbTw5XUllCI35Kkn/7Yi4acdmxhmV8ISobYY=; b=cu5zGrckqXd5FsqYLaJorOWfQ4xavDmc0RZB4aH5WWpnNnNd0Ig5jVc/cT+KkbK2mZ 7zwEalsQlWOrD1M30EgrLTcNRiV3HeUo9DzbNleccKaRVKz2Et+jA3tR0IZLDA8ThKMw C/VCzp3P1/02P+zprZ/3qolKsnbtplWXHesxqgEdFYbA6P46/9hlZd9tlrsMBANCqOpD Q2i9PRYXByulJXmL6M5lEYcsVqxXeIDWLkjuo8i2gC3+BhnddKmAX/G+ke09+0rW24Z/ DWL3bjMy+7LQGGcoWv83gTqgsvYjaxrsW85y2vynmLSMBEEZRZl2SDslJHQN4KEiFF01 7c2w== X-Gm-Message-State: AFqh2kochRzf31lwBUwNY9kpm+ands79OCFoVuDN6siz+mYOjE+SVzlI F7LqLfYYkRI9D3wZXLlS3bsqbecwMuxDQVnGeshQRe40fIEV9Jfg6AZpUNuhahsZ59gCDOLfq+M wW38Gm11UM6En1VEl6TomqKcoOqKUvUfIEg== X-Received: by 2002:a05:651c:384:b0:27f:e894:685a with SMTP id e4-20020a05651c038400b0027fe894685amr2093593ljp.444.1673521321999; Thu, 12 Jan 2023 03:02:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOjyPPRcKUAtQUX+pdbx4yMFvpugBnw5v6RwfJuyoeeBWrpaxhqt/F2AepiQukauoIb0NuXF8tJnPS2rxR57c= X-Received: by 2002:a05:651c:384:b0:27f:e894:685a with SMTP id e4-20020a05651c038400b0027fe894685amr2093589ljp.444.1673521321605; Thu, 12 Jan 2023 03:02:01 -0800 (PST) MIME-Version: 1.0 References: <20230106002239.102638-1-jwakely@redhat.com> In-Reply-To: From: Jonathan Wakely Date: Thu, 12 Jan 2023 11:01:50 +0000 Message-ID: Subject: Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics To: Thomas Rodgers Cc: Iain Sandoe , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 12 Jan 2023 at 01:27, Thomas Rodgers wrote: > > I agree with this change. Thanks, pushed to trunk. > > On Thu, Jan 5, 2023 at 4:22 PM Jonathan Wakely wrote: >> >> How about this? >> >> I don't think we should worry about targets without atomic int, so don't >> bother using types smaller than int. >> >> >> -- >8 -- >> >> For non-futex targets the __platform_wait_t type is currently uint64_t, >> but that requires a lock in libatomic for some 32-bit targets. We don't >> really need a 64-bit type, so use unsigned long if that is lock-free, >> and int otherwise. This should mean it's lock-free on a wider set of >> targets. >> >> libstdc++-v3/ChangeLog: >> >> * include/bits/atomic_wait.h (__detail::__platform_wait_t): >> Define as unsigned long if always lock-free, and unsigned int >> otherwise. >> --- >> libstdc++-v3/include/bits/atomic_wait.h | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h >> index bd1ed56d157..46f39f10cbc 100644 >> --- a/libstdc++-v3/include/bits/atomic_wait.h >> +++ b/libstdc++-v3/include/bits/atomic_wait.h >> @@ -64,7 +64,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> // and __platform_notify() if there is a more efficient primitive supported >> // by the platform (e.g. __ulock_wait()/__ulock_wake()) which is better than >> // a mutex/condvar based wait. >> - using __platform_wait_t = uint64_t; >> +# if ATOMIC_LONG_LOCK_FREE == 2 >> + using __platform_wait_t = unsigned long; >> +# else >> + using __platform_wait_t = unsigned int; >> +# endif >> inline constexpr size_t __platform_wait_alignment >> = __alignof__(__platform_wait_t); >> #endif >> -- >> 2.39.0 >>