Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [igt-dev] [PATCH i-g-t] lib/drmtest.h: make ALIGN work with uint64_t values
@ 2023-10-17 12:54 Marcin Bernatowicz
  2023-10-17 14:15 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Marcin Bernatowicz @ 2023-10-17 12:54 UTC (permalink / raw)
  To: igt-dev

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



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-12-01 11:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17 12:54 [igt-dev] [PATCH i-g-t] lib/drmtest.h: make ALIGN work with uint64_t values Marcin Bernatowicz
2023-10-17 14:15 ` [igt-dev] ✓ Fi.CI.BAT: success for " 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox