From patchwork Thu Mar 23 09:08:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 13185294 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 C983BC7619A for ; Thu, 23 Mar 2023 09:09:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.513691.795076 (Exim 4.92) (envelope-from ) id 1pfGwY-0004xw-8t; Thu, 23 Mar 2023 09:09:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 513691.795076; Thu, 23 Mar 2023 09:09: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 1pfGwY-0004xp-6N; Thu, 23 Mar 2023 09:09:10 +0000 Received: by outflank-mailman (input) for mailman id 513691; Thu, 23 Mar 2023 09:09: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 1pfGwW-0004iI-Ss for xen-devel@lists.xenproject.org; Thu, 23 Mar 2023 09:09:08 +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 5dc64794-c95a-11ed-85db-49a42c6b2330; Thu, 23 Mar 2023 10:09: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-out2.suse.de (Postfix) with ESMTPS id 4B4125BF35; Thu, 23 Mar 2023 09:09: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 46A5D13596; Thu, 23 Mar 2023 09:09:07 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id siHQDzMXHGQQPAAAMHmgww (envelope-from ); Thu, 23 Mar 2023 09:09:07 +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: 5dc64794-c95a-11ed-85db-49a42c6b2330 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1679562547; 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=tK/VfAs+HwoOwyc0XN0NF5mz6F3pkkpHh5nlaBVfidg=; b=Hm273TDuSugT/TtFetQzGJarVQ+BKeW4zz6s1JRyY7TPhjcaW5j/rMZhlXAfH8zbtU3yEm HZLXkc7J4C5UEw4X3rlWKyUjvqnGThunj+dMaocQFhi0VTQ5nvCBPMLyYn3edQyomeoYH3 QuFwP5066gzD19Nvd9f2aBBmDLKm8Fc= 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 v5 1/5] tools: get rid of additional min() and max() definitions Date: Thu, 23 Mar 2023 10:08:55 +0100 Message-Id: <20230323090859.25240-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230323090859.25240-1-jgross@suse.com> References: <20230323090859.25240-1-jgross@suse.com> MIME-Version: 1.0 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: Jan Beulich Acked-by: Anthony PERARD --- V5: - change patch sequence --- tools/firmware/hvmloader/util.h | 8 ++------ tools/libs/vchan/init.c | 3 +-- tools/tests/vpci/Makefile | 2 +- tools/tests/vpci/emul.h | 18 ++---------------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.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" +#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..021e1f29e1 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/vpci/Makefile b/tools/tests/vpci/Makefile index 5075bc2be2..62f21f341a 100644 --- a/tools/tests/vpci/Makefile +++ b/tools/tests/vpci/Makefile @@ -11,7 +11,7 @@ run: $(TARGET) ./$(TARGET) $(TARGET): vpci.c vpci.h list.h main.c emul.h - $(HOSTCC) -g -o $@ vpci.c main.c + $(HOSTCC) $(CFLAGS_xeninclude) -g -o $@ vpci.c main.c .PHONY: clean clean: diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h index f03e3a56d1..d26e00b9d7 100644 --- a/tools/tests/vpci/emul.h +++ b/tools/tests/vpci/emul.h @@ -27,6 +27,8 @@ #include #include +#include + #define container_of(ptr, type, member) ({ \ typeof(((type *)0)->member) *mptr = (ptr); \ \ @@ -110,22 +112,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 /*