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 BC0523858C66 for ; Thu, 12 Jan 2023 11:02:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC0523858C66 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=1673521324; 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=My3Hw5Ub/MBhsVlgZeiwd6v0ThvZgaKDBdofWnoQkFOyL96YahcDYXLtbAaNlL5983tLxs TNcdPyhtEUYDJsP4f/41CvYNLttZ7hTZnteUk+0HPqn9DR4GWUPlPAG7KwuXO55RDUqLXY mPrHIl22PxSxWvtFjXcd9vazkshxZMo= 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-180-OdJfUJULMU2jatesmC5OnQ-1; Thu, 12 Jan 2023 06:02:03 -0500 X-MC-Unique: OdJfUJULMU2jatesmC5OnQ-1 Received: by mail-lj1-f199.google.com with SMTP id b23-20020a05651c033700b0028473c6cc7bso3527981ljp.6 for ; Thu, 12 Jan 2023 03:02:02 -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=4NPrqgf9BBdU78NnnDbAXvSRuTnQvj1+pyR6BCSfViOb0JOHIwgTGWFq4PM5NA74ry JqMB/2FaKrtXm86dIZOKZmTMhzvQ3SuhG8kfZnpbhbVvRhKGy0CkMYb7DiPviosCRNk+ F234hv1PJ32kJj3F15aUC7hoIT9ERD25xqNZpobKgGw8jswLDh0nHMeW2/pd5Ij2XVIM 3c6927XHhqPKbRD/ATVGzV/7inwVdfSASGHgQ5hYaoQCkoeKThEmyO/lVbLEDxw+i5qP iWSkBp39gCFZNZP6fbXhGltsullp3/x+ccyFOTQX6QBKJ3+uxyEzLEq8DZywEZ/LiOUB H8vw== X-Gm-Message-State: AFqh2kpVZzGWRk52HRrzXiVokHeC+i3B66o/W0Lgb9Kl3PHOUZ0lKL+o YDZHB+2MdxgW42aTmPw9StVve8xJpNRz4EvfhDsOskep3kz6pvVXmlGfx4lcrnQz4mRSZdTL+J9 cY6uy14597FRUFDXLe1w9GXIHmtMJmH8= X-Received: by 2002:a05:651c:384:b0:27f:e894:685a with SMTP id e4-20020a05651c038400b0027fe894685amr2093591ljp.444.1673521321859; 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=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: 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 >>