From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by sourceware.org (Postfix) with ESMTPS id 45137398B145; Fri, 26 Feb 2021 16:00:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 45137398B145 IronPort-SDR: M3tpqd/h/R6ir4FxNOUEpG8Ora1q1AYYngJRcizqkC1MrXaeLeIV6zaeP4an7TCnFaeNi5KdkG Wi0xdJDJUHSg== X-IronPort-AV: E=McAfee;i="6000,8403,9907"; a="270889252" X-IronPort-AV: E=Sophos;i="5.81,208,1610438400"; d="scan'208";a="270889252" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2021 08:00:07 -0800 IronPort-SDR: U08GS7O7gd9gBOQExusfCrrtrjgDSAHN4sAfzkscUjyuaunxUhcu1RYl5j7m3xH/JzmaIYjrRc L2g98yFow7AA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,208,1610438400"; d="scan'208";a="434413241" Received: from tjmaciei-desk.jf.intel.com (HELO tjmaciei-ctnr.jf.intel.com) ([10.54.75.8]) by fmsmga002.fm.intel.com with ESMTP; 26 Feb 2021 07:59:57 -0800 From: Thiago Macieira To: libstdc++@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org Subject: [PATCH 2/5] Atomic __platform_wait: accept any 32-bit type, not just int Date: Fri, 26 Feb 2021 07:59:34 -0800 Message-Id: <20210226155937.621324-2-thiago.macieira@intel.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210226155937.621324-1-thiago.macieira@intel.com> References: <1968544.UC5HiB4uFJ@tjmaciei-mobl1> <20210226155937.621324-1-thiago.macieira@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 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, 26 Feb 2021 16:00:10 -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/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..1c6bda2e2b6 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>; + = is_scalar_v> && 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