From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3AEA410E30F for ; Tue, 17 Oct 2023 13:27:50 +0000 (UTC) From: Marcin Bernatowicz Date: Tue, 17 Oct 2023 12:54:28 +0000 Message-ID: <20231017125428.607100-1-marcin.bernatowicz@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [igt-dev] [PATCH i-g-t] lib/drmtest.h: make ALIGN work with uint64_t values List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: igt-dev@lists.freedesktop.org List-ID: Let alignment be the same type as aligned value. Based on kernel code. This should fix code like: uint32_t a = 4096; uint64_t v = 32768ULL * 32768 * 4; v = ALIGN(v, a); Signed-off-by: Marcin Bernatowicz --- lib/drmtest.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/drmtest.h b/lib/drmtest.h index 97ab6e759..524d81b7a 100644 --- a/lib/drmtest.h +++ b/lib/drmtest.h @@ -87,7 +87,8 @@ void __set_forced_driver(const char *name); * * Macro to align a value @v to a specified unit @a. */ -#define ALIGN(v, a) (((v) + (a)-1) & ~((a)-1)) +#define ALIGN(v, a) ALIGN_MASK(v, (typeof(v))(a) - 1) +#define ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask)) /** * ALIGN_DOWN: -- 2.42.0