]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared/macro: Add macros for more attributes
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 3 Jan 2025 20:32:00 +0000 (14:32 -0600)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sat, 4 Jan 2025 04:44:18 +0000 (22:44 -0600)
Move attributes from test definition to a wrapper macro.

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 4cbdc7aad4fbd292861e280b9d814103b33d970f..3e8143f84e221402ab4cb9dc2b3bf1d1d0ccf17a 100644 (file)
 #define _printf_format_(a, b) __attribute__((format(printf, a, b)))
 #define _always_inline_ __inline__ __attribute__((always_inline))
 #define _sentinel_ __attribute__((sentinel))
+#define _used_ __attribute((used))
+#define _retain_ __attribute((retain))
+#define _section_(a) __attribute((section(a)))
+#define _aligned_(a) __attribute((aligned(a)))
 
 #if defined(__clang_analyzer__)
 #define _clang_suppress_ __attribute__((suppress))
index 9486622ac4ded61dbbbf4ebe197c083deae23ea8..eca276d555839411cd6d529dbc0cdc6f877fdd88 100644 (file)
@@ -129,8 +129,11 @@ int test_run(const struct test *t);
 // clang-format off: At least up to version 18, it just makes a mess with _Pragma()
 #define DEFINE_TEST_WITH_FUNC(_name, _func, ...)                                         \
        _Pragma("GCC diagnostic ignored \"-Wattributes\"")                               \
-       static const struct test UNIQ(s##_name)                                          \
-       __attribute__((retain, used, section("kmod_tests"), aligned(8))) = {             \
+       _used_                                                                           \
+       _retain_                                                                         \
+       _section_("kmod_tests")                                                          \
+       _aligned_(8)                                                                     \
+       static const struct test UNIQ(s##_name) = {                                      \
                .name = #_name, .func = _func, ##__VA_ARGS__                             \
        };
 // clang-format on