From patchwork Mon Feb 27 12:09:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 13153393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58DB2C64ED6 for ; Mon, 27 Feb 2023 12:10:24 +0000 (UTC) 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 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/util.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" +#include + /* Request un-prefixed values from errno.h. */ #define XEN_ERRNO(name, value) name = 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 = (x); type __y = (y); __x < __y ? __x: __y; }) -#define max_t(type,x,y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) #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 #include "vchan.h" @@ -72,8 +73,6 @@ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) #endif -#define max(a,b) ((a > b) ? a : b) - static int init_gnt_srv(struct libxenvchan *ctrl, int domain) { int pages_left = ctrl->read.order >= PAGE_SHIFT ? 1 << (ctrl->read.order - 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 = (x); type __y = (y); __x < __y ? __x : __y; }) -#define max_t(type, x, y) \ - ({ type __x = (x); type __y = (y); __x > __y ? __x : __y; }) + #define offsetof(t, m) ((unsigned long )&((t *)0)->m) 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) -#define min(x, y) ({ \ - const typeof(x) tx = (x); \ - const typeof(y) ty = (y); \ - \ - (void) (&tx == &ty); \ - tx < ty ? tx : ty; \ -}) - -#define max(x, y) ({ \ - const typeof(x) tx = (x); \ - const typeof(y) ty = (y); \ - \ - (void) (&tx == &ty); \ - tx > ty ? tx : ty; \ -}) - #endif /*