[igt-dev] [PATCH i-g-t] lib/drmtest.h: make ALIGN work with uint64_t values
Marcin Bernatowicz
marcin.bernatowicz at linux.intel.com
Tue Oct 17 12:54:28 UTC 2023
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 at 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
More information about the igt-dev
mailing list