mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 02:36:02 +00:00
d51e783c17
These macros are a clever trick to determine a count of the number of LSMs that are enabled in the config to ascertain the maximum number of static calls that need to be configured per LSM hook. Without this one would need to generate static calls for the total number of LSMs in the kernel (even if they are not compiled) times the number of LSM hooks which ends up being quite wasteful. Tested-by: Guenter Roeck <linux@roeck-us.net> Suggested-by: Kui-Feng Lee <sinquersw@gmail.com> Suggested-by: Andrii Nakryiko <andrii@kernel.org> 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: Casey Schaufler <casey@schaufler-ca.com> Acked-by: Song Liu <song@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Nacked-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: KP Singh <kpsingh@kernel.org> [PM: added IPE to the count during merge] Signed-off-by: Paul Moore <paul@paul-moore.com>
29 lines
1021 B
C
29 lines
1021 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef _LINUX_ARGS_H
|
|
#define _LINUX_ARGS_H
|
|
|
|
/*
|
|
* How do these macros work?
|
|
*
|
|
* In __COUNT_ARGS() _0 to _12 are just placeholders from the start
|
|
* in order to make sure _n is positioned over the correct number
|
|
* from 12 to 0 (depending on X, which is a variadic argument list).
|
|
* They serve no purpose other than occupying a position. Since each
|
|
* macro parameter must have a distinct identifier, those identifiers
|
|
* are as good as any.
|
|
*
|
|
* In COUNT_ARGS() we use actual integers, so __COUNT_ARGS() returns
|
|
* that as _n.
|
|
*/
|
|
|
|
/* This counts to 15. Any more, it will return 16th argument. */
|
|
#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _n, X...) _n
|
|
#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
|
|
|
|
/* Concatenate two parameters, but allow them to be expanded beforehand. */
|
|
#define __CONCAT(a, b) a ## b
|
|
#define CONCATENATE(a, b) __CONCAT(a, b)
|
|
|
|
#endif /* _LINUX_ARGS_H */
|