From nobody Mon Feb 9 11:51:54 2026 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=1745322115; cv=none; d=zohomail.com; s=zohoarc; b=ZkI+Os719+0o6MSaetThAWEqxq1lPVfcj+feBDL6MnOsXQ8VXWsoo6cWp6xnWcAEQ2yMaeltffjMNva61soKzAJEb94/vLJYnBusoagJBxJm1TRabAHsI9RAYypNXVjFVzItRzlffnNpfTwds+ix7KcH1g/AjqNUR9gENKsXuUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1745322115; 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=DNRoRMIV3mPbRJOU5zpVZ3h9hj11xcU/yw8OKGBMsdM=; b=F7161zl/395sfGlkvFIXdNe1aCBhmQ7gO/txF6JwvgIbd4OSFRMH8TCci34bFu1PEad3wx+1GqlvLySLMg9X5q9NtKniOrzxDwvgQGFsMd9EpFx+ibF9Ym8ibAUvEisRjibegNDn9/7I3i/LofFkEhWVJKzovTxLXomjhhdS5gs= 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 1745322115467587.1737761743587; Tue, 22 Apr 2025 04:41:55 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.962550.1353739 (Exim 4.92) (envelope-from ) id 1u7C0U-0008HJ-FV; Tue, 22 Apr 2025 11:41:42 +0000 Received: by outflank-mailman (output) from mailman id 962550.1353739; Tue, 22 Apr 2025 11:41:42 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7C0U-0008HC-CO; Tue, 22 Apr 2025 11:41:42 +0000 Received: by outflank-mailman (input) for mailman id 962550; Tue, 22 Apr 2025 11:41:41 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1u7C0T-00085L-Dh for xen-devel@lists.xenproject.org; Tue, 22 Apr 2025 11:41:41 +0000 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [2a00:1450:4864:20::334]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b98dc6e3-1f6e-11f0-9ffb-bf95429c2676; Tue, 22 Apr 2025 13:41:27 +0200 (CEST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43cec5cd73bso32508095e9.3 for ; Tue, 22 Apr 2025 04:41:38 -0700 (PDT) Received: from localhost.localdomain ([83.104.178.215]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4406d5bbd8asm170611385e9.23.2025.04.22.04.41.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 04:41:36 -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: b98dc6e3-1f6e-11f0-9ffb-bf95429c2676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1745322097; x=1745926897; 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=DNRoRMIV3mPbRJOU5zpVZ3h9hj11xcU/yw8OKGBMsdM=; b=pxRmZWtmdIQ28rd0lSVTkMnxK+0GynbhB2zMLKc6OdFfvRRf+F7iAttNLYSeSAs/Jm iwYrgHL4cMIPZxe1M187iu0wBovukYbnwTLOKOqw3Oh/ucbQWUuvreGbg1EIRXh081dn c7VSdm36ydmAoGcbeyyU9p+u80Jt+HzeenAFA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745322097; x=1745926897; 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=DNRoRMIV3mPbRJOU5zpVZ3h9hj11xcU/yw8OKGBMsdM=; b=U+JV5ef0IPf/WBJxRJE62MvCWOB6NVz8yG5b5oZ2J46QlgGu9rQPiagsEkHsDJXzqJ tLTTCUruz5YdxYuymfrZsR+G0lRruMUkESwq7x78ZfC243Cyo6BnfI48Ikg6WiXApu0h rld83lRG69Xd2STUPc9kIh0K4NGkNmKOL5hU8rEIlEAGLal5RqfduHLdNyrysRjcN7r+ 4BJCSl7zyvny5h4p0Lp3nsGoXqV9S3uaDD9lHm2KmMV5q/tvKt8dFtvQqwwqnZ5F3y83 k10HAyKHqSLzKEwl6Xf45p3jUGyWtQV3pVK6QLFWFsm2oBnCNvPtCI1ObNXDFNbfuswz S5Ug== X-Gm-Message-State: AOJu0YwjJus4m+g0sZkCM2lQZyE1cDhbdObC8l9eZxrjEQY8QKRNw9I4 +/FpAPG3/8OEBKFKj6wFIZXHYPUTODXMmo3pmC3dMRmVkggMQawUOMJPoo9YCwhOaFCf3OmE00u hgng20Q== X-Gm-Gg: ASbGncvwLvq+WxwQFWNEwrJSDcK4iod4a2SlxEAIuNQu0k4myGu0EuLmbvHFHogBg1c xhxe342QOAqqIHCLrPeojnYYIBDwQsAiZBlNPv2iibELzOn7Yk9Ut07E26whcQPXwWPLWMgan/E LfK37VPWpgAN+VBZmLKOWpq2WEoJbyMSeLGqwEL/ngT55e+90sHWSGYI1/r596X+JYXNwO6moQO 8SyuDPjwq7pwPVSR9tG1QA+U9Jbhr+efc9WugeAk+UuhUIDTNh39fqG2bz7DLoyzElMzqleir5p LGd0q9K2I69m3wm1UwSRSFVzLTw9ENHAElKqLgsL6feaj9AS9rO+jW8CyEfoyg== X-Google-Smtp-Source: AGHT+IEkUiKybHlRk7K4jXCi61eyqX96jUQJ53U/d8Dw5A2W2RN0c7HxHwZ/eZVUfmZy9hDDAWoyPQ== X-Received: by 2002:a05:600c:848c:b0:43c:e467:d6ce with SMTP id 5b1f17b1804b1-440715b5f22mr123364115e9.4.1745322097118; Tue, 22 Apr 2025 04:41:37 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Bertrand Marquis , Michal Orzel Subject: [PATCH] xen: Consistently use alignof() Date: Tue, 22 Apr 2025 12:41:34 +0100 Message-Id: <20250422114134.1291254-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: 1745322117517019000 We have a mix of all 3 spellings in Xen, as well as having compatibility in compiler.h for older C standards. Remove the use of __alignof() and __alignof__(), which reduced code volume a little. No functional change. Signed-off-by: Andrew Cooper Acked-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Stefano Stabellini CC: Julien Grall CC: Volodymyr Babchuk CC: Bertrand Marquis CC: Michal Orzel x86_emulate.c and compat-build-header.py still use __alignof() because they have code used outside of Xen. The compiler.h compatibilty checks for < C11, whereas it was C23 when they became keywords. Nothing seems to mind, so I've left it alone. --- xen/arch/x86/xstate.c | 4 ++-- xen/common/coverage/gcc_3_4.c | 4 ++-- xen/common/device-tree/device-tree.c | 8 ++++---- xen/include/xen/config.h | 2 +- xen/include/xen/percpu.h | 2 +- xen/include/xen/xmalloc.h | 16 ++++++++-------- xen/include/xen/xvmalloc.h | 16 ++++++++-------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 3d249518a1b7..d423bf7978da 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -542,8 +542,8 @@ int xstate_alloc_save_area(struct vcpu *v) } =20 /* XSAVE/XRSTOR requires the save area be 64-byte-boundary aligned. */ - BUILD_BUG_ON(__alignof(*save_area) < 64); - save_area =3D _xvzalloc(size, __alignof(*save_area)); + BUILD_BUG_ON(alignof(*save_area) < 64); + save_area =3D _xvzalloc(size, alignof(*save_area)); if ( save_area =3D=3D NULL ) return -ENOMEM; =20 diff --git a/xen/common/coverage/gcc_3_4.c b/xen/common/coverage/gcc_3_4.c index 3631f4bc2535..393e3c866d74 100644 --- a/xen/common/coverage/gcc_3_4.c +++ b/xen/common/coverage/gcc_3_4.c @@ -199,8 +199,8 @@ static size_t get_fn_size(const struct gcov_info *info) =20 size =3D sizeof(struct gcov_fn_info) + num_counter_active(info) * sizeof(unsigned int); - if ( __alignof__(struct gcov_fn_info) > sizeof(unsigned int) ) - size =3D ROUNDUP(size, __alignof__(struct gcov_fn_info)); + if ( alignof(struct gcov_fn_info) > sizeof(unsigned int) ) + size =3D ROUNDUP(size, alignof(struct gcov_fn_info)); return size; } =20 diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/= device-tree.c index 90fee2ba0315..e4dea4b42a1d 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -1885,7 +1885,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, } =20 np =3D unflatten_dt_alloc(&mem, sizeof(struct dt_device_node) + allocl, - __alignof__(struct dt_device_node)); + alignof(struct dt_device_node)); if ( allnextpp ) { memset(np, 0, sizeof(*np)); @@ -1963,7 +1963,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, has_name =3D 1; l =3D strlen(pname) + 1; pp =3D unflatten_dt_alloc(&mem, sizeof(struct dt_property), - __alignof__(struct dt_property)); + alignof(struct dt_property)); if ( allnextpp ) { /* We accept flattened tree phandles either in @@ -2010,7 +2010,7 @@ static unsigned long unflatten_dt_node(const void *fd= t, pa =3D p1; sz =3D (pa - ps) + 1; pp =3D unflatten_dt_alloc(&mem, sizeof(struct dt_property) + sz, - __alignof__(struct dt_property)); + alignof(struct dt_property)); if ( allnextpp ) { pp->name =3D "name"; @@ -2088,7 +2088,7 @@ int unflatten_device_tree(const void *fdt, struct dt_= device_node **mynodes) dt_dprintk(" size is %#lx allocating...\n", size); =20 /* Allocate memory for the expanded device tree */ - mem =3D (unsigned long)_xmalloc (size + 4, __alignof__(struct dt_devic= e_node)); + mem =3D (unsigned long)_xmalloc(size + 4, alignof(struct dt_device_nod= e)); if ( !mem ) return -ENOMEM; =20 diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h index 1d7195066c08..479c3bac8925 100644 --- a/xen/include/xen/config.h +++ b/xen/include/xen/config.h @@ -105,7 +105,7 @@ #define BITS_PER_LONG (BITS_PER_BYTE * BYTES_PER_LONG) #define BITS_PER_LLONG (BITS_PER_BYTE * __SIZEOF_LONG_LONG__) =20 -/* It is assumed that sizeof(void *) =3D=3D __alignof(void *) */ +/* It is assumed that sizeof(void *) =3D=3D alignof(void *) */ #define POINTER_ALIGN __SIZEOF_POINTER__ =20 #if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ diff --git a/xen/include/xen/percpu.h b/xen/include/xen/percpu.h index e7f585c7ed69..62a6259b2bc1 100644 --- a/xen/include/xen/percpu.h +++ b/xen/include/xen/percpu.h @@ -18,7 +18,7 @@ =20 #define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ typedef char name ## _chk_t \ - [BUILD_BUG_ON_ZERO(__alignof(type) & (PAGE_SIZE - 1))]; \ + [BUILD_BUG_ON_ZERO(alignof(type) & (PAGE_SIZE - 1))]; \ __DEFINE_PER_CPU(__section(".bss.percpu.page_aligned"), \ type, _ ## name) =20 diff --git a/xen/include/xen/xmalloc.h b/xen/include/xen/xmalloc.h index f0412fb4e021..b7616c3b9038 100644 --- a/xen/include/xen/xmalloc.h +++ b/xen/include/xen/xmalloc.h @@ -13,8 +13,8 @@ */ =20 /* Allocate space for typed object. */ -#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type= ))) -#define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), __alignof__(_type= ))) +#define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), alignof(_type))) +#define xzalloc(_type) ((_type *)_xzalloc(sizeof(_type), alignof(_type))) =20 /* * Allocate space for a typed object and copy an existing instance. @@ -34,24 +34,24 @@ =20 /* Allocate space for array of typed objects. */ #define xmalloc_array(_type, _num) \ - ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num)) + ((_type *)_xmalloc_array(sizeof(_type), alignof(_type), _num)) #define xzalloc_array(_type, _num) \ - ((_type *)_xzalloc_array(sizeof(_type), __alignof__(_type), _num)) + ((_type *)_xzalloc_array(sizeof(_type), alignof(_type), _num)) #define xrealloc_array(_ptr, _num) \ ((typeof(_ptr))_xrealloc_array(_ptr, sizeof(typeof(*(_ptr))), \ - __alignof__(typeof(*(_ptr))), _num)) + alignof(typeof(*(_ptr))), _num)) =20 /* Allocate space for a structure with a flexible array of typed objects. = */ #define xzalloc_flex_struct(type, field, nr) \ - ((type *)_xzalloc(offsetof(type, field[nr]), __alignof__(type))) + ((type *)_xzalloc(offsetof(type, field[nr]), alignof(type))) =20 #define xmalloc_flex_struct(type, field, nr) \ - ((type *)_xmalloc(offsetof(type, field[nr]), __alignof__(type))) + ((type *)_xmalloc(offsetof(type, field[nr]), alignof(type))) =20 /* Re-allocate space for a structure with a flexible array of typed object= s. */ #define xrealloc_flex_struct(ptr, field, nr) \ ((typeof(ptr))_xrealloc(ptr, offsetof(typeof(*(ptr)), field[nr]), \ - __alignof__(typeof(*(ptr))))) + alignof(typeof(*(ptr))))) =20 /* Allocate untyped storage. */ #define xmalloc_bytes(_bytes) _xmalloc(_bytes, SMP_CACHE_BYTES) diff --git a/xen/include/xen/xvmalloc.h b/xen/include/xen/xvmalloc.h index 7686d49f8154..d2288c175814 100644 --- a/xen/include/xen/xvmalloc.h +++ b/xen/include/xen/xvmalloc.h @@ -10,13 +10,13 @@ */ =20 /* Allocate space for typed object. */ -#define xvmalloc(_type) ((_type *)_xvmalloc(sizeof(_type), __alignof__(_ty= pe))) -#define xvzalloc(_type) ((_type *)_xvzalloc(sizeof(_type), __alignof__(_ty= pe))) +#define xvmalloc(_type) ((_type *)_xvmalloc(sizeof(_type), alignof(_type))) +#define xvzalloc(_type) ((_type *)_xvzalloc(sizeof(_type), alignof(_type))) =20 /* Allocate space for a typed object and copy an existing instance. */ #define xvmemdup(ptr) \ ({ \ - void *p_ =3D _xvmalloc(sizeof(*(ptr)), __alignof__(*(ptr))); \ + void *p_ =3D _xvmalloc(sizeof(*(ptr)), alignof(*(ptr))); \ if ( p_ ) \ memcpy(p_, ptr, sizeof(*(ptr))); \ (typeof(*(ptr)) *)p_; \ @@ -24,21 +24,21 @@ =20 /* Allocate space for array of typed objects. */ #define xvmalloc_array(_type, _num) \ - ((_type *)_xvmalloc_array(sizeof(_type), __alignof__(_type), _num)) + ((_type *)_xvmalloc_array(sizeof(_type), alignof(_type), _num)) #define xvzalloc_array(_type, _num) \ - ((_type *)_xvzalloc_array(sizeof(_type), __alignof__(_type), _num)) + ((_type *)_xvzalloc_array(sizeof(_type), alignof(_type), _num)) =20 /* Allocate space for a structure with a flexible array of typed objects. = */ #define xvzalloc_flex_struct(type, field, nr) \ - ((type *)_xvzalloc(offsetof(type, field[nr]), __alignof__(type))) + ((type *)_xvzalloc(offsetof(type, field[nr]), alignof(type))) =20 #define xvmalloc_flex_struct(type, field, nr) \ - ((type *)_xvmalloc(offsetof(type, field[nr]), __alignof__(type))) + ((type *)_xvmalloc(offsetof(type, field[nr]), alignof(type))) =20 /* Re-allocate space for a structure with a flexible array of typed object= s. */ #define xvrealloc_flex_struct(ptr, field, nr) \ ((typeof(ptr))_xvrealloc(ptr, offsetof(typeof(*(ptr)), field[nr]), \ - __alignof__(typeof(*(ptr))))) + alignof(typeof(*(ptr))))) =20 #ifdef CONFIG_HAS_VMAP =20 --=20 2.39.5