From nobody Mon Feb 9 19:07:36 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; 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 ARC-Seal: i=1; a=rsa-sha256; t=1598175364; cv=none; d=zohomail.com; s=zohoarc; b=dTmZUj0FGst6bkNONDnYjYpzjk6lCH7n4HjAtwJcBAOp+DnGIyUztQbVne+oerNDUnJrrzmbcZFJx9CYNhGjML+YY91cKQ2iWg4rg/HE0hS5b2ywfDZFQdemEPPaP60ZpzwMLvHkhDA/Vz99GuxGbSOkZk5RNEEEVaZ6ZA08Qj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598175364; 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=omIBslkZ3gf3dpqWkHfDHOnm/Nq6WLEGLQWj8JWzHyU=; b=HYFjzTw3Oiz8O0GJz0aLYguZ0Er5Ls1tE1gtjhMtluERZPpwmsY0c3DuueUQYJ+N3Z2H6YAc4ismUKjC3Sif1pcv3pYmdPuW6IXF5uiwYUS/KeRQ4vOuWnZEfa1jWHYmD6K9fD9KADhgDdiG+CP1ln79c/C8DyYhb2p0kzcsiQI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1598175364145726.8390759913577; Sun, 23 Aug 2020 02:36:04 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k9mPX-0004wq-MX; Sun, 23 Aug 2020 09:35:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1k9mPW-0004sy-F8 for xen-devel@lists.xenproject.org; Sun, 23 Aug 2020 09:35:34 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 37512d6a-d983-48be-a810-28b218093e3f; Sun, 23 Aug 2020 09:35:24 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id C87D1AD6F; Sun, 23 Aug 2020 09:35:52 +0000 (UTC) X-Inumbo-ID: 37512d6a-d983-48be-a810-28b218093e3f X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Ian Jackson , Wei Liu , Anthony PERARD Subject: [PATCH v3 05/38] tools: define ROUNDUP() in tools/include/xen-tools/libs.h Date: Sun, 23 Aug 2020 11:34:46 +0200 Message-Id: <20200823093519.18386-6-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200823093519.18386-1-jgross@suse.com> References: <20200823093519.18386-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Content-Type: text/plain; charset="utf-8" Today there are multiple copies of the ROUNDUP() macro in various sources and headers. Define it once in tools/include/xen-tools/libs.h. Using xen-tools/libs.h enables removing copies of MIN() and MAX(), too. Signed-off-by: Juergen Gross Acked-by: Wei Liu --- tools/console/daemon/io.c | 6 +----- tools/include/xen-tools/libs.h | 4 ++++ tools/libs/call/buffer.c | 3 +-- tools/libs/foreignmemory/linux.c | 3 +-- tools/libs/gnttab/private.h | 3 --- tools/libxc/xg_private.h | 1 - tools/libxl/libxl_internal.h | 3 --- tools/xenstore/xenstored_core.c | 2 -- 8 files changed, 7 insertions(+), 18 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index a43c57edad..4af27ffc5d 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -49,9 +49,7 @@ #include #include #endif - -#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#define MIN(a, b) (((a) < (b)) ? (a) : (b)) +#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) @@ -80,8 +78,6 @@ static struct pollfd *fds; static unsigned int current_array_size; static unsigned int nr_fds; =20 -#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) - struct buffer { char *data; size_t consumed; diff --git a/tools/include/xen-tools/libs.h b/tools/include/xen-tools/libs.h index cc7dfc8c64..a16e0c3807 100644 --- a/tools/include/xen-tools/libs.h +++ b/tools/include/xen-tools/libs.h @@ -59,4 +59,8 @@ }) #endif =20 +#ifndef ROUNDUP +#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) +#endif + #endif /* __XEN_TOOLS_LIBS__ */ diff --git a/tools/libs/call/buffer.c b/tools/libs/call/buffer.c index 0b6af2db60..085674d882 100644 --- a/tools/libs/call/buffer.c +++ b/tools/libs/call/buffer.c @@ -16,14 +16,13 @@ #include #include #include +#include =20 #include "private.h" =20 #define DBGPRINTF(_m...) \ xtl_log(xcall->logger, XTL_DEBUG, -1, "xencall:buffer", _m) =20 -#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) - pthread_mutex_t cache_mutex =3D PTHREAD_MUTEX_INITIALIZER; =20 static void cache_lock(xencall_handle *xcall) diff --git a/tools/libs/foreignmemory/linux.c b/tools/libs/foreignmemory/li= nux.c index 8daa5828e3..fe73d5ab72 100644 --- a/tools/libs/foreignmemory/linux.c +++ b/tools/libs/foreignmemory/linux.c @@ -25,11 +25,10 @@ =20 #include #include +#include =20 #include "private.h" =20 -#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) - #ifndef O_CLOEXEC #define O_CLOEXEC 0 #endif diff --git a/tools/libs/gnttab/private.h b/tools/libs/gnttab/private.h index c5e23639b1..eb6a6abe54 100644 --- a/tools/libs/gnttab/private.h +++ b/tools/libs/gnttab/private.h @@ -5,9 +5,6 @@ #include #include =20 -/* Set of macros/defines used by both Linux and FreeBSD */ -#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) - #define GTERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gnttab", _f) #define GSERROR(_l, _f...) xtl_log(_l, XTL_ERROR, errno, "gntshr", _f) =20 diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h index f0a4b2c616..40b5baecde 100644 --- a/tools/libxc/xg_private.h +++ b/tools/libxc/xg_private.h @@ -95,7 +95,6 @@ typedef uint64_t x86_pgentry_t; #define PAGE_SIZE_X86 (1UL << PAGE_SHIFT_X86) #define PAGE_MASK_X86 (~(PAGE_SIZE_X86-1)) =20 -#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w)= )-1)) #define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT) =20 =20 diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index 94a23179d3..c63d0686fd 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -132,9 +132,6 @@ #define MB(_mb) (_AC(_mb, ULL) << 20) #define GB(_gb) (_AC(_gb, ULL) << 30) =20 -#define ROUNDUP(_val, _order) \ - (((unsigned long)(_val)+(1UL<<(_order))-1) & ~((1UL<<(_order))-1)) - #define DIV_ROUNDUP(n, d) (((n) + (d) - 1) / (d)) =20 #define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_cor= e.c index 7bd959f28b..9700772d40 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -73,8 +73,6 @@ static unsigned int nr_fds; static int sock =3D -1; static int ro_sock =3D -1; =20 -#define ROUNDUP(_x, _w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w= ))-1)) - static bool verbose =3D false; LIST_HEAD(connections); int tracefd =3D -1; --=20 2.26.2