From patchwork Mon Oct 24 23:24:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617896 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3036110pvb; Mon, 24 Oct 2022 16:26:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7TQ9QJh1hxlDtwZqqwMskETV9+n/2Au5Jdog33YZJv+8WSou0yoshzHIZZCJBHJRLxWyWx X-Received: by 2002:a05:6214:2505:b0:4bb:8927:872e with SMTP id gf5-20020a056214250500b004bb8927872emr379647qvb.93.1666653985804; Mon, 24 Oct 2022 16:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653985; cv=none; d=google.com; s=arc-20160816; b=iKV/xL+SAPvuDjxE+MWD/aI2CLitAQdMjBrISSe8SM4Ex6qZRZIsT7bLNkOyN7hNTm 1MFyfS+AfEUHnd3cuVx0vskz10/UxX2Yu3Lbio/T1aVWmDHu2ULsfVMzgoOHylL5+4AC 82/3kIzfHADIOvESYe5gJ0vxhHXdgGjA6mYZokSvug9fJFKiV7YpZOJLaAsxs6oaq8ml nDm8nH4/raHh+3u857PQHNZC9lOZONHVe/Bag7gk1mpLgTJ+eOkLXRydCp0BmL8tdcis /yuUuKlXYHKZ4PHS8/Kweu4taeKuAEZtcOuRrTIX+QT457a8XBGsY4FieHN+99picqdN IEdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=+GpEWM3LySgqJhgOZJqGlQkMf1hRDDzweYduhNP71iI=; b=UY4c+QDeoCodl4ahXEgHK0V2yAl0YOyOShX8M1nXlX++F8CLQ9sgDn8zbFuBErnGDe oS65Uzl42PziUDg8vwRGlP+/tzqnJ5Q9Ya080zQvnkaPfdFirOTJ77qGMOmw0xi7pY8Y bedrBE2x52OM8hRkrN4mZHWobxjBrmwwvl7LddMWHuI0e1IKyUex9yYsu+vgF4aEJFot E2uhXGNTniQ3V5Sa1yBoSf5o6uIy/TC/zXv+5pnOu1lqhN5UkrkKfHKfDtl1BWSi3c8W XyYKK60W57K8PTfXEup1eU4BJIQtJJ1o4BLEv5xGci4Ksh7l/3BqFMTFnUUHqAlYwnrY QjWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DW2qvZUv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y13-20020a37f60d000000b006eebcbb03besi723746qkj.462.2022.10.24.16.26.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Oct 2022 16:26:25 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DW2qvZUv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on6oJ-0007eo-CB; Mon, 24 Oct 2022 19:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on6oI-0007XV-J4 for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:46 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on6oH-0000DG-0N for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:46 -0400 Received: by mail-pf1-x434.google.com with SMTP id i3so10246515pfc.11 for ; Mon, 24 Oct 2022 16:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+GpEWM3LySgqJhgOZJqGlQkMf1hRDDzweYduhNP71iI=; b=DW2qvZUvdPN7M870Ke26svL/iB6HUMxw0a8Wm6cE4NracKGo7qDWWNlgtsokZL8Zc0 MxOjfv2VhSrn2ir6vlxEhqYP9Yyczt3f1QKjeYDQKw+KMnANsymajDRigacw6d4R3sIG mopyypehe6ysvN8GLAH7FIE0fSh1VH6q7pU1bIMCsJMEOanMQFrMAfiuoEQLAAlxj3va qRalfrpO2VEmPIVgMn5rDm6RaV3LUfVzl3hLHz2Q89QKCYRfxPQ7s0S+IocEvBl+cYKj fLOAPKXaRKdvQBWNfAMOJw6ovJIGuwSX23zdFGZhj1whnOMm/i0W2obSUP80FdKGghWC vaTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+GpEWM3LySgqJhgOZJqGlQkMf1hRDDzweYduhNP71iI=; b=qB8GLTVzfkYf6svfwaeVhNeqVTmZaDZGWEkwJMX+Na4Zpcq2HKmmif65ZAc7xaKcif Y0ekJd3JAq144Bif9Wwu3Jgm0lktmGNKS+xy4HeLYBH+mRvSf88OhXhIGfQ7Rtt0xYPO 2AyzsMAgFO6mOoPDAzoPKIk6KwRB8Mz4oOB6/LegSZgKK2YVfQQUfBWUXh8GNLKQ5YHO Jpf8dN93a5zCUP4/3VDn4SB6UZOC8Gm3vmbJzwb0mEDNm+3j5Fjkc4qvbRpjZHyBK0CE UFhHIc8t7KM6/FgWJtYz8/0J1fU1iTIIvT+hdxo4y/59cB3TqASoKWYh49s8C2As5W16 ztnA== X-Gm-Message-State: ACrzQf39Lw0C+uqZPyoYSuiqPg+0mZrFziWxziJF6wcRaqv03MC46p0y sOwk0BQXtErII8MazsvuFHuIogklj2plKw== X-Received: by 2002:a62:19cd:0:b0:56b:6a55:ffba with SMTP id 196-20020a6219cd000000b0056b6a55ffbamr17266097pfz.85.1666653883393; Mon, 24 Oct 2022 16:24:43 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id k3-20020aa79983000000b0056bfa2cf517sm324788pfh.3.2022.10.24.16.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 16:24:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/4] include/qemu/osdep: Add qemu_build_assert Date: Tue, 25 Oct 2022 09:24:32 +1000 Message-Id: <20221024232435.3334600-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024232435.3334600-1-richard.henderson@linaro.org> References: <20221024232435.3334600-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org This differs from assert, in that with optimization enabled it triggers at build-time. It differs from QEMU_BUILD_BUG_ON, aka _Static_assert, in that it is sensitive to control flow and is subject to dead-code elimination. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/osdep.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index b1c161c035..2276094729 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -186,6 +186,14 @@ void QEMU_ERROR("code path is reachable") #define qemu_build_not_reached() g_assert_not_reached() #endif +/** + * qemu_build_assert() + * + * The compiler, during optimization, is expected to prove that the + * assertion is true. + */ +#define qemu_build_assert(test) while (!(test)) qemu_build_not_reached() + /* * According to waitpid man page: * WCOREDUMP From patchwork Mon Oct 24 23:24:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617895 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3036088pvb; Mon, 24 Oct 2022 16:26:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6lVOygyxmyDnkHYYKlBPZNqmeoghFIy0fhIiWFxpBuW4qfNeTPABsC+O4q5wwVQZoetw6O X-Received: by 2002:a05:620a:44c6:b0:6ee:7a7a:93d1 with SMTP id y6-20020a05620a44c600b006ee7a7a93d1mr24179163qkp.256.1666653983064; Mon, 24 Oct 2022 16:26:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653983; cv=none; d=google.com; s=arc-20160816; b=Hb/azwcHO6Kx0RrroztQpXlKjLONYl/JnbLfTXKU9o8jc4gsfHvlyCShfZVQYQfY/r g9f+UlNgyS3IhhS2SqTn10bTstFbBAa4Vhtx/OE+uRRwq0ynxoLDeQrY5/CxFbICCCJu XadRaOg9uIjDYrul6kHOTCKW68fjr+QC15zJYfHUmG+Vpdt37hXw9UezLcLnXXWhpeoC CC425hdmoym418ShDiMkS1FqSOH/DnPw5RVaiLOdkZfBYn5nV2vRbgZ8OcDEiFAwpPNj R8UrjOReOffd/DLpAM/qFLwfaHvZM2jfUcFlBzPgta+dA7iNW13kgr/vfzUppsSjNsXT 5tOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=PvLfshUVxQ9Mypl80D0uVTHRSLnGuXN+L2Mxf0dBkyM=; b=FDPEfaF1T09LQ+XdVoG1pQGsF8G+RpzlCSvH1UIOkyQF0RY11O4jQ/PKieKGOaM6dI aOE7iX3BNc4HzjYiJ/110bIDs4Q/s9ajS3rNfaMEVhUjoRU3y2dBRNR9sVpUBOitDBy4 q4G3YnrgpTgMcdsjhkiVoOHzQUeEGNe1jVyYgfwhNFMbe4A8VIUkofNpsO4zFQc4+9zv aKvMB0Kj3L0NUy8dQaUWt9suMIX7SsF6U4W3IbkOsUR7+8dPVRN9dGG1Il3hUp6PZ9hy Z7Fdi3LTobPS7PbSo0wQGLNPBmZ1lcFW69eevQvRgk4mq/Ryv9Z2gzNMBWk1YayRgImS V8zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vXkHP2Th; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iw4-20020a0562140f2400b00496b42cd3f4si829184qvb.456.2022.10.24.16.26.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Oct 2022 16:26:23 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vXkHP2Th; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on6oW-0001PE-I4; Mon, 24 Oct 2022 19:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on6oV-00010e-7w for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:59 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on6oT-0000GB-Ir for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:58 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-1322fa1cf6fso13674505fac.6 for ; Mon, 24 Oct 2022 16:24:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=PvLfshUVxQ9Mypl80D0uVTHRSLnGuXN+L2Mxf0dBkyM=; b=vXkHP2Thfh04B9MGPzzuXTBR7b6ZuCb8nAdr8CIhk0h/oBOPxheJnfTM93tqPJC+Dk V2w98U8XNP26Zw+UfSAQR0aD7nGkQk8mVz9VK/lG53leoyEy0KDYz1hObnHh5lZamaX6 w6he8a7+f3uYbQmobhLiN1G2eQoIDaugQefEgqZc1/cGK9fFEpvZdDKlF/1EUrQKH9xR Dw56YrxTBiyv+NX6k1Db+e4wCf6MY70sbZx4Xn8wSUpfG0KEP+JoMyIwF6AIK7/U3Rt6 Vc22fVbF5u2ygYxXAxPHpZIuGUMcwL0BpLP5kNXiMKjncnyIUk7b1IE+nrHH+Ghi5aKT yrtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PvLfshUVxQ9Mypl80D0uVTHRSLnGuXN+L2Mxf0dBkyM=; b=dNoWjwQxC5I+fcr4sGHRnEILbi/IRO7xkzsSkXHRphGQKVjeEnG4QzBCWEKbGSdRPS CkPMl2/H6K0E/C9KB8fpONeYNB21/OATp6BZX1v+qDZ3jAqD7N8PxGKmXUqEIlzhtHv7 vEOwo7fw/QvrohrpE5LQJy9hUf8HtZel+W+Bs9IslDpja8+Ppj5kw5gBoz5ecJTzHiBu D33DmgLFHRMbFxoQn3Hxe5yve3ErggkUWzRc+HiWEYAH+mKDhtHVf+m7N7KAavMkODcP fdR5btK8ic0f10X3Up5ihMHquX6RmNjYNN8njU8OYePkpskRwjFuOoQEe+sg9mATZRnV Ylxw== X-Gm-Message-State: ACrzQf1Mm427YlBfzxAc7O+rpGNR+ZdPmbI8l+SvBMgLoRoWqbJZOKUK XkxPiKR9LCOlhuuFoCLS2YXHksUwvBOs7Q== X-Received: by 2002:a17:90b:1808:b0:20c:8409:2007 with SMTP id lw8-20020a17090b180800b0020c84092007mr41585623pjb.226.1666653885712; Mon, 24 Oct 2022 16:24:45 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id k3-20020aa79983000000b0056bfa2cf517sm324788pfh.3.2022.10.24.16.24.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 16:24:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/4] include/qemu/atomic: Use qemu_build_assert Date: Tue, 25 Oct 2022 09:24:33 +1000 Message-Id: <20221024232435.3334600-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024232435.3334600-1-richard.henderson@linaro.org> References: <20221024232435.3334600-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x29.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Change from QEMU_BUILD_BUG_ON, which requires ifdefs to avoid problematic code, to qemu_build_assert, which can use C ifs. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- include/qemu/atomic.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 7e8fc8e7cd..874134fd19 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -133,7 +133,7 @@ #define qatomic_read(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ qatomic_read__nocheck(ptr); \ }) @@ -141,7 +141,7 @@ __atomic_store_n(ptr, i, __ATOMIC_RELAXED) #define qatomic_set(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ qatomic_set__nocheck(ptr, i); \ } while(0) @@ -159,27 +159,27 @@ #define qatomic_rcu_read(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ typeof_strip_qual(*ptr) _val; \ qatomic_rcu_read__nocheck(ptr, &_val); \ _val; \ }) #define qatomic_rcu_set(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ __atomic_store_n(ptr, i, __ATOMIC_RELEASE); \ } while(0) #define qatomic_load_acquire(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ typeof_strip_qual(*ptr) _val; \ __atomic_load(ptr, &_val, __ATOMIC_ACQUIRE); \ _val; \ }) #define qatomic_store_release(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ __atomic_store_n(ptr, i, __ATOMIC_RELEASE); \ } while(0) @@ -191,7 +191,7 @@ }) #define qatomic_xchg(ptr, i) ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ qatomic_xchg__nocheck(ptr, i); \ }) @@ -204,7 +204,7 @@ }) #define qatomic_cmpxchg(ptr, old, new) ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <= ATOMIC_REG_SIZE); \ qatomic_cmpxchg__nocheck(ptr, old, new); \ }) From patchwork Mon Oct 24 23:24:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617894 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3036071pvb; Mon, 24 Oct 2022 16:26:20 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CWu3yStMfSsz27FM/fZkAYIXFwGGcu7dOsJQvWx/3Cr8lYMYfg8O8ovvOOjppvOTsHGoH X-Received: by 2002:a05:622a:591:b0:39c:f3c8:117c with SMTP id c17-20020a05622a059100b0039cf3c8117cmr29835489qtb.270.1666653980638; Mon, 24 Oct 2022 16:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653980; cv=none; d=google.com; s=arc-20160816; b=U7Xx3PrcvEPr1g878ofpTgFzD7NEwEykqmDWv4NuwU+zFczqvo/GPcB7lgqnDZG+R+ 7ukT98D1dI0OXJjtgofvRF6agmFRmh8Y/XVi1388YIibnEPx9q+ML3yIY2qB0Q9FS1mj tDnJIpCGhRVE18IlHsEPUcExTgbu1g75/Kl40eAEBzK7RHD9KfPYNgOAi2d0yoCilxjl XuAgQTtRDcvP0mjkiCdApTHKX5iQk9Ld2xzyZuZmoHKPhhNlWhCZ3kIWi35LTCV2dYw4 ewPR1WZpNyjxQc739gppnZDIUtrT0eRQwEDkuF4R4ajrd+e2aJqVptFADngK5WskluMx i/tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=RsEIfxD+OlYFT9OI+wvS42/nayZLR/Rh+gxaS68HxWbiL1MA5iLuq5W78eR4BYxMX3 blDENveRJRM7wNBnCdpbavY6a6NlcM0P+o5QpSlktTLgi7VNUZJ93bilzSpgdBaOfXTE lc92ztgO5BI/2Mny67ZPrJRT1bm5jNscaxBSUI3ArUCz7Eb0CwUgkeCbp/MkhzpW99Y/ ZPMHjs3DW+YRDvQRXIZ2ATlC7TDwjeIMqHp0iMWVgZp0oKWKFXCoZyzZqRyNubFCH1AK 2aIxZVTy2t11bBDs3jPcfhVhbKGos4F30FPxT+8ktEEIaeh0Uk3f5O4cDvPNx361oes2 MeNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=th02GPJz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r13-20020a056214212d00b004b799333465si812050qvc.482.2022.10.24.16.26.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Oct 2022 16:26:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=th02GPJz; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on6oS-0000fi-S1; Mon, 24 Oct 2022 19:24:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on6oP-00008D-UI for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on6oL-0000F4-AV for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: by mail-pl1-x635.google.com with SMTP id j12so9742762plj.5 for ; Mon, 24 Oct 2022 16:24:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=th02GPJzxhvyjQqh/DI514LqgLPG5l5afg+cE66ZxkF58AfCb46aBuVzv2VWzlEw0y JmcGlI9XiNTrgVZtG8x7hd4aCuqTGIZkTCC0+SLgDOToRD9LiDKM899xcH5TbJ7FDVId GhlkITIP/jdTDM1Zc6ZVPffekqc8Mg+W1daqdMzw2g3NqNyrm1NI1f9z0VonwYwkjrer fy2UMYrTK6CnyoEbC2yQnbVDTH7o3gAeHoc72u/BogW60jOQtw9xrOAq1SdCkB2YXF30 oV47tRWq4xWcnLjdMuP366+Wr36USKMQ3qdZyTBTZX74r0WWO1qlPpmIrZCkFSjzqsle rXjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=K2CVuuBiPH9ErDh0CXmpJ8YMBs6RgohbMHDMEo1fOpKy7vMHvj02u/PvuPIfcEUWPM 3yGabhgaX1E0CH00rRuv4eQhFjg0/Q+k7pdJCgOZNnSczqHNbRYGteTKJcZEDE6OpDsX 3G/tMO9uXrJTER7jSV8gv96q8pnWSUCVqDk3PYQ46nIioqcMHiyzxy3cacqx5T7I5jHT RMrHuTQp5DBdbHeYXXorhia5Ny/0zLhjj7ViaLu1knJEPU2HXH1NhWFCagFF6tDa6vLp soh8Kj8zVMn2HTelpwIOPkL6Ci1Vd5hBDZeWxD2DWNBOKRQQvCCf3o8LmiH9dzlIQ+d3 XPIA== X-Gm-Message-State: ACrzQf33SRy/RHThIrxo3VFfjuX4PVqYTInUuVQlgdUmuhct9zjGQIuW gReKIy+U9npCuxRhztIaDOvln/cUvliDIQ== X-Received: by 2002:a17:902:d484:b0:17f:7437:565d with SMTP id c4-20020a170902d48400b0017f7437565dmr35518531plg.154.1666653887892; Mon, 24 Oct 2022 16:24:47 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id k3-20020aa79983000000b0056bfa2cf517sm324788pfh.3.2022.10.24.16.24.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 16:24:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/4] include/qemu/thread: Use qatomic_* functions Date: Tue, 25 Oct 2022 09:24:34 +1000 Message-Id: <20221024232435.3334600-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024232435.3334600-1-richard.henderson@linaro.org> References: <20221024232435.3334600-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x635.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Use qatomic_*, which expands to __atomic_* in preference to the "legacy" __sync_* functions. Signed-off-by: Richard Henderson --- include/qemu/thread.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/qemu/thread.h b/include/qemu/thread.h index af19f2b3fc..976e1ab995 100644 --- a/include/qemu/thread.h +++ b/include/qemu/thread.h @@ -227,7 +227,7 @@ struct QemuSpin { static inline void qemu_spin_init(QemuSpin *spin) { - __sync_lock_release(&spin->value); + qatomic_set(&spin->value, 0); #ifdef CONFIG_TSAN __tsan_mutex_create(spin, __tsan_mutex_not_static); #endif @@ -246,7 +246,7 @@ static inline void qemu_spin_lock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_lock(spin, 0); #endif - while (unlikely(__sync_lock_test_and_set(&spin->value, true))) { + while (unlikely(qatomic_xchg(&spin->value, true))) { while (qatomic_read(&spin->value)) { cpu_relax(); } @@ -261,7 +261,7 @@ static inline bool qemu_spin_trylock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_lock(spin, __tsan_mutex_try_lock); #endif - bool busy = __sync_lock_test_and_set(&spin->value, true); + bool busy = qatomic_xchg(&spin->value, true); #ifdef CONFIG_TSAN unsigned flags = __tsan_mutex_try_lock; flags |= busy ? __tsan_mutex_try_lock_failed : 0; @@ -280,7 +280,7 @@ static inline void qemu_spin_unlock(QemuSpin *spin) #ifdef CONFIG_TSAN __tsan_mutex_pre_unlock(spin, 0); #endif - __sync_lock_release(&spin->value); + qatomic_store_release(&spin->value, 0); #ifdef CONFIG_TSAN __tsan_mutex_post_unlock(spin, 0); #endif From patchwork Mon Oct 24 23:24:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 617893 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3035833pvb; Mon, 24 Oct 2022 16:25:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AeaEWbJioSjfAy0FVSCDdVbTjVMkAkmC0dxQxQ7YcqSeEBHocL0LjlpxwHhbYc1N4YKbJ X-Received: by 2002:a05:622a:1b8e:b0:39c:ec9e:46c0 with SMTP id bp14-20020a05622a1b8e00b0039cec9e46c0mr29338987qtb.329.1666653944201; Mon, 24 Oct 2022 16:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666653944; cv=none; d=google.com; s=arc-20160816; b=qB2a97YAwRbpMnKiW7PSXjmpEE9U4AKajw3KYmHrn2hwocOVfwKHhKG5mieBMBEN7w W5foobVmTktqP1DyUNxQtlmiDJL1SJvJda5mdIQXMC09iGxkex5tTGEg73b+Fj25vlkB NBcvmQo66+Sw7h/LjH7e+luTkAxfcl4TCcshS+IgoFIQAoJOC7wCYZi5k4HQUBPvNNfp niwEJO2EmGGs2itki1y+TIN+tkLWLmmT+TYjEUSxDoBTTPHt3+chb6UL1O3pK5DymEbr Hi8sYiP7qQraYHf3oXtojxwTTnt3axahmgpkMlxRuQKrt9SfqCADnxL805kohy5HVgBH wOQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ZKPPwqUM3u9rEDoyh08pEPXNUD2eKrireqQWX4VXiQY=; b=fGnEdNPEwl6ikb4niDiDMAHD0nGg/jM/Ij+g8j4GgwR1bSBWEPQyjgUOQqeDSP4r4O E7FX5vmr/VWkypvS2BNFFmlopm8La1ooxvVUi7R35MKz5o4gOqk/QoLcoxcOsrkD4BA4 SB42wwCNEzpb3iD/rQhe1lFZoH0icH+ydau/EE3QkumVAx7oysT24HiwxTZMOOjSTRvY +sgRvOJRG8wkOFoEcG+QMbN+z1YHB42b8eijd5XkLWqnaMiAp7ZVbx3lkqRDYV6vq5jk dt25Di8Y0BBSCtzVORZrKlIwKAHBcYw1GCFyAgG3fd/EL/j5lQlNSi1Tt2fW1hmX0XGB dZwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2sE8Y6s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hr14-20020a05621423ce00b004aaaad81dffsi864602qvb.199.2022.10.24.16.25.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Oct 2022 16:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a2sE8Y6s; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1on6oR-0000Qt-9F; Mon, 24 Oct 2022 19:24:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1on6oP-0008WE-MI for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1on6oO-0000FL-4H for qemu-devel@nongnu.org; Mon, 24 Oct 2022 19:24:53 -0400 Received: by mail-pj1-x102b.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so4926102pjc.3 for ; Mon, 24 Oct 2022 16:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ZKPPwqUM3u9rEDoyh08pEPXNUD2eKrireqQWX4VXiQY=; b=a2sE8Y6sh/8LHZaXz/+TmN4Kozz2XmqhrJ7pCN3CvcRRk6VgKNC2k+Se5jkudwjTUk 16YCYvzZGAWyBGDLvelgmsZOj/m2A7bOY2YloCZyc0o98gIBFWcP8DhM/StxToHOC+EB 7Tycn5ZlUV/qE2hrVc5gmmjCWEqbzkP1YNh20SbbLqX+Xj5V+gOehi07X57UnRDAWiyO UBccLnQ3Q6++enxVh2cVKlwbo70ZDcCRCRAyqOeBvwOeBjN9fx1l4vTbNMwCuQQGJ/aL hvcPTAuUbA6AS6+rhbr5ZChEXp6n9p1goXNY5KXFa9HAt69zFLxDPKphrUxMJdcvPAjp xIig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZKPPwqUM3u9rEDoyh08pEPXNUD2eKrireqQWX4VXiQY=; b=bkYrYt9Q0kLPYsZu4cRJ1W909Fj2vAAI8jlnUkDCNl3WlRIFUajdhiFwt82XbrM7/v tooVFNVTTkmPgHmxKmcmx3FhADqk5DeF2K6MruIrfISjdLpw3fymEHN66qxuWF13a/rG lF27KSByeVXbg9/EDehvsM8yxP50vPEzXhyQx4F9Yyn12jXxUEFf+KaJLVG8HRTMNeYu to5X+/FSrcNexG4Sfx73W+zEDhJNPMuwfNJyP9co8CKCCNzRbev1tAxGUeD1JAVkKfGD QyUW/sQH4/jpnlWvoVxMhPgmPe9HFSKd0a/mHwFbiAyb/UideslKlqEy8vVa/cpM3FEs CpSg== X-Gm-Message-State: ACrzQf0vrB0qcgtYYUNMc7KLGLMqwjbhwkrZrPNc3+ja8VlrrolQ5Zj4 0fKweWvCkzKnPDEjhaz7hHZAAqZU6/MIfg== X-Received: by 2002:a17:902:eccd:b0:186:5d25:ec5a with SMTP id a13-20020a170902eccd00b001865d25ec5amr27747326plh.93.1666653890059; Mon, 24 Oct 2022 16:24:50 -0700 (PDT) Received: from stoup.. ([103.100.225.182]) by smtp.gmail.com with ESMTPSA id k3-20020aa79983000000b0056bfa2cf517sm324788pfh.3.2022.10.24.16.24.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Oct 2022 16:24:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/4] include/qemu/atomic128: Avoid __sync_val_compare_and_swap_16 Date: Tue, 25 Oct 2022 09:24:35 +1000 Message-Id: <20221024232435.3334600-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221024232435.3334600-1-richard.henderson@linaro.org> References: <20221024232435.3334600-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Merge the CONFIG_ATOMIC128 and CONFIG_CMPXCHG128 cases with respect to atomic16_cmpxchg and use __atomic_compare_exchange_nomic (via qatomic_cmpxchg) instead of the "legacy" __sync_val_compare_and_swap_16. Update the meson has_cmpxchg128 test to match. Signed-off-by: Richard Henderson --- include/qemu/atomic128.h | 8 +------- meson.build | 3 ++- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/include/qemu/atomic128.h b/include/qemu/atomic128.h index adb9a1a260..ec45754515 100644 --- a/include/qemu/atomic128.h +++ b/include/qemu/atomic128.h @@ -41,18 +41,12 @@ * Therefore, special case each platform. */ -#if defined(CONFIG_ATOMIC128) +#if defined(CONFIG_ATOMIC128) || defined(CONFIG_CMPXCHG128) static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) { return qatomic_cmpxchg__nocheck(ptr, cmp, new); } # define HAVE_CMPXCHG128 1 -#elif defined(CONFIG_CMPXCHG128) -static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) -{ - return __sync_val_compare_and_swap_16(ptr, cmp, new); -} -# define HAVE_CMPXCHG128 1 #elif defined(__aarch64__) /* Through gcc 8, aarch64 has no support for 128-bit at all. */ static inline Int128 atomic16_cmpxchg(Int128 *ptr, Int128 cmp, Int128 new) diff --git a/meson.build b/meson.build index 1ec3f72edc..d8c4e76e7b 100644 --- a/meson.build +++ b/meson.build @@ -2224,7 +2224,8 @@ if has_int128 int main(void) { unsigned __int128 x = 0, y = 0; - __sync_val_compare_and_swap_16(&x, y, x); + __atomic_compare_exchange_n(&x, &y, x, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED); return 0; } ''')