From nobody Sat May 18 06:31:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666653987; cv=none; d=zohomail.com; s=zohoarc; b=Q3nJFWB6baOqNSXZnYIWV+Eg09jU27AD2B8LgopAITxbFdT2csmZnwjJpIU3xYSLOYigMxMvDtrROGxRESyCoRGG4EJF5Q3M/JsN4+ILa+tA976U92GaFq7cKFmIQF9xcJR6sJlMiT/NA9fciTufaPEB0c/krAAwH3FiJPbeiwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666653987; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+GpEWM3LySgqJhgOZJqGlQkMf1hRDDzweYduhNP71iI=; b=Enge5hC2JfB+keJ4cdpfPsoMoecdifZ3MC48yV/EQlO+pePpnGd80OoCL9fRyeIu4fGIwv6tNZpzwfrfFHW0SsNlNh9ApvDXmikEC6Sc5H/XYd6zGTnRBTOuywchNvsibofT7KBHon2VDaBxQUXL4Z/wpNp2BNCCPtsFSLbxb1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666653987217973.1845826286235; Mon, 24 Oct 2022 16:26:27 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AMsMyM53I2DSaO/iXHdoFwS5V/I1LRxcTDYWgelbHtDWKrH81a2r95jDp5nOxEpxxggt3t4nJD0JAw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666653988370100003 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 =20 +/** + * 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 --=20 2.34.1 From nobody Sat May 18 06:31:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666653983; cv=none; d=zohomail.com; s=zohoarc; b=SymywRFIYUKXPYFi4cF4q3EX9qpjSmfN41z6FghRS3n5Q7jmCWt/wTU9sWYbArdQNui4QJ2eOZf7vu3mZdFYdjj5uDBLViNkoaNapMoHi5694e2qsPKH08Uu28VBMpW2o7tNk1JJ4wT3lS2/3BKT7soaOn+BTPTS8I05ABFzmiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666653983; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PvLfshUVxQ9Mypl80D0uVTHRSLnGuXN+L2Mxf0dBkyM=; b=Xw8/H0GucxZ1B6/X2SGrwWLXIIUTKMDv+zZpFUTlSTG021Lhd3norMMsW+nOxJeBOO0d88TQshh6yaZN0DcZmWizkiVeyQ0R+FA9SBZAnAxNsl+aTRl2T23aT3oBj/QnNCEDQQgyNl1tSt8Xlob4GeDqk8ApNTqnXRe34KfXiX0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666653983738368.89821443165; Mon, 24 Oct 2022 16:26:23 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AMsMyM5RUZepWlplJEQy9WfSyrY6x37shLv2/p0zn4df/+lFZvICJ881buJao3wC1Jhnym0uCQMedw== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666653984365100007 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- 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 @@ =20 #define qatomic_read(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ qatomic_read__nocheck(ptr); \ }) =20 @@ -141,7 +141,7 @@ __atomic_store_n(ptr, i, __ATOMIC_RELAXED) =20 #define qatomic_set(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ qatomic_set__nocheck(ptr, i); \ } while(0) =20 @@ -159,27 +159,27 @@ =20 #define qatomic_rcu_read(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ typeof_strip_qual(*ptr) _val; \ qatomic_rcu_read__nocheck(ptr, &_val); \ _val; \ }) =20 #define qatomic_rcu_set(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ __atomic_store_n(ptr, i, __ATOMIC_RELEASE); \ } while(0) =20 #define qatomic_load_acquire(ptr) \ ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ typeof_strip_qual(*ptr) _val; \ __atomic_load(ptr, &_val, __ATOMIC_ACQUIRE); \ _val; \ }) =20 #define qatomic_store_release(ptr, i) do { \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ __atomic_store_n(ptr, i, __ATOMIC_RELEASE); \ } while(0) =20 @@ -191,7 +191,7 @@ }) =20 #define qatomic_xchg(ptr, i) ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ qatomic_xchg__nocheck(ptr, i); \ }) =20 @@ -204,7 +204,7 @@ }) =20 #define qatomic_cmpxchg(ptr, old, new) ({ \ - QEMU_BUILD_BUG_ON(sizeof(*ptr) > ATOMIC_REG_SIZE); \ + qemu_build_assert(sizeof(*ptr) <=3D ATOMIC_REG_SIZE); \ qatomic_cmpxchg__nocheck(ptr, old, new); \ }) =20 --=20 2.34.1 From nobody Sat May 18 06:31:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666653981; cv=none; d=zohomail.com; s=zohoarc; b=ERM5CG+LaPnzbnrz9XZFsz5gSzlPGgvtnKIzi2d+c9LEJ/R3XAA3vxCM4dkAQzXqvSQDDa97y6NoePPyYiixpbeQutkYqX+wDBL2jDajgtdim4RbIyqs4IByi3AL8fLZFQkedeMGAW4MqC3H1syX71ZpvcOgO38SxY0xrKuhczg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666653981; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LJ+JQv3dsaa9WWtb7Vu+unKKfyu5T/tcB60KushyFxs=; b=mn306TkdQ6ZkU7JYDpkhs2cj/hBK9r44ePGpokRDLTHg/OPwoSussjyJFcl67HieWnU8C1zPDpZrCkjyJFyYvYOmagnqkxOHgcPoGlYCCSFDGBD01/QgWuXLU6hZhC+chYUp+bKtVRHrpXefqeVbiMbgjTLwd9tK9W4pBCWJelY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666653981151609.3176218792128; Mon, 24 Oct 2022 16:26:21 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AMsMyM6/9JFyx5xXWhnPerH3Y+sfydMdvh38OuKOfiS92lDuOOCHWpeUyE8WxztiSaL6CIBb9oLmzg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666653982346100001 Content-Type: text/plain; charset="utf-8" Use qatomic_*, which expands to __atomic_* in preference to the "legacy" __sync_* functions. Signed-off-by: Richard Henderson Acked-by: Paolo Bonzini --- 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 { =20 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 =3D __sync_lock_test_and_set(&spin->value, true); + bool busy =3D qatomic_xchg(&spin->value, true); #ifdef CONFIG_TSAN unsigned flags =3D __tsan_mutex_try_lock; flags |=3D 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 --=20 2.34.1 From nobody Sat May 18 06:31:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1666653945; cv=none; d=zohomail.com; s=zohoarc; b=ikt6WShQMo7PAVpqT86CubF0duSYX1Cyh2knRsaXf51jqCxerymsQN+okryrMwWu2I6KrEog/nNv/MVEwKqsiPwb/duQnMQSSU7HQZDH4zyjpGL5d7IHbXao8lnmwZDpYSlL884CoXalRBTWfqfdOQ/k8lL3wX5gHkbWXUhxLTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666653945; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZKPPwqUM3u9rEDoyh08pEPXNUD2eKrireqQWX4VXiQY=; b=LCupWEMKBNI3gClPd/2Wr2PM7KDvhRVSz1AGpmFJaJ9lMlAKwtwr2/fENeK5nnklYOs6GT22mKQ2sFIfjo5eqDMOOAiuW5h1rEwSktfeNs+9ZN0lPCbknkWrmVWofsJ8l27jYHGNYC7Uy8KFr6Ke0iUwyD9MVqCv21ILvQIOieE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666653945027951.5083717539743; Mon, 24 Oct 2022 16:25:45 -0700 (PDT) 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) 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) 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-Google-Smtp-Source: AMsMyM5cuLO+GCCvJtbyebxYlj61AmyezxuUKEMyvKazZiHWjTbzY4rg7NC3jtk+XSr2afBxahCXOg== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1666653946206100001 Content-Type: text/plain; charset="utf-8" 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 Acked-by: Paolo Bonzini --- 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. */ =20 -#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 =3D 0, y =3D 0; - __sync_val_compare_and_swap_16(&x, y, x); + __atomic_compare_exchange_n(&x, &y, x, 0, + __ATOMIC_RELAXED, __ATOMIC_RELAXED); return 0; } ''') --=20 2.34.1