From nobody Thu May 16 15:10:08 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=1677499827; cv=none; d=zohomail.com; s=zohoarc; b=K7tL0URU7DxMf58evXAf7p9sYAakE1eoHW7yTMhfoFUusGv56JQ1jkdNORe9LPaEe/T0zW+EaWOeuNjCLHrlyW/HGMdOns4EVRekbd+OyChP4WzeH9R4cSu7SKTCRvxGgGVLRCvwE1XcztK28ggY6pjpkLfwuW266GOGgDFwync= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677499827; 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=ie1ECZIy0vs3ZjCA8d3JTPcaE1XIqDwSIQ7h6WLxykU=; b=ln5FnnxnaTdh5iHb6i7QQuiunQv70qx3Z6NgzyTPQ1oCGj0brbwWFnD3ewKlNm5bdriKJaBf5rYnHo0dezgu+w6NG85zNtW51UB8L1nlXUpEqBX9lKD8JnxI8S8X+jLdxqpSntNuCDOLAVJDjnT06roiASjsyngVCYE/js5dxiI= 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 1677499827976427.0815155369894; Mon, 27 Feb 2023 04:10:27 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502456.774272 (Exim 4.92) (envelope-from ) id 1pWcKa-0003Zc-Gb; Mon, 27 Feb 2023 12:10:12 +0000 Received: by outflank-mailman (output) from mailman id 502456.774272; Mon, 27 Feb 2023 12:10:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWcKa-0003ZV-DA; Mon, 27 Feb 2023 12:10:12 +0000 Received: by outflank-mailman (input) for mailman id 502456; Mon, 27 Feb 2023 12:10:11 +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 1pWcKY-00039C-TG for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 12:10:11 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ae5d68ee-b697-11ed-88bb-e56d68cac8db; Mon, 27 Feb 2023 13:10:10 +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 E49FA1FD63; Mon, 27 Feb 2023 12:10:09 +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 AA54813912; Mon, 27 Feb 2023 12:10:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id rQ1OKKGd/GPeNAAAMHmgww (envelope-from ); Mon, 27 Feb 2023 12:10:09 +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: ae5d68ee-b697-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677499809; 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=ie1ECZIy0vs3ZjCA8d3JTPcaE1XIqDwSIQ7h6WLxykU=; b=ChPKJbdiSyCpbkH3pPsThXCZB/GMcMpnBKMWxXxnY62nXuG1Z3i1/UZk3b/YX1z5h0wqzH CUnbSMUt3x4fr9Mjn8JorgFtDrYsJVuf9+YmEVDbu1x9k0IVhaIzdGJnsNoJuDyLKWz7tJ LqxHNftYfpfzbwRVDVcksWtxZIv4VjQ= 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 1/3] tools: add container_of() macro to xen-tools/libs.h Date: Mon, 27 Feb 2023 13:09:55 +0100 Message-Id: <20230227120957.10037-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227120957.10037-1-jgross@suse.com> References: <20230227120957.10037-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677499829508100003 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/libs.h and use that instead. Delete the other copies of that macro. Signed-off-by: Juergen Gross --- 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/libs.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/libs.h b/tools/include/xen-tools/libs.h index bafc90e2f6..3672486daa 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/libs.h @@ -67,4 +67,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_LIBS__ */ diff --git a/tools/tests/vhpet/emul.h b/tools/tests/vhpet/emul.h index b022cc0eab..7db47c5beb 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..237edb4e95 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 18ae40d017..0849c07dbc 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..1f469eafaf 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 15:10:08 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=1677499837; cv=none; d=zohomail.com; s=zohoarc; b=mB2vUKWXhs5zyJbO1BJ+hItBm+7CaSjqp632F0Zn6v5eXIy0oituNtSzI7wKXfX+XA38hOsIXygzBn1GZTn3sAQ4XrGmw+DjgNhK396yIZ8w0BV3rRx0NdRaNo8dW7/ScsPv4WxGeKdIJUcFhxXBL6OydUoMLMiK2GzCWwEQJq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677499837; 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=irti9dshWtZl+rE8Uu5A3Tbf4UdOJi+qh8/ebGpIp0U=; b=URhFKEVkyLuguQVI/bosTknUTs6JXfYtVFolo/GIX753/BKJsw+u2lX7ujdqPE5PrULhG62t8+TNw5SiJfhvVgFyOB1Y3ZFvnboed+38Fp6uKp+1Vk5znVcJsFVyXGVhpJ9+x1r8UbJzGqt8Wlo6zyx/yzqbjel2kI+iQnh7NaY= 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 167749983684877.18183322605307; Mon, 27 Feb 2023 04:10:36 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502457.774282 (Exim 4.92) (envelope-from ) id 1pWcKf-0003uK-Of; Mon, 27 Feb 2023 12:10:17 +0000 Received: by outflank-mailman (output) from mailman id 502457.774282; Mon, 27 Feb 2023 12:10: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 1pWcKf-0003uC-La; Mon, 27 Feb 2023 12:10:17 +0000 Received: by outflank-mailman (input) for mailman id 502457; Mon, 27 Feb 2023 12:10:16 +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 1pWcKe-00039C-9P for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 12:10:16 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [2001:67c:2178:6::1d]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b1b7b076-b697-11ed-88bb-e56d68cac8db; Mon, 27 Feb 2023 13:10:15 +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 8BDB81FD63; Mon, 27 Feb 2023 12:10:15 +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 548CD13A43; Mon, 27 Feb 2023 12:10:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cDthE6ed/GMSNQAAMHmgww (envelope-from ); Mon, 27 Feb 2023 12:10:15 +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: b1b7b076-b697-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677499815; 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=irti9dshWtZl+rE8Uu5A3Tbf4UdOJi+qh8/ebGpIp0U=; b=DsyqlgXcZ7ed7Hc7tySnhQwhCl6MMs9AABtkrZAlSlTTICyulBdNwRc2124BqIzP0D7Rv/ 1KJyNg7tmEdmYEb108GN/hwTTlU5C0weSCyQ498JNvdxzyfGQuT1X6LMqR78F1WCsttUwr aNpiljEnp93D/vapXOIsAbB84dzTzks= 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 2/3] tools: get rid of additional min() and max() definitions Date: Mon, 27 Feb 2023 13:09:56 +0100 Message-Id: <20230227120957.10037-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227120957.10037-1-jgross@suse.com> References: <20230227120957.10037-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677499837640100001 Content-Type: text/plain; charset="utf-8" Defining min(), min_t(), max() and max_t() at other places than xen-tools/libs.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 --- 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..69afcc6daa 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..ea2d7f2c54 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 7db47c5beb..efd04ed313 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 237edb4e95..bf3cef5586 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 15:10:08 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=1677499841; cv=none; d=zohomail.com; s=zohoarc; b=PD46y5S80Z5YrDbcv309RbVtyxetARaVjBqAQHJ4MJEgEmCsMo+w/3YwkS1SwHFUDOfd+RZJiQuG7g/MnrmWSdIYFIK2HN07ysUWjEv03U5a1PDIMWL4HIwAXKB6sjx06BI7SYqbig0nudZtcwYjpBUmpJqDzWDcHeX4nyeUnoA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677499841; 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=cGDTryXA/fAzaKK5uzbhHS2WMaHPYkQlraK/zFukITQ=; b=Q8ScL//i3XYRdV9vBIYj5Qzt7fwXmhcuv1dDOP5vR+0npN1nUxU/rd124ghU0Uq4/AdihhTkZMSnsd9iLhA/7AX5N/hZrE8klyDwrjJffW2xOQnw6o2ebKvozAbP/QHw6UFTwtggr2jo5iq+r09N6AM26/ApEDuef6jrWu5Nbr8= 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 1677499841180839.1874595419373; Mon, 27 Feb 2023 04:10:41 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.502461.774292 (Exim 4.92) (envelope-from ) id 1pWcKl-0004Jv-64; Mon, 27 Feb 2023 12:10:23 +0000 Received: by outflank-mailman (output) from mailman id 502461.774292; Mon, 27 Feb 2023 12:10:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pWcKl-0004Jl-37; Mon, 27 Feb 2023 12:10:23 +0000 Received: by outflank-mailman (input) for mailman id 502461; Mon, 27 Feb 2023 12:10:22 +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 1pWcKk-00039C-1h for xen-devel@lists.xenproject.org; Mon, 27 Feb 2023 12:10:22 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b5150e23-b697-11ed-88bb-e56d68cac8db; Mon, 27 Feb 2023 13:10:21 +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 352D5219F4; Mon, 27 Feb 2023 12:10:21 +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 F2CFD13A43; Mon, 27 Feb 2023 12:10:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eOUWOqyd/GMtNQAAMHmgww (envelope-from ); Mon, 27 Feb 2023 12:10:20 +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: b5150e23-b697-11ed-88bb-e56d68cac8db DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1677499821; 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=cGDTryXA/fAzaKK5uzbhHS2WMaHPYkQlraK/zFukITQ=; b=ktEbKrX7zS6S6jjNsOHtDjW+Yjfy7KrBBqH0J7LVRf782Ms0e5pckmG4oOnpA9EgjvrmLe ZBozM4YbPwZp7CGu8jCAJPWIGaVnj8/s0qnVa7QkIXMBsSOJlZcXV5n72cXCHaeLERNd9O 26fISx2GyB68ZvLZpNFF9+rESgbDCio= 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 3/3] tools: add offsetof() to xen-tools/libs.h Date: Mon, 27 Feb 2023 13:09:57 +0100 Message-Id: <20230227120957.10037-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230227120957.10037-1-jgross@suse.com> References: <20230227120957.10037-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1677499841642100001 Content-Type: text/plain; charset="utf-8" Instead of having multiple files defining offsetof(), add the definition to tools/include/xen-tools/libs.h. Signed-off-by: Juergen Gross --- tools/firmware/hvmloader/util.h | 3 --- tools/firmware/include/stddef.h | 4 ++-- tools/include/xen-tools/libs.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 69afcc6daa..668ee74f3c 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..926ae12fa5 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/libs.h b/tools/include/xen-tools/libs.h index 3672486daa..c222aa5bb0 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/libs.h @@ -71,4 +71,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_LIBS__ */ 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..4c0cde9777 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 ea2d7f2c54..9c0c5ca0c5 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 efd04ed313..2eeefa7098 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