diff options
author | KP Singh <kpsingh@kernel.org> | 2024-08-16 18:43:05 +0300 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2024-08-20 21:05:33 +0300 |
commit | 7cff549daa67c7549c5a8688674cea2df8c2ec80 (patch) | |
tree | ac4d70deb0a47097651c7eb9615c59f693f31f5f /include/linux/lsm_count.h | |
parent | 77b644c39d6afc0b2985807c74d95335931f6403 (diff) | |
download | linux-7cff549daa67c7549c5a8688674cea2df8c2ec80.tar.xz |
kernel: Add helper macros for loop unrolling
This helps in easily initializing blocks of code (e.g. static calls and
keys).
UNROLL(N, MACRO, __VA_ARGS__) calls MACRO N times with the first
argument as the index of the iteration. This allows string pasting to
create unique tokens for variable names, function calls etc.
As an example:
#include <linux/unroll.h>
#define MACRO(N, a, b) \
int add_##N(int a, int b) \
{ \
return a + b + N; \
}
UNROLL(2, MACRO, x, y)
expands to:
int add_0(int x, int y)
{
return x + y + 0;
}
int add_1(int x, int y)
{
return x + y + 1;
}
Tested-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Casey Schaufler <casey@schaufler-ca.com>
Reviewed-by: John Johansen <john.johansen@canonical.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Song Liu <song@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
Nacked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: KP Singh <kpsingh@kernel.org>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'include/linux/lsm_count.h')
0 files changed, 0 insertions, 0 deletions