From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by sourceware.org (Postfix) with ESMTPS id 5E21C3870851; Fri, 5 Mar 2021 18:21:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5E21C3870851 IronPort-SDR: VNzIb7d35fMWvZGxzGyWBc7+FFKga+v5bb8D5exncEZ4hBLVlEntAWTtenQNvYErO8WX/Z/bSf i4Hlw0U62J1g== X-IronPort-AV: E=McAfee;i="6000,8403,9914"; a="185296810" X-IronPort-AV: E=Sophos;i="5.81,225,1610438400"; d="scan'208";a="185296810" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2021 10:21:29 -0800 IronPort-SDR: zZo9nPtbEwrgzHKOTM6AJCGBpQwTmSAJJEgsLHo1m296FFRT7XfL3M5+hIYbTf/DyJXyw8fVeE HeGXtRDyvPMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,225,1610438400"; d="scan'208";a="587221827" Received: from tjmaciei-desk.jf.intel.com (HELO tjmaciei-ctnr.jf.intel.com) ([10.54.75.8]) by orsmga005.jf.intel.com with ESMTP; 05 Mar 2021 10:21:29 -0800 From: Thiago Macieira To: libstdc++@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 1/3] Atomic __platform_wait: accept any 32-bit type, not just int Date: Fri, 5 Mar 2021 10:21:26 -0800 Message-Id: <20210305182128.2071822-2-thiago.macieira@intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305182128.2071822-1-thiago.macieira@intel.com> References: <20210305182128.2071822-1-thiago.macieira@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org 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: Fri, 05 Mar 2021 18:21:32 -0000 The kernel doesn't care what we store in those 32 bits, only that they are comparable. This commit adds: * pointers and long on 32-bit architectures * unsigned * untyped enums and typed enums on int & unsigned int * float We're not using FUTEX_OP anywhere today. The kernel reserves 4 bits for this field but has only used 6 values so far, so it can be extended to unsigned compares in the future, if needed. libstdc++-v3/ChangeLog: * include/bits/atomic_wait.h: Update __platform_wait_uses_type --- libstdc++-v3/include/bits/atomic_wait.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/atomic_wait.h b/libstdc++-v3/include/bits/atomic_wait.h index 424fccbe4c5..4b4573df691 100644 --- a/libstdc++-v3/include/bits/atomic_wait.h +++ b/libstdc++-v3/include/bits/atomic_wait.h @@ -65,7 +65,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template inline constexpr bool __platform_wait_uses_type #ifdef _GLIBCXX_HAVE_LINUX_FUTEX - = is_same_v, __platform_wait_t>; + = sizeof(_Tp) == sizeof(__platform_wait_t) && + alignof(_Tp) >= alignof(__platform_wait_t); #else = false; #endif @@ -91,13 +92,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template void - __platform_wait(const _Tp* __addr, __platform_wait_t __val) noexcept + __platform_wait(const _Tp* __addr, _Tp __val) noexcept { for(;;) { auto __e = syscall (SYS_futex, static_cast(__addr), static_cast(__futex_wait_flags::__wait_private), - __val, nullptr); + static_cast<__platform_wait_t>(__val), nullptr); if (!__e || errno == EAGAIN) break; else if (errno != EINTR) -- 2.30.1