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 B36ED3858D28 for ; Fri, 6 Jan 2023 00:22:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B36ED3858D28 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=1672964562; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SEKUAzVPEhAjaVk/31uneWnphsgSJAdds3wJ3Goxcls=; b=Xze3Se/cRR1NSMwdi/3UYtSojHV8inbZxr61/PrFX/p2tdXVueaZE58bXSOfyy05CkhTG+ B1/6V55B9PYMiuCEscNO1flzZLq3G5yUEOwtR77FMoXNnphJE7XpBcFkszQPnbZs+Lm6Gr D3ggs/PJSRYPSbFwuZa8gtCCXRDxXao= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-221-kYYJvO4gMo2CgzQKg2fayw-1; Thu, 05 Jan 2023 19:22:40 -0500 X-MC-Unique: kYYJvO4gMo2CgzQKg2fayw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8DEA83C0CD39; Fri, 6 Jan 2023 00:22:40 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54C9549BB6A; Fri, 6 Jan 2023 00:22:40 +0000 (UTC) From: Jonathan Wakely To: Iain Sandoe Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org, Thomas Rodgers Subject: Re: [RFA] choosing __platform_wait_t on targets without lock-free 64 atomics Date: Fri, 6 Jan 2023 00:22:39 +0000 Message-Id: <20230106002239.102638-1-jwakely@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 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=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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