From patchwork Sat Jul 17 01:41:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 479221 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1942920jao; Fri, 16 Jul 2021 18:43:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyevDjI2O2JC7WFVu0BzJ/gTUeh5EoQMZ9/OeHfbVYkOkKEfks8vQ8NR3IdzmRk8fQ3IsCm X-Received: by 2002:a05:6214:312:: with SMTP id i18mr13339463qvu.55.1626486198169; Fri, 16 Jul 2021 18:43:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626486198; cv=none; d=google.com; s=arc-20160816; b=mHSN66BGCR+mQeyek3bVkuNcz8D9tudryQPYy6v1xtooj2q3SLFWqOByXbL/Yh3SiN rkRjzuTQgM3pN0TLn3nmdtHr8VQlWGHZtOqCw8P7ZtJXSb5grM3HKpF1lE0hdyFMul9X stQacDRmbHlPv5GMQY0H1038VTNwxLN0oWjX/nxMvKjGAmh130SdzwXpGlHlfd0Bw3xf hcgSdY2FON/6dCTE+nfTIVKEXMEX9hYBTP35K+yKTs0S/lBs/YMCNA/IJV/+S2oXUmHs H4oEUhy6lv4ybny6HBm+FzAJyFNgr48UZjnuyC3e88y2IDfzAtHrP5VRvq268tmQAOMv w37A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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=jzyzTgwtvr8cL7SL4244DrybGOaLuPJ3lUTmoddAPyo=; b=fOky20VnnI2ueSDJDF3SlT48dBp95k17rBnYt7P/V44mQi+yQXyq2bAApgX65RxKmN 7t4maW88IsXXgzXy3JiofLLz/c9khzWLfRAtVnAZqp3JBBycocZJUXQmUouGpcnuspBJ Rf44qLrX2xVbHsfiid9skK+3Py+iwyqmvqEq/mADmILBm9FPGddtYknaiVf+XqTG22CN rF63IND0TcMnNEYm4Rsu/DG3F1ayJFt0/E20TyTzEoyS2jTOBX/yUjCsizKBmtRvhYSZ Ekx8b6uXPrOyA0hCTn2JILfKPXNEoz2lmFC7cbuTxl4+idbj+R+7lu5TwcpgD9Ox92mI HY3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kZ0GuNGl; 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=fail (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 c14si8970232qtd.299.2021.07.16.18.43.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 16 Jul 2021 18:43:18 -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=fail header.i=@linaro.org header.s=google header.b=kZ0GuNGl; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:47544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m4ZML-0006HE-Ib for patch@linaro.org; Fri, 16 Jul 2021 21:43:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m4ZKa-0000pn-3d for qemu-devel@nongnu.org; Fri, 16 Jul 2021 21:41:28 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]:33512) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m4ZKY-0000xL-50 for qemu-devel@nongnu.org; Fri, 16 Jul 2021 21:41:27 -0400 Received: by mail-pg1-x529.google.com with SMTP id 37so11776330pgq.0 for ; Fri, 16 Jul 2021 18:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jzyzTgwtvr8cL7SL4244DrybGOaLuPJ3lUTmoddAPyo=; b=kZ0GuNGlRX3/NNO9jcWNw3WHsC8H/iZ8ZJyj7RbBNMafCfL+kOBHn3vFB6RYdAJZj/ qWjzBRf5lfpNYHBUdo4BAp1sC1nIYoO7LSFXPYQ2JHn3KBshzX98E4Zoa806ufgzlPQp l/LZ69DNm7nBhrHQibCS2aaj+yeleQ87JvlBF67xRiMeqPDwwT/baZn203dogGX8PWC+ YL6/UuIUOwAuNkgLalqAJjFAM4xp+w0fPJ6pTZyLK6D34i0jfeH3JM+HSBuZfWqDV9Ga igLyiRtQTdbig0+rFZq3UTEJ/3gdk5cHG2ssVz9+IW7XDmyEAHSOEX9SR7tHW5GbyEYA 5BxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jzyzTgwtvr8cL7SL4244DrybGOaLuPJ3lUTmoddAPyo=; b=Lg9QRYwiLUwqgiE+j0SDdQP+4+kz63l8MES4XqJtS6+alUUErHtzS0m4oEEcicjVtg Si+8vbjpt8gTigz6hh1hF0Iz2JYBL95dLeDepzS5b0M4btNexnqsIKUMK/LFriD9iotg Mm5ds6MccU6EK27fVH/Xk4++JF+dWoNO0KmGjX4JZyRAASw0X4ZFToPuajeeyBoLrGDX iweD65949XT9udi9/pPXX5UfnlfiTsreaT8xdkMSqb5TdaH5B55URVTPyN+AIRlItrRk TNKK2uRCs1RWEL2gAXT6hctUyTzdTBwLUJV9/oFXP8KR1xUmJslYgXjCFI0U61tCpHjh 4Utg== X-Gm-Message-State: AOAM531M7dmS/WP7mi6r4OO28CbxMBRirlKgH6hBzMD8NBNLoh0zhceH 8Fx033+g/jJgxjXjRkl8BIcTh8870Zbcvg== X-Received: by 2002:aa7:9626:0:b029:32a:f13b:7ab3 with SMTP id r6-20020aa796260000b029032af13b7ab3mr13319386pfg.43.1626486084651; Fri, 16 Jul 2021 18:41:24 -0700 (PDT) Received: from localhost.localdomain ([71.212.149.176]) by smtp.gmail.com with ESMTPSA id q18sm12812738pgj.8.2021.07.16.18.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Jul 2021 18:41:24 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 02/11] qemu/atomic: Simplify typeof_strip_qual Date: Fri, 16 Jul 2021 18:41:12 -0700 Message-Id: <20210717014121.1784956-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210717014121.1784956-1-richard.henderson@linaro.org> References: <20210717014121.1784956-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::529; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x529.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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, pbonzini@redhat.com, crobinso@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The right-hand side of the comma operator has the type quals stripped without also undergoing implicit promotion. Signed-off-by: Richard Henderson --- include/qemu/atomic.h | 41 ++++------------------------------------- 1 file changed, 4 insertions(+), 37 deletions(-) -- 2.25.1 diff --git a/include/qemu/atomic.h b/include/qemu/atomic.h index 99d6030095..55d75fc757 100644 --- a/include/qemu/atomic.h +++ b/include/qemu/atomic.h @@ -18,47 +18,14 @@ /* Compiler barrier */ #define barrier() ({ asm volatile("" ::: "memory"); (void)0; }) -/* The variable that receives the old value of an atomically-accessed +/* + * The variable that receives the old value of an atomically-accessed * variable must be non-qualified, because atomic builtins return values * through a pointer-type argument as in __atomic_load(&var, &old, MODEL). * - * This macro has to handle types smaller than int manually, because of - * implicit promotion. int and larger types, as well as pointers, can be - * converted to a non-qualified type just by applying a binary operator. + * Handle this by evaluating an expression involving the comma operator. */ -#define typeof_strip_qual(expr) \ - typeof( \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(typeof(expr), bool) || \ - __builtin_types_compatible_p(typeof(expr), const bool) || \ - __builtin_types_compatible_p(typeof(expr), volatile bool) || \ - __builtin_types_compatible_p(typeof(expr), const volatile bool), \ - (bool)1, \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(typeof(expr), signed char) || \ - __builtin_types_compatible_p(typeof(expr), const signed char) || \ - __builtin_types_compatible_p(typeof(expr), volatile signed char) || \ - __builtin_types_compatible_p(typeof(expr), const volatile signed char), \ - (signed char)1, \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(typeof(expr), unsigned char) || \ - __builtin_types_compatible_p(typeof(expr), const unsigned char) || \ - __builtin_types_compatible_p(typeof(expr), volatile unsigned char) || \ - __builtin_types_compatible_p(typeof(expr), const volatile unsigned char), \ - (unsigned char)1, \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(typeof(expr), signed short) || \ - __builtin_types_compatible_p(typeof(expr), const signed short) || \ - __builtin_types_compatible_p(typeof(expr), volatile signed short) || \ - __builtin_types_compatible_p(typeof(expr), const volatile signed short), \ - (signed short)1, \ - __builtin_choose_expr( \ - __builtin_types_compatible_p(typeof(expr), unsigned short) || \ - __builtin_types_compatible_p(typeof(expr), const unsigned short) || \ - __builtin_types_compatible_p(typeof(expr), volatile unsigned short) || \ - __builtin_types_compatible_p(typeof(expr), const volatile unsigned short), \ - (unsigned short)1, \ - (expr)+0)))))) +#define typeof_strip_qual(expr) typeof((void)0, (expr)) #ifdef __ATOMIC_RELAXED /* For C11 atomic ops */