From nobody Fri Oct 31 16:05:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1746449239; cv=none; d=zohomail.com; s=zohoarc; b=dweQ6Dd1deMPQcCTRXxRrcu9dGbuOhzhRknIOyF7FH1sOtx3pHnH7qK38qr6uMBWPWqL8FAqMlw62UB4PJ01bPomBKTATx4Lh6CcsW3Ai1/CINEmaF+2sduJeoSEiuNznaSQd87LJkINv7jCsbVaoLvGrKUbCR9SGwJzSQWlTJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1746449239; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=P+VL0wqxMqE1quEoDvljUttyjHUDK003gdW4PwSJ+m8=; b=IiMK5qJQefuwjmRMYKlPZmcEaTGE/VWponfxuTsYrwRcCrkez3zz5n7ynOLaq5i9rIlID5wPjaG81CL5b3fw8wWlylQ5qT6UqmMreitwV+j/WtyIq1QPwPitCHOu084tNtLraWKl7MOcI6yAPqgdidK9c+iuyC+J0MFMsKGrEmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1746449239176429.8664678148342; Mon, 5 May 2025 05:47:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.976096.1363330 (Exim 4.92) (envelope-from ) id 1uBvDf-0004oM-LM; Mon, 05 May 2025 12:46:51 +0000 Received: by outflank-mailman (output) from mailman id 976096.1363330; Mon, 05 May 2025 12:46:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBvDf-0004oF-Ik; Mon, 05 May 2025 12:46:51 +0000 Received: by outflank-mailman (input) for mailman id 976096; Mon, 05 May 2025 12:46:50 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uBvDe-0004o9-10 for xen-devel@lists.xenproject.org; Mon, 05 May 2025 12:46:50 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 02884c22-29af-11f0-9eb4-5ba50f476ded; Mon, 05 May 2025 14:46:48 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-39c1ef4ae3aso2551342f8f.1 for ; Mon, 05 May 2025 05:46:48 -0700 (PDT) Received: from localhost.localdomain (host-92-26-98-202.as13285.net. [92.26.98.202]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a099ae79d8sm10137329f8f.42.2025.05.05.05.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 May 2025 05:46:47 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 02884c22-29af-11f0-9eb4-5ba50f476ded DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1746449208; x=1747054008; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=P+VL0wqxMqE1quEoDvljUttyjHUDK003gdW4PwSJ+m8=; b=qJ2fjmS1JTUeH0kKyZOkyAD4gMHwIPSTuQJdi0Qb0hCe6LAnAp+qegZulrxHbGaFea RKJJnHeb3b2acB1UWAXOiEl49S+86+fznuNUtyHQHZxQWhDCoVE3iI1+U5hsioSRzq9O nV4NYJ/fJvOG8ftC84fGmVSHHxXiYZsKhjdvU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746449208; x=1747054008; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P+VL0wqxMqE1quEoDvljUttyjHUDK003gdW4PwSJ+m8=; b=cosly43sICDw22605ny9asthTJBvh3B0030goA9k5o0Wu9B1Xoag27gvSatyIQ23sY dN8PrZWmPUwVFpWdv2IUyrPDFW+4idc6Z7LuL3pNei4Up4VYY0IXN6G7EwaLvvQMLYOL iCdZqct9UJyY5pjKZsWJh0a3Pi2D6u1C2GlkvblFq4u/PwT2badSmuwJdcTNZeKLkue4 O6gVdrwR29M51jGLXAfexCXQMcxHnowvFbPrrtVS947p7gp5TiJ0SXqV2WdIKCR/lmeM UobehU36WrEk1eEauHj1CEw7Ae5clSzlzhDi9obX0H/27UbLo3lUlM9WoucSa7hRBvpl 9NbA== X-Gm-Message-State: AOJu0YzHE9j24vFXQSr7eyKLYgw+7qQ4iZ/iDcuDm+XahY/bOs9W4l/b B4hV8cCBtrKd9GJvbUsmvfneb+LWqbyzTI5orltyoX7BdY/5Klzr+Z0CDsoEc9Dm/3Vfc5KTuOc /DdI= X-Gm-Gg: ASbGnctELXVO8tl24wSdqDkVAoMTJhw7sFtmrgtFQWkDRLlNgBueaNSAS1WAkFaz05G K7WYHAFxqZ4kkpI2OZ4ShtN5sHeY7yR2OzI8KmRiaMRde8jf546n+5rJrrVH+mA/lNkScP+ugHH c8yxkT5UcVgdmpF7BvzjOnQooMyAzcZBy0DdcaSQ5yUcDlQcY7qjEldROkt+NQHvN/JCfr0Znx+ WiSfGGC6I2+BZdxxM+IFf9E4jMI4nv4bjoUT3aju+Jm/e3FLtE/gGGz66WODFaOo7PqoJhR4BC7 Ve04xLPjE/4KmDjpXLKQJd7yvdQ3PI4gWuH6xNiQo7VqGznr8TGTJTjXfo/Mgs7rSgDrslXWLdo Op8RONv8jNMDM1g== X-Google-Smtp-Source: AGHT+IFzb+Lb4Udr3dz0EmFhJodPqS3NWucS8PSc99lV2WQTX6ulqVzK4K9TJrViknXbfQKD64sOGw== X-Received: by 2002:a5d:588a:0:b0:38d:dc03:a3d6 with SMTP id ffacd0b85a97d-3a09402ca18mr11846814f8f.4.1746449208050; Mon, 05 May 2025 05:46:48 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Michal Orzel , Jan Beulich , Julien Grall , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Roberto Bagnara , Nicola Vetrini , "consulting @ bugseng . com" Subject: [PATCH] xen: Use __auto_type Date: Mon, 5 May 2025 13:46:46 +0100 Message-Id: <20250505124646.1569767-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1746449241344019000 In macros it is common to declare local variables using typeof(param) in or= der to ensure that side effects are only evaluated once. A consequence of this= is double textural expansion of the parameter, which can get out of hand very quickly with nested macros. A GCC extension, __auto_type, is now avaialble in the new toolchain baseline and avoids the double textural expansion. Signed-off-by: Andrew Cooper --- CC: Anthony PERARD CC: Michal Orzel CC: Jan Beulich CC: Julien Grall CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Roberto Bagnara CC: Nicola Vetrini CC: consulting@bugseng.com The resulting build is identical. RFC. This requires a MISRA change, as it currently manifests as a R1.1 violation. Nevertheless, I think we want to start using in places where we currently use typeof(expression of ). Eclair run on this patch (expecting a failure): https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1800631949 Min toolchain check: https://godbolt.org/z/f9WjooPYj GCC Manual: https://www.gnu.org/software/c-intro-and-ref/manual/html_node/Auto-Type.h= tml --- xen/include/xen/macros.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h index cd528fbdb127..b5e5ff4b1c2f 100644 --- a/xen/include/xen/macros.h +++ b/xen/include/xen/macros.h @@ -71,18 +71,18 @@ /* Hide a value from the optimiser. */ #define HIDE(x) \ ({ \ - typeof(x) _x =3D (x); \ + __auto_type _x =3D (x); \ asm volatile ( "" : "+r" (_x) ); \ _x; \ }) =20 #define ABS(x) ({ \ - typeof(x) x_ =3D (x); \ + __auto_type x_ =3D (x); \ (x_ < 0) ? -x_ : x_; \ }) =20 #define SWAP(a, b) \ - do { typeof(a) t_ =3D (a); (a) =3D (b); (b) =3D t_; } while ( 0 ) + do { __auto_type t_ =3D (a); (a) =3D (b); (b) =3D t_; } while ( 0 ) =20 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]) + __must_be_array(x)) =20 @@ -110,15 +110,15 @@ */ #define min(x, y) \ ({ \ - const typeof(x) _x =3D (x); \ - const typeof(y) _y =3D (y); \ + const __auto_type _x =3D (x); \ + const __auto_type _y =3D (y); \ (void)(&_x =3D=3D &_y); /* typecheck */ \ _x < _y ? _x : _y; \ }) #define max(x, y) \ ({ \ - const typeof(x) _x =3D (x); \ - const typeof(y) _y =3D (y); \ + const __auto_type _x =3D (x); \ + const __auto_type _y =3D (y); \ (void)(&_x =3D=3D &_y); /* typecheck */ \ _x > _y ? _x : _y; \ }) base-commit: 78ce2be733b1e45e2e190c1765fe31da318d435f --=20 2.39.5