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 ESMTPS id 1436E3858D35 for ; Thu, 12 Jan 2023 01:27:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1436E3858D35 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=1673486859; 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=AUZphxYXa9FbBhzOqxj3XVdfRN7IpRnXooqEOEX2sTY=; b=V/9/4IJaES/4SWZRHhMP6DMPELVfTAKW65QL5sLECnDzZQ5SJPXijVmeQhpChHdcGAo4Pa NF6ieYWlBCEq4jWo/2Kt2KG76yeRYT2t2cERTsfrmH+3wRw5rIimw1rKsd2yvuBeNMpE3v Eutzy7x9wFfYO3SmaiVmm+LVAKyyHW4= Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-645-ZKBid62vPKW2sEKOMLyCxA-1; Wed, 11 Jan 2023 20:27:38 -0500 X-MC-Unique: ZKBid62vPKW2sEKOMLyCxA-1 Received: by mail-pj1-f71.google.com with SMTP id h12-20020a17090a604c00b00225b2dbe4cfso7375828pjm.1 for ; Wed, 11 Jan 2023 17:27:38 -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=AUZphxYXa9FbBhzOqxj3XVdfRN7IpRnXooqEOEX2sTY=; b=vHWsaswmMMyzdiljIkXCpcyokWSMr3a2GBJQIYwTMxZVzlqMnlsPNQObXfnNp95srH hd+bI2AxvQBr18I6xuk/pa8nBu80OWJNJsKk41RTIENqW/DXSOU8UhBOu9bZ8ZGjcM3D ZkXjhBPBTbQI2p6YHvIon1EE6c6QGfjm9l2L2937pXL6cD0pFt4vVdu0typLldz8XPNY 29snBJUhFJELZ/RqUOrJbsJYhIoZeldvfxKM5KIQ5esoDQfFbWBvmXmwyLvWnuikCN/f oh2/O+ltPz+0l3LiyNS0TgacfGXGLOlMMTQttcMcHDIZpTL4CT/CfMRXP4Nm94Jglhvt BffA== X-Gm-Message-State: AFqh2krZCbiei6Ok9gksLU2RuwgRV4sHIcl6ZQvhgvtAAAcMdptg4ruS yxR6o4rC1iOXFLYC53FdIP5P216kc0ThRoS0A0uoSIYdRT9eA22lG3z0coKHhR/PjzmdCdjekjw XXAfIxRhOI4vb3dbaN2IYJu9C9y3JkEo= X-Received: by 2002:a63:1b53:0:b0:479:52c0:2e7a with SMTP id b19-20020a631b53000000b0047952c02e7amr3551540pgm.51.1673486857212; Wed, 11 Jan 2023 17:27:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXvTzu77ANhsDNTgG8Ss12tkWCjJJJxAZy6XYrnWZ78x2WxIdLDDH+diAuqHKDTNRGwoYcYzT2d5/65KUU+X7rU= X-Received: by 2002:a63:1b53:0:b0:479:52c0:2e7a with SMTP id b19-20020a631b53000000b0047952c02e7amr3551537pgm.51.1673486856854; Wed, 11 Jan 2023 17:27:36 -0800 (PST) MIME-Version: 1.0 References: <20230106002239.102638-1-jwakely@redhat.com> In-Reply-To: <20230106002239.102638-1-jwakely@redhat.com> From: Thomas Rodgers Date: Wed, 11 Jan 2023 17:27:26 -0800 Message-ID: Subject: Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics To: Jonathan Wakely Cc: Iain Sandoe , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000a3bc0205f2070530" X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,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: --000000000000a3bc0205f2070530 Content-Type: text/plain; charset="UTF-8" I agree with this change. 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 > > --000000000000a3bc0205f2070530--