]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared/macro: Add _alignedptr_
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 3 Jan 2025 20:35:10 +0000 (14:35 -0600)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sat, 4 Jan 2025 04:44:18 +0000 (22:44 -0600)
Peek what systemd does and do something similar. Instead of hardcoding
8, add a ptr abstraction for the aligned attribute.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/274
shared/macro.h
testsuite/testsuite.h

index 3e8143f84e221402ab4cb9dc2b3bf1d1d0ccf17a..8829d0b65df17ab7963303a0480dd62b2ef66d63 100644 (file)
@@ -49,6 +49,7 @@
 #define _retain_ __attribute((retain))
 #define _section_(a) __attribute((section(a)))
 #define _aligned_(a) __attribute((aligned(a)))
+#define _alignedptr_ _aligned_(sizeof(void *))
 
 #if defined(__clang_analyzer__)
 #define _clang_suppress_ __attribute__((suppress))
index eca276d555839411cd6d529dbc0cdc6f877fdd88..2ea50a525535b9b98e6d3e95fb3179655f8a8c2b 100644 (file)
@@ -132,7 +132,7 @@ int test_run(const struct test *t);
        _used_                                                                           \
        _retain_                                                                         \
        _section_("kmod_tests")                                                          \
-       _aligned_(8)                                                                     \
+       _alignedptr_                                                                     \
        static const struct test UNIQ(s##_name) = {                                      \
                .name = #_name, .func = _func, ##__VA_ARGS__                             \
        };