[v1,1/3] kernel.h: Don't pollute header with single user macros
Commit Message
The COUNT_ARGS() and CONCATENATE() macros are used by a single user.
Let move them to it.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/kernel.h | 7 -------
include/trace/bpf_probe.h | 7 +++++++
2 files changed, 7 insertions(+), 7 deletions(-)
Comments
On Tue, Jul 13, 2021 at 11:45:39AM +0300, Andy Shevchenko wrote:
> The COUNT_ARGS() and CONCATENATE() macros are used by a single user.
> Let move them to it.
That seems to be because people like re-implementing it instead of
reusing existing ones:
arch/x86/include/asm/efi.h:#define __efi_nargs__(_0, _1, _2, _3, _4, _5, _6, _7, n, ...) \
arch/x86/include/asm/rmwcc.h:#define __RMWcc_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
include/linux/arm-smccc.h:#define ___count_args(_0, _1, _2, _3, _4, _5, _6, _7, _8, x, ...) x
include/linux/kernel.h:#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
On Tue, Jul 13, 2021 at 3:41 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Tue, Jul 13, 2021 at 11:45:39AM +0300, Andy Shevchenko wrote:
> > The COUNT_ARGS() and CONCATENATE() macros are used by a single user.
> > Let move them to it.
>
> That seems to be because people like re-implementing it instead of
> reusing existing ones:
>
> arch/x86/include/asm/efi.h:#define __efi_nargs__(_0, _1, _2, _3, _4, _5, _6, _7, n, ...) \
> arch/x86/include/asm/rmwcc.h:#define __RMWcc_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
> include/linux/arm-smccc.h:#define ___count_args(_0, _1, _2, _3, _4, _5, _6, _7, _8, x, ...) x
> include/linux/kernel.h:#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
Good catch!
I will redo this, thanks!
@@ -476,13 +476,6 @@ ftrace_vprintk(const char *fmt, va_list ap)
static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }
#endif /* CONFIG_TRACING */
-/* This counts to 12. Any more, it will return 13th argument. */
-#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
-#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-
-#define __CONCAT(a, b) a ## b
-#define CONCATENATE(a, b) __CONCAT(a, b)
-
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.
@@ -27,6 +27,13 @@
#undef __perf_task
#define __perf_task(t) (t)
+/* This counts to 12. Any more, it will return 13th argument. */
+#define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n
+#define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+#define __CONCAT(a, b) a ## b
+#define CONCATENATE(a, b) __CONCAT(a, b)
+
/* cast any integer, pointer, or small struct to u64 */
#define UINTTYPE(size) \
__typeof__(__builtin_choose_expr(size == 1, (u8)1, \