From: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t] lib/drmtest.h: make ALIGN work with uint64_t values
Date: Tue, 17 Oct 2023 12:54:28 +0000 [thread overview]
Message-ID: <20231017125428.607100-1-marcin.bernatowicz@linux.intel.com> (raw)
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 <marcin.bernatowicz@linux.intel.com>
---
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
next reply other threads:[~2023-10-17 13:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 12:54 Marcin Bernatowicz [this message]
2023-10-17 14:15 ` [igt-dev] ✓ Fi.CI.BAT: success for lib/drmtest.h: make ALIGN work with uint64_t values Patchwork
2023-10-17 14:19 ` [igt-dev] ✓ CI.xeBAT: " Patchwork
2023-10-17 15:43 ` [igt-dev] [PATCH i-g-t] " Kamil Konieczny
2023-10-17 19:15 ` [igt-dev] ✗ Fi.CI.IGT: failure for " Patchwork
2023-11-30 14:01 ` Kamil Konieczny
2023-12-01 11:44 ` Illipilli, TejasreeX
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231017125428.607100-1-marcin.bernatowicz@linux.intel.com \
--to=marcin.bernatowicz@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox