From nobody Thu May 16 22:07:52 2024 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1677512549; cv=none; d=zohomail.com; s=zohoarc; b=gRkNqKqFjkfr9RJ4L4ei30f6nhP3r1oyIawhWlUCQABcS9t0IXPzr1p5M/uaNgqQhi8EA8O6tXjjjO4skD8Hm+/wTulfrhSCC2/JUhqGjHVQpIL/YHpiUfLXsUhUMUvRZMgOmj/KayQOJkrKHBnmyXVluiQa9H3B4yM4YWg9KtM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677512549; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jnk/7wu8wbdXtKZRHkZW+NZ4KlZpKHkQVohbC1DIgv0=; b=dhqYOKK1PhsKOVApzYTDGQrrw1i2oiw2NOtOwblXqV2MjuSYw7Us8M/9xdah6gAXTqgLnweDNBR0MfdkiylY4bIcqPVuHvAaHZa9pz1IfBrmOKYROBVfyd9isWQIFRi9cxzakQfjhmSL/cS0XhHXbbdCYnWLjdChj+7VCITzPU0= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677512549582141.00974096498214; Mon, 27 Feb 2023 07:42:29 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502744.774682 (Exim 4.92) (envelope-from ) id 1pWfde-00035P-Oo; Mon, 27 Feb 2023 15:42:06 +0000 Received: by outflank-mailman (output) from mailman id 502744.774682; Mon, 27 Feb 2023 15:42:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWfde-00035I-Ld; Mon, 27 Feb 2023 15:42:06 +0000 Received: by outflank-mailman (input) for mailman id 502744; Mon, 27 Feb 2023 15:42:06 +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 1pWfde-00034v-2I for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 15:42:06 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4766f902-b6b5-11ed-a82a-c9ca1d2f71af; Mon, 27 Feb 2023 16:42:02 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 13C95219E1; Mon, 27 Feb 2023 15:42:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 99AFE13912; Mon, 27 Feb 2023 15:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id C/ZPJEnP/GOLLgAAMHmgww (envelope-from ); Mon, 27 Feb 2023 15:42:01 +0000 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: 4766f902-b6b5-11ed-a82a-c9ca1d2f71af DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677512522; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jnk/7wu8wbdXtKZRHkZW+NZ4KlZpKHkQVohbC1DIgv0=; b=QCMlVF7uNQIJ83PcyoZRnK5QTvKRVRz2QkS6CDipWzhty8znCfD9btjxhl1tmTcKHDcvEk 2CezFzw6d3hM07kw8F4tgsk0bpaB8pbZ34+v6sG23NEQuSoy+AiFMc/OGtVLyrAC4n3Eql 2j/T5hou3g5ySazQRtpOXm5pFgCKOg4= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Tamas K Lengyel , Alexandru Isaila , Petre Pircalabu , Konrad Rzeszutek Wilk , Ross Lagerwall , Christian Lindig , David Scott , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Julien Grall , George Dunlap Subject: [PATCH v2 1/4] tools: rename xen-tools/libs.h file to common-macros.h Date: Mon, 27 Feb 2023 16:41:50 +0100 Message-Id: <20230227154153.31080-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227154153.31080-1-jgross@suse.com> References: <20230227154153.31080-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677512550995100001 Content-Type: text/plain; charset="utf-8" In order to better reflect the contents of the header and to make it more appropriate to use it for different runtime environments like programs, libraries, and firmware, rename the libs.h include file to common-macros.h. Additionally ad a comment pointing out the need to be self-contained. Suggested-by: Andrew Cooper Signed-off-by: Juergen Gross Acked-by: Christian Lindig Acked-by: Marek Marczykowski-G=C3=B3recki --- V2: - new patch --- tools/console/daemon/io.c | 2 +- tools/fuzz/cpu-policy/afl-policy-fuzzer.c | 2 +- .../include/xen-tools/{libs.h =3D> common-macros.h} | 14 +++++++++++--- tools/libs/call/buffer.c | 2 +- tools/libs/ctrl/xc_pm.c | 2 +- tools/libs/ctrl/xc_private.h | 2 +- tools/libs/foreignmemory/linux.c | 2 +- tools/libs/gnttab/freebsd.c | 2 +- tools/libs/gnttab/linux.c | 2 +- tools/libs/guest/xg_core_arm.c | 2 +- tools/libs/guest/xg_cpuid_x86.c | 2 +- tools/libs/guest/xg_dom_arm.c | 2 +- tools/libs/guest/xg_dom_bzimageloader.c | 2 +- tools/libs/guest/xg_dom_x86.c | 2 +- tools/libs/guest/xg_sr_common.c | 2 +- tools/libs/light/libxl_internal.h | 2 +- tools/libs/light/libxl_psr.c | 2 +- tools/libs/stat/xenstat_linux.c | 2 +- tools/misc/xen-access.c | 2 +- tools/misc/xen-cpuid.c | 2 +- tools/misc/xen-diag.c | 2 +- tools/misc/xen-hptool.c | 2 +- tools/misc/xen-livepatch.c | 2 +- tools/misc/xen-mfndump.c | 2 +- tools/misc/xenpm.c | 2 +- tools/ocaml/libs/mmap/xenmmap_stubs.c | 2 +- tools/ocaml/libs/xc/xenctrl_stubs.c | 2 +- tools/python/xen/lowlevel/xc/xc.c | 2 +- tools/tests/cpu-policy/test-cpu-policy.c | 2 +- tools/tests/paging-mempool/test-paging-mempool.c | 2 +- tools/tests/resource/test-resource.c | 2 +- tools/tests/tsx/test-tsx.c | 2 +- tools/tests/vhpet/emul.h | 2 +- tools/tests/x86_emulator/x86-emulate.h | 2 +- tools/tests/xenstore/test-xenstore.c | 2 +- tools/xenstore/utils.h | 2 +- tools/xentrace/analyze.h | 2 +- tools/xl/xl_cmdtable.c | 2 +- xen/lib/x86/private.h | 2 +- 39 files changed, 49 insertions(+), 41 deletions(-) rename tools/include/xen-tools/{libs.h =3D> common-macros.h} (83%) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 682c1f4008..6bfe96715b 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -50,7 +50,7 @@ #include #include #endif -#include +#include =20 /* Each 10 bits takes ~ 3 digits, plus one, plus one for nul terminator. */ #define MAX_STRLEN(x) ((sizeof(x) * CHAR_BIT + CHAR_BIT-1) / 10 * 3 + 2) diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-pol= icy/afl-policy-fuzzer.c index 79a849a044..7d0f274c6c 100644 --- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c +++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c @@ -8,7 +8,7 @@ =20 #include =20 -#include +#include #include #include #include diff --git a/tools/include/xen-tools/libs.h b/tools/include/xen-tools/commo= n-macros.h similarity index 83% rename from tools/include/xen-tools/libs.h rename to tools/include/xen-tools/common-macros.h index bafc90e2f6..f39cd96008 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/common-macros.h @@ -1,5 +1,13 @@ -#ifndef __XEN_TOOLS_LIBS__ -#define __XEN_TOOLS_LIBS__ +#ifndef __XEN_TOOLS_COMMON_MACROS__ +#define __XEN_TOOLS_COMMON_MACROS__ + +/* + * Caution: + * + * This header must be completely self-contained. There are no external + * references to variables or functions allowed, as the file might be incl= uded + * for different runtime environments, such as firmware or normal programs. + */ =20 #ifndef BUILD_BUG_ON #if __GNUC__ > 4 || (__GNUC__ =3D=3D 4 && __GNUC_MINOR__ >=3D 6) @@ -67,4 +75,4 @@ #define __must_check __attribute__((__warn_unused_result__)) #endif =20 -#endif /* __XEN_TOOLS_LIBS__ */ +#endif /* __XEN_TOOLS_COMMON_MACROS__ */ diff --git a/tools/libs/call/buffer.c b/tools/libs/call/buffer.c index 085674d882..2579b8c719 100644 --- a/tools/libs/call/buffer.c +++ b/tools/libs/call/buffer.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include =20 #include "private.h" =20 diff --git a/tools/libs/ctrl/xc_pm.c b/tools/libs/ctrl/xc_pm.c index 76d7eb7f26..c3a9864bf7 100644 --- a/tools/libs/ctrl/xc_pm.c +++ b/tools/libs/ctrl/xc_pm.c @@ -21,7 +21,7 @@ #include #include "xc_private.h" =20 -#include +#include =20 /* * Get PM statistic info diff --git a/tools/libs/ctrl/xc_private.h b/tools/libs/ctrl/xc_private.h index ed960c6f30..80dc464c93 100644 --- a/tools/libs/ctrl/xc_private.h +++ b/tools/libs/ctrl/xc_private.h @@ -39,7 +39,7 @@ =20 #include =20 -#include +#include =20 #if defined(HAVE_VALGRIND_MEMCHECK_H) && !defined(NDEBUG) && !defined(__MI= NIOS__) /* Compile in Valgrind client requests? */ diff --git a/tools/libs/foreignmemory/linux.c b/tools/libs/foreignmemory/li= nux.c index 9062117407..12f959765a 100644 --- a/tools/libs/foreignmemory/linux.c +++ b/tools/libs/foreignmemory/linux.c @@ -25,7 +25,7 @@ =20 #include #include -#include +#include =20 #include "private.h" =20 diff --git a/tools/libs/gnttab/freebsd.c b/tools/libs/gnttab/freebsd.c index e42ac3fbf3..d69d928a16 100644 --- a/tools/libs/gnttab/freebsd.c +++ b/tools/libs/gnttab/freebsd.c @@ -31,7 +31,7 @@ #include =20 #include -#include +#include =20 #include "private.h" =20 diff --git a/tools/libs/gnttab/linux.c b/tools/libs/gnttab/linux.c index 5628fd5719..7286c1d4fe 100644 --- a/tools/libs/gnttab/linux.c +++ b/tools/libs/gnttab/linux.c @@ -33,7 +33,7 @@ #include =20 #include -#include +#include =20 #include "private.h" =20 diff --git a/tools/libs/guest/xg_core_arm.c b/tools/libs/guest/xg_core_arm.c index aaabd07558..de30cf0c31 100644 --- a/tools/libs/guest/xg_core_arm.c +++ b/tools/libs/guest/xg_core_arm.c @@ -19,7 +19,7 @@ #include "xc_private.h" #include "xg_core.h" =20 -#include +#include =20 int xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt, diff --git a/tools/libs/guest/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x8= 6.c index 57f81eb0a0..4542878bbe 100644 --- a/tools/libs/guest/xg_cpuid_x86.c +++ b/tools/libs/guest/xg_cpuid_x86.c @@ -24,7 +24,7 @@ #include #include "xg_private.h" #include -#include +#include =20 enum { #define XEN_CPUFEATURE(name, value) X86_FEATURE_##name =3D value, diff --git a/tools/libs/guest/xg_dom_arm.c b/tools/libs/guest/xg_dom_arm.c index 5e3b76355e..d616dccbd6 100644 --- a/tools/libs/guest/xg_dom_arm.c +++ b/tools/libs/guest/xg_dom_arm.c @@ -21,7 +21,7 @@ =20 #include #include -#include +#include =20 #include "xg_private.h" =20 diff --git a/tools/libs/guest/xg_dom_bzimageloader.c b/tools/libs/guest/xg_= dom_bzimageloader.c index 764ddbb43e..c6ee6d83e7 100644 --- a/tools/libs/guest/xg_dom_bzimageloader.c +++ b/tools/libs/guest/xg_dom_bzimageloader.c @@ -34,7 +34,7 @@ #include "xg_private.h" #include "xg_dom_decompress.h" =20 -#include +#include =20 #ifndef __MINIOS__ =20 diff --git a/tools/libs/guest/xg_dom_x86.c b/tools/libs/guest/xg_dom_x86.c index 9328fbf804..811d176488 100644 --- a/tools/libs/guest/xg_dom_x86.c +++ b/tools/libs/guest/xg_dom_x86.c @@ -35,7 +35,7 @@ #include #include =20 -#include +#include =20 #include "xg_private.h" #include "xenctrl.h" diff --git a/tools/libs/guest/xg_sr_common.c b/tools/libs/guest/xg_sr_commo= n.c index 17567ab133..7ccdc3b1f6 100644 --- a/tools/libs/guest/xg_sr_common.c +++ b/tools/libs/guest/xg_sr_common.c @@ -2,7 +2,7 @@ =20 #include "xg_sr_common.h" =20 -#include +#include =20 static const char *const dhdr_types[] =3D { diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index ad982d691a..5244fde623 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -58,7 +58,7 @@ #include #include =20 -#include +#include =20 #include "xentoollog.h" =20 diff --git a/tools/libs/light/libxl_psr.c b/tools/libs/light/libxl_psr.c index 9ced7d1715..712a55a73d 100644 --- a/tools/libs/light/libxl_psr.c +++ b/tools/libs/light/libxl_psr.c @@ -16,7 +16,7 @@ #include "libxl_osdeps.h" /* must come before any other headers */ #include "libxl_internal.h" =20 -#include +#include =20 #define IA32_QM_CTR_ERROR_MASK (0x3ul << 62) =20 diff --git a/tools/libs/stat/xenstat_linux.c b/tools/libs/stat/xenstat_linu= x.c index ebcd65f24a..05d0b07553 100644 --- a/tools/libs/stat/xenstat_linux.c +++ b/tools/libs/stat/xenstat_linux.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include =20 #include "xenstat_priv.h" =20 diff --git a/tools/misc/xen-access.c b/tools/misc/xen-access.c index 0731c20b83..4097eebe6f 100644 --- a/tools/misc/xen-access.c +++ b/tools/misc/xen-access.c @@ -43,7 +43,7 @@ #include #include =20 -#include +#include =20 #if defined(__arm__) || defined(__aarch64__) #include diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 3ab820571d..8cf6a5ecfe 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -10,7 +10,7 @@ #include #include =20 -#include +#include =20 static uint32_t nr_features; =20 diff --git a/tools/misc/xen-diag.c b/tools/misc/xen-diag.c index 4778914820..cd0c2c1fc6 100644 --- a/tools/misc/xen-diag.c +++ b/tools/misc/xen-diag.c @@ -11,7 +11,7 @@ #include =20 #include -#include +#include =20 static xc_interface *xch; =20 diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c index 7f17f24942..6d6aec8bad 100644 --- a/tools/misc/xen-hptool.c +++ b/tools/misc/xen-hptool.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include =20 static xc_interface *xch; =20 diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c index 16a4a47ab7..5bf9d9a32b 100644 --- a/tools/misc/xen-livepatch.c +++ b/tools/misc/xen-livepatch.c @@ -15,7 +15,7 @@ #include =20 #include -#include +#include =20 static xc_interface *xch; =20 diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c index 62121bd241..b32c95e262 100644 --- a/tools/misc/xen-mfndump.c +++ b/tools/misc/xen-mfndump.c @@ -8,7 +8,7 @@ #include #include =20 -#include +#include =20 #define M2P_SIZE(_m) ROUNDUP(((_m) * sizeof(xen_pfn_t)), 21) #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL)) diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c index 4f8cde690a..1bb6187e56 100644 --- a/tools/misc/xenpm.c +++ b/tools/misc/xenpm.c @@ -28,7 +28,7 @@ #include #include =20 -#include +#include =20 #define MAX_PKG_RESIDENCIES 12 #define MAX_CORE_RESIDENCIES 8 diff --git a/tools/ocaml/libs/mmap/xenmmap_stubs.c b/tools/ocaml/libs/mmap/= xenmmap_stubs.c index d623ad390e..c85b1fcce7 100644 --- a/tools/ocaml/libs/mmap/xenmmap_stubs.c +++ b/tools/ocaml/libs/mmap/xenmmap_stubs.c @@ -21,7 +21,7 @@ #include #include "mmap_stubs.h" =20 -#include +#include =20 #include #include diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenc= trl_stubs.c index ed1cbafdb4..6ec9ed6d1e 100644 --- a/tools/ocaml/libs/xc/xenctrl_stubs.c +++ b/tools/ocaml/libs/xc/xenctrl_stubs.c @@ -33,7 +33,7 @@ #define XC_WANT_COMPAT_MAP_FOREIGN_API #include #include -#include +#include =20 #include "mmap_stubs.h" =20 diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/= xc/xc.c index cfb2734a99..224671bc02 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -22,7 +22,7 @@ #include #include =20 -#include +#include =20 /* Needed for Python versions earlier than 2.3. */ #ifndef PyMODINIT_FUNC diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-pol= icy/test-cpu-policy.c index ed450a0997..d3f24fd6d2 100644 --- a/tools/tests/cpu-policy/test-cpu-policy.c +++ b/tools/tests/cpu-policy/test-cpu-policy.c @@ -7,7 +7,7 @@ #include #include =20 -#include +#include #include #include #include diff --git a/tools/tests/paging-mempool/test-paging-mempool.c b/tools/tests= /paging-mempool/test-paging-mempool.c index b2dfe9b074..1ebc13455a 100644 --- a/tools/tests/paging-mempool/test-paging-mempool.c +++ b/tools/tests/paging-mempool/test-paging-mempool.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include =20 static unsigned int nr_failures; #define fail(fmt, ...) \ diff --git a/tools/tests/resource/test-resource.c b/tools/tests/resource/te= st-resource.c index 0a950072f9..7ae88ea348 100644 --- a/tools/tests/resource/test-resource.c +++ b/tools/tests/resource/test-resource.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include =20 static unsigned int nr_failures; #define fail(fmt, ...) \ diff --git a/tools/tests/tsx/test-tsx.c b/tools/tests/tsx/test-tsx.c index f11e8c54e0..d6d98c299b 100644 --- a/tools/tests/tsx/test-tsx.c +++ b/tools/tests/tsx/test-tsx.c @@ -28,7 +28,7 @@ =20 #include #include -#include +#include =20 #include "xg_private.h" =20 diff --git a/tools/tests/vhpet/emul.h b/tools/tests/vhpet/emul.h index b022cc0eab..dfeb10f74e 100644 --- a/tools/tests/vhpet/emul.h +++ b/tools/tests/vhpet/emul.h @@ -24,7 +24,7 @@ =20 #include "hpet.h" =20 -#include +#include =20 #define NR_CPUS 8 =20 diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emula= tor/x86-emulate.h index 18ae40d017..46d4e43cea 100644 --- a/tools/tests/x86_emulator/x86-emulate.h +++ b/tools/tests/x86_emulator/x86-emulate.h @@ -39,7 +39,7 @@ #include #include =20 -#include +#include =20 #define BUG() abort() #define ASSERT assert diff --git a/tools/tests/xenstore/test-xenstore.c b/tools/tests/xenstore/te= st-xenstore.c index d3574b3fa2..d491dac53b 100644 --- a/tools/tests/xenstore/test-xenstore.c +++ b/tools/tests/xenstore/test-xenstore.c @@ -31,7 +31,7 @@ #include #include =20 -#include +#include =20 #define TEST_PATH "xenstore-test" #define WRITE_BUFFERS_N 10 diff --git a/tools/xenstore/utils.h b/tools/xenstore/utils.h index 9d012b97c1..028ecb9d7a 100644 --- a/tools/xenstore/utils.h +++ b/tools/xenstore/utils.h @@ -5,7 +5,7 @@ #include #include =20 -#include +#include =20 #include "xenstore_lib.h" =20 diff --git a/tools/xentrace/analyze.h b/tools/xentrace/analyze.h index f9d98d8da4..6fefa19639 100644 --- a/tools/xentrace/analyze.h +++ b/tools/xentrace/analyze.h @@ -3,7 +3,7 @@ =20 #include =20 -#include +#include =20 #define TRC_GEN_MAIN 0 #define TRC_SCHED_MAIN 1 diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 35182ca196..ccf4d83584 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -15,7 +15,7 @@ #include =20 #include -#include +#include =20 #include "xl.h" =20 diff --git a/xen/lib/x86/private.h b/xen/lib/x86/private.h index 2d53bd3ced..60bb82a400 100644 --- a/xen/lib/x86/private.h +++ b/xen/lib/x86/private.h @@ -26,7 +26,7 @@ #include #include =20 -#include +#include =20 static inline bool test_bit(unsigned int bit, const void *vaddr) { --=20 2.35.3 From nobody Thu May 16 22:07:52 2024 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1677512542; cv=none; d=zohomail.com; s=zohoarc; b=GhxhxhIg0t4/1HLJH8G4bpEFiM7twQlqK0EU7Zm7Mc62bLSIV+2ziitrgGE+DzaAqZrSbsUSD0Qd2lSdHDC2NqMidTkvGTp41zn0xfQhpmFNmM3pz5noWYDgot9j5c0Ca/1gRFF3XFIETppD3cS3nrlPhp/kLyI2YhuU4xfSc44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677512542; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OmPvDiKPc8fkjb5bC8ZuNmcnqo6DotzNARfC8zrr0bE=; b=B/3ttV1QRD1j3Yq2xlcKXSNT/2XR5LCkTgt2/NrTR/9SxWjnmSPT5LidhJzYs9m8qi8M1jhrbmaT1W+5ekGziRzEgw41AiqAop/Z/3C2BqurKe3kwgGjiLiCvDA5OBmvg+bWaw+JdCJftEEGAWPyHiy+hOhCFtUkL6cuzeScTNg= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677512542831134.6916140567738; Mon, 27 Feb 2023 07:42:22 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502745.774692 (Exim 4.92) (envelope-from ) id 1pWfdi-0003Mu-2A; Mon, 27 Feb 2023 15:42:10 +0000 Received: by outflank-mailman (output) from mailman id 502745.774692; Mon, 27 Feb 2023 15:42:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWfdh-0003Mn-V6; Mon, 27 Feb 2023 15:42:09 +0000 Received: by outflank-mailman (input) for mailman id 502745; Mon, 27 Feb 2023 15:42:08 +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 1pWfdg-0002o3-Iz for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 15:42:08 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [2001:67c:2178:6::1c]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 4ac2dfa5-b6b5-11ed-88bb-e56d68cac8db; Mon, 27 Feb 2023 16:42:07 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B14B0219ED; Mon, 27 Feb 2023 15:42:07 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 763B513912; Mon, 27 Feb 2023 15:42:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6Z+QG0/P/GOaLgAAMHmgww (envelope-from ); Mon, 27 Feb 2023 15:42:07 +0000 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: 4ac2dfa5-b6b5-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677512527; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OmPvDiKPc8fkjb5bC8ZuNmcnqo6DotzNARfC8zrr0bE=; b=B1Y3ANN2XOIZx+NtezMI3FnOUMphvlhyjY1K7T2VbEO58d5c726lbJ7HoOR8whOw27IPkd m84zhstbNKatlWsxs4tlIeYcgYIVK+H/N1SDUogv7EeKHkFj6S9hjHjizqZsx6k06AasaS 41zvzcF7i/k+uNHIt80d5W4NbG+Dw6Q= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Anthony PERARD , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Julien Grall Subject: [PATCH v2 2/4] tools: add container_of() macro to xen-tools/common-macros.h Date: Mon, 27 Feb 2023 16:41:51 +0100 Message-Id: <20230227154153.31080-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227154153.31080-1-jgross@suse.com> References: <20230227154153.31080-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677512544690100001 Content-Type: text/plain; charset="utf-8" Instead of having 4 identical copies of the definition of a container_of() macro in different tools header files, add that macro to xen-tools/common-macros.h and use that instead. Delete the other copies of that macro. Signed-off-by: Juergen Gross Acked-by: Christian Lindig --- There is a similar macro CONTAINER_OF() defined in tools/include/xentoolcore_internal.h, which allows to not only use a type for the 2nd parameter, but a variable, too. I'd like to get rid of that macro as well, but there are lots of use cases especially in libxl. Any thoughts regarding that macro? I could either: - don't touch it at all - enhance container_of() like CONTAINER_OF() and replace all use cases of CONTAINER_OF() with container_of() - replace the few CONTAINER_OF() users outside libxl with container_of() and define CONTAINER_OF() in e.g. libxl_internal.h - replace all CONTAINER_OF() use cases with container_of(), including the change from (.., var, ..) to (.., type, ...). Signed-off-by: Juergen Gross --- tools/include/xen-tools/common-macros.h | 4 ++++ tools/tests/vhpet/emul.h | 3 --- tools/tests/vpci/emul.h | 6 +----- tools/tests/x86_emulator/x86-emulate.h | 5 ----- tools/xenstore/list.h | 6 ++---- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-to= ols/common-macros.h index f39cd96008..3e73b33c91 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -75,4 +75,8 @@ #define __must_check __attribute__((__warn_unused_result__)) #endif =20 +#define container_of(ptr, type, member) ({ \ + typeof( ((type *)0)->member ) *__mptr =3D (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + #endif /* __XEN_TOOLS_COMMON_MACROS__ */ diff --git a/tools/tests/vhpet/emul.h b/tools/tests/vhpet/emul.h index dfeb10f74e..610641ab0c 100644 --- a/tools/tests/vhpet/emul.h +++ b/tools/tests/vhpet/emul.h @@ -125,9 +125,6 @@ enum #define max_t(type, x, y) \ ({ type __x =3D (x); type __y =3D (y); __x > __y ? __x : __y; }) #define offsetof(t, m) ((unsigned long )&((t *)0)->m) -#define container_of(ptr, type, member) ({ \ - typeof( ((type *)0)->member ) *__mptr =3D (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) ); }) =20 struct domain; =20 diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h index f03e3a56d1..7169a2ea02 100644 --- a/tools/tests/vpci/emul.h +++ b/tools/tests/vpci/emul.h @@ -27,11 +27,7 @@ #include #include =20 -#define container_of(ptr, type, member) ({ \ - typeof(((type *)0)->member) *mptr =3D (ptr); \ - \ - (type *)((char *)mptr - offsetof(type, member)); \ -}) +#include =20 #define smp_wmb() #define prefetch(x) __builtin_prefetch(x) diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emula= tor/x86-emulate.h index 46d4e43cea..1af986f78d 100644 --- a/tools/tests/x86_emulator/x86-emulate.h +++ b/tools/tests/x86_emulator/x86-emulate.h @@ -56,11 +56,6 @@ =20 #define cf_check /* No Control Flow Integriy checking */ =20 -#define container_of(ptr, type, member) ({ \ - typeof(((type *)0)->member) *mptr__ =3D (ptr); \ - (type *)((char *)mptr__ - offsetof(type, member)); \ -}) - #define AC_(n,t) (n##t) #define _AC(n,t) AC_(n,t) =20 diff --git a/tools/xenstore/list.h b/tools/xenstore/list.h index b17d13e0ec..a464a38b61 100644 --- a/tools/xenstore/list.h +++ b/tools/xenstore/list.h @@ -3,6 +3,8 @@ /* Taken from Linux kernel code, but de-kernelized for userspace. */ #include =20 +#include + #undef LIST_HEAD_INIT #undef LIST_HEAD #undef INIT_LIST_HEAD @@ -15,10 +17,6 @@ #define LIST_POISON1 ((void *) 0x00100100) #define LIST_POISON2 ((void *) 0x00200200) =20 -#define container_of(ptr, type, member) ({ \ - typeof( ((type *)0)->member ) *__mptr =3D (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - /* * Simple doubly linked list implementation. * --=20 2.35.3 From nobody Thu May 16 22:07:52 2024 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1677512557; cv=none; d=zohomail.com; s=zohoarc; b=UtqLNi6VqhQp2pBGP5oUpiaIEK5oPy8uscsTDc+iP85C0WBJRS0t3EgJDBxSn0+ab3uWTlFDT4wd2UK4QamCHBmpjd0oQ6SEv+n6pGhfq/njvGhc3p5z5QKIY77TJRSaQy8RgjtRqjxiCvoAVXQIdku0xlWIIjEi90kdyy297iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677512557; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B1c6Zfhki+3SKicBGrekaC400lL1q73+u27gT8K2e1I=; b=bNW8CWD7sgqEIPIQakFYcPbWtETcZW/54PJhRLcD+R6hGbBUtChR0PnMr84dOghyqtcUs6wK2pxdkfDih4HbnW3jxrlKlHrI+gYKgsa+942F7DNiR9YOUk4G+n2PExu1lrBdM1D4mtYxFyazuQsIzq2fZuW5oEc0NIFZnlzt2KQ= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677512557463171.24800045158884; Mon, 27 Feb 2023 07:42:37 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502747.774701 (Exim 4.92) (envelope-from ) id 1pWfdp-0003ox-Fo; Mon, 27 Feb 2023 15:42:17 +0000 Received: by outflank-mailman (output) from mailman id 502747.774701; Mon, 27 Feb 2023 15:42:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWfdp-0003oq-CY; Mon, 27 Feb 2023 15:42:17 +0000 Received: by outflank-mailman (input) for mailman id 502747; Mon, 27 Feb 2023 15:42:15 +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 1pWfdn-00034v-KP for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 15:42:15 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4e1b024a-b6b5-11ed-a82a-c9ca1d2f71af; Mon, 27 Feb 2023 16:42:13 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 54C3E1FD63; Mon, 27 Feb 2023 15:42:13 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1C60C13912; Mon, 27 Feb 2023 15:42:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /XSRBVXP/GOiLgAAMHmgww (envelope-from ); Mon, 27 Feb 2023 15:42:13 +0000 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: 4e1b024a-b6b5-11ed-a82a-c9ca1d2f71af DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677512533; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B1c6Zfhki+3SKicBGrekaC400lL1q73+u27gT8K2e1I=; b=ToNLji9L1Vcxn1NbOwijP6BP0hp0B0QRVgwFHq1qvKvwqOpH36YtV+L6dl3BlXDhv99iqA eLnLPGBfSCyRjcAmDIKAIL7YybmcAjT/k1QVk24E3bHjjhyyOYHfxQBNmM+jUCtbVDJg91 S0cRYrIrnz8n4GwDFISgh0j5QM/ripA= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Anthony PERARD Subject: [PATCH v2 3/4] tools: get rid of additional min() and max() definitions Date: Mon, 27 Feb 2023 16:41:52 +0100 Message-Id: <20230227154153.31080-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227154153.31080-1-jgross@suse.com> References: <20230227154153.31080-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677512558832100001 Content-Type: text/plain; charset="utf-8" Defining min(), min_t(), max() and max_t() at other places than xen-tools/common-macros.h isn't needed, as the definitions in said header can be used instead. Same applies to BUILD_BUG_ON() in hvmloader. Signed-off-by: Juergen Gross Acked-by: Christian Lindig --- tools/firmware/hvmloader/util.h | 8 ++------ tools/libs/vchan/init.c | 3 +-- tools/tests/vhpet/emul.h | 11 +---------- tools/tests/vpci/emul.h | 16 ---------------- 4 files changed, 4 insertions(+), 34 deletions(-) diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/uti= l.h index 8d95eab28a..e04990ee97 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -9,6 +9,8 @@ #include #include "e820.h" =20 +#include + /* Request un-prefixed values from errno.h. */ #define XEN_ERRNO(name, value) name =3D value, enum { @@ -41,12 +43,6 @@ void __assert_failed(const char *assertion, const char *= file, int line) void __bug(const char *file, int line) __attribute__((noreturn)); #define BUG() __bug(__FILE__, __LINE__) #define BUG_ON(p) do { if (p) BUG(); } while (0) -#define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)])) - -#define min_t(type,x,y) \ - ({ type __x =3D (x); type __y =3D (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x =3D (x); type __y =3D (y); __x > __y ? __x: __y; }) =20 #define MB(mb) (mb##ULL << 20) #define GB(gb) (gb##ULL << 30) diff --git a/tools/libs/vchan/init.c b/tools/libs/vchan/init.c index 9195bd3b98..021e1f29e1 100644 --- a/tools/libs/vchan/init.c +++ b/tools/libs/vchan/init.c @@ -45,6 +45,7 @@ #include #include #include +#include =20 #include "vchan.h" =20 @@ -72,8 +73,6 @@ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif =20 -#define max(a,b) ((a > b) ? a : b) - static int init_gnt_srv(struct libxenvchan *ctrl, int domain) { int pages_left =3D ctrl->read.order >=3D PAGE_SHIFT ? 1 << (ctrl->read.or= der - PAGE_SHIFT) : 0; diff --git a/tools/tests/vhpet/emul.h b/tools/tests/vhpet/emul.h index 610641ab0c..6af880cd43 100644 --- a/tools/tests/vhpet/emul.h +++ b/tools/tests/vhpet/emul.h @@ -114,16 +114,7 @@ enum TASKLET_SOFTIRQ, NR_COMMON_SOFTIRQS }; -/* - * ..and if you can't take the strict - * types, you can specify one yourself. - * - * Or not use min/max at all, of course. - */ -#define min_t(type, x, y) \ - ({ type __x =3D (x); type __y =3D (y); __x < __y ? __x : __y; }) -#define max_t(type, x, y) \ - ({ type __x =3D (x); type __y =3D (y); __x > __y ? __x : __y; }) + #define offsetof(t, m) ((unsigned long )&((t *)0)->m) =20 struct domain; diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h index 7169a2ea02..8c5bcadd5f 100644 --- a/tools/tests/vpci/emul.h +++ b/tools/tests/vpci/emul.h @@ -106,22 +106,6 @@ typedef union { #define BUG() assert(0) #define ASSERT_UNREACHABLE() assert(0) =20 -#define min(x, y) ({ \ - const typeof(x) tx =3D (x); \ - const typeof(y) ty =3D (y); \ - \ - (void) (&tx =3D=3D &ty); \ - tx < ty ? tx : ty; \ -}) - -#define max(x, y) ({ \ - const typeof(x) tx =3D (x); \ - const typeof(y) ty =3D (y); \ - \ - (void) (&tx =3D=3D &ty); \ - tx > ty ? tx : ty; \ -}) - #endif =20 /* --=20 2.35.3 From nobody Thu May 16 22:07:52 2024 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=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1677512552; cv=none; d=zohomail.com; s=zohoarc; b=d/yQyzjP6DHt0Nz6Sf8zeBhmyoJ5xzrf7g0gELu5wJlwZoeysApcQFRHUMGw5g0OGz8gE2uhLDwRQtkaCC8PHzTO/2dUBWixF09LrrTJwxRVoTHsJtLw4WEFEIRgqs/54vhGCzjA4dsCidg0xlaLfLql+9eHybW3O7ASmIrcdvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677512552; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4YWfk5My0zrpM/pObahciTKOWepQnXUCCFFrc1nZeeQ=; b=WNObag2M38f+jbqTBVPErqlJpJiZAB6PqiLuV889JATEMVQ0TJ9h1f7jtNJyNxFAzTcrpxlN8xmxoavSXSVXk1J/1n63WKg6qTwAVHN2JJ5eIlMzSqh51/OdC0N5R/fOJTzuFdl4dIgtoS9RszVaKnewosamQvBgZ5t41/GXVoM= 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=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1677512552210836.1822853835865; Mon, 27 Feb 2023 07:42:32 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502751.774712 (Exim 4.92) (envelope-from ) id 1pWfdt-0004Bx-Nw; Mon, 27 Feb 2023 15:42:21 +0000 Received: by outflank-mailman (output) from mailman id 502751.774712; Mon, 27 Feb 2023 15:42:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWfdt-0004Bq-KN; Mon, 27 Feb 2023 15:42:21 +0000 Received: by outflank-mailman (input) for mailman id 502751; Mon, 27 Feb 2023 15:42:21 +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 1pWfds-00034v-To for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 15:42:21 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 517cd902-b6b5-11ed-a82a-c9ca1d2f71af; Mon, 27 Feb 2023 16:42:19 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 00CA91FD63; Mon, 27 Feb 2023 15:42:19 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id BFEFC13912; Mon, 27 Feb 2023 15:42:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gfKoLVrP/GOwLgAAMHmgww (envelope-from ); Mon, 27 Feb 2023 15:42:18 +0000 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: 517cd902-b6b5-11ed-a82a-c9ca1d2f71af DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677512539; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4YWfk5My0zrpM/pObahciTKOWepQnXUCCFFrc1nZeeQ=; b=YpcS6Y5moX0AY9fwb7/NHlagQD0CqMilkF98tapMM6nsaeTDfo3PuN8aeSqbvO4FnWw/aw yJyJFVRTOCFtWKHphvf+LaqTPWAIFB33Wox6U9pyqk8Fd6i+vY7ofUN88jSBkdR7h0XOxY P84fqA8k4sUG5QYVL1nlmpoKbJ72WWY= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Anthony PERARD Subject: [PATCH v2 4/4] tools: add offsetof() to xen-tools/common-macros.h Date: Mon, 27 Feb 2023 16:41:53 +0100 Message-Id: <20230227154153.31080-5-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227154153.31080-1-jgross@suse.com> References: <20230227154153.31080-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677512552798100003 Content-Type: text/plain; charset="utf-8" Instead of having multiple files defining offsetof(), add the definition to tools/include/xen-tools/common-macros.h. Signed-off-by: Juergen Gross Acked-by: Christian Lindig --- tools/firmware/hvmloader/util.h | 3 --- tools/firmware/include/stddef.h | 4 ++-- tools/include/xen-tools/common-macros.h | 4 ++++ tools/libfsimage/Rules.mk | 2 ++ tools/libfsimage/xfs/fsys_xfs.c | 4 +--- tools/libs/vchan/init.c | 4 ---- tools/tests/vhpet/emul.h | 2 -- 7 files changed, 9 insertions(+), 14 deletions(-) diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/uti= l.h index e04990ee97..7249773eeb 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -30,9 +30,6 @@ enum { #define SEL_DATA32 0x0020 #define SEL_CODE64 0x0028 =20 -#undef offsetof -#define offsetof(t, m) ((unsigned long)&((t *)0)->m) - #undef NULL #define NULL ((void*)0) =20 diff --git a/tools/firmware/include/stddef.h b/tools/firmware/include/stdde= f.h index c7f974608a..0afb426a6d 100644 --- a/tools/firmware/include/stddef.h +++ b/tools/firmware/include/stddef.h @@ -1,10 +1,10 @@ #ifndef _STDDEF_H_ #define _STDDEF_H_ =20 +#include + typedef __SIZE_TYPE__ size_t; =20 #define NULL ((void*)0) =20 -#define offsetof(t, m) __builtin_offsetof(t, m) - #endif diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-to= ols/common-macros.h index 3e73b33c91..15399e9b88 100644 --- a/tools/include/xen-tools/common-macros.h +++ b/tools/include/xen-tools/common-macros.h @@ -79,4 +79,8 @@ typeof( ((type *)0)->member ) *__mptr =3D (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) =20 +#ifndef offsetof +#define offsetof(a, b) __builtin_offsetof(a, b) +#endif + #endif /* __XEN_TOOLS_COMMON_MACROS__ */ diff --git a/tools/libfsimage/Rules.mk b/tools/libfsimage/Rules.mk index cf37d6cb0d..85674f2379 100644 --- a/tools/libfsimage/Rules.mk +++ b/tools/libfsimage/Rules.mk @@ -3,6 +3,8 @@ include $(XEN_ROOT)/tools/libfsimage/common.mk FSLIB =3D fsimage.so TARGETS +=3D $(FSLIB) =20 +CFLAGS +=3D $(CFLAGS_xeninclude) + .PHONY: all all: $(TARGETS) =20 diff --git a/tools/libfsimage/xfs/fsys_xfs.c b/tools/libfsimage/xfs/fsys_xf= s.c index d735a88e55..f562daaef0 100644 --- a/tools/libfsimage/xfs/fsys_xfs.c +++ b/tools/libfsimage/xfs/fsys_xfs.c @@ -19,6 +19,7 @@ =20 #include #include "xfs.h" +#include =20 #define MAX_LINK_COUNT 8 =20 @@ -182,9 +183,6 @@ fsb2daddr (xfs_fsblock_t fsbno) (xfs_agblock_t)(fsbno & mask32lo(xfs.agblklog))); } =20 -#undef offsetof -#define offsetof(t,m) ((size_t)&(((t *)0)->m)) - static inline int btroot_maxrecs (fsi_file_t *ffi) { diff --git a/tools/libs/vchan/init.c b/tools/libs/vchan/init.c index 021e1f29e1..ad4cc66d2c 100644 --- a/tools/libs/vchan/init.c +++ b/tools/libs/vchan/init.c @@ -69,10 +69,6 @@ #define MAX_RING_SHIFT 20 #define MAX_RING_SIZE (1 << MAX_RING_SHIFT) =20 -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - static int init_gnt_srv(struct libxenvchan *ctrl, int domain) { int pages_left =3D ctrl->read.order >=3D PAGE_SHIFT ? 1 << (ctrl->read.or= der - PAGE_SHIFT) : 0; diff --git a/tools/tests/vhpet/emul.h b/tools/tests/vhpet/emul.h index 6af880cd43..7b3ee88fb5 100644 --- a/tools/tests/vhpet/emul.h +++ b/tools/tests/vhpet/emul.h @@ -115,8 +115,6 @@ enum NR_COMMON_SOFTIRQS }; =20 -#define offsetof(t, m) ((unsigned long )&((t *)0)->m) - struct domain; =20 struct vcpu --=20 2.35.3