git: af187b20cdb0 - main - linuxkpi: Define `COUNT_ARGS()` and `CONCATENATE()`

From: Jean-Sébastien Pédron <dumbbell_at_FreeBSD.org>
Date: Sat, 20 Jun 2026 11:53:58 UTC
The branch main has been updated by dumbbell:

URL: https://cgit.FreeBSD.org/src/commit/?id=af187b20cdb00b89a39dfea1a8eef41ce5c134aa

commit af187b20cdb00b89a39dfea1a8eef41ce5c134aa
Author:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2026-06-12 20:21:12 +0000
Commit:     Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2026-06-20 10:35:51 +0000

    linuxkpi: Define `COUNT_ARGS()` and `CONCATENATE()`
    
    `COUNT_ARGS()` counts the number of arguments it is passed. The
    implementation is heavily inspired from the one of `CTR()`.
    
    `CONCATENATE()` is an alias for `__CONCAT()`.
    
    Reviewed by:    emaste
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D57584
---
 sys/compat/linuxkpi/common/include/linux/args.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/args.h b/sys/compat/linuxkpi/common/include/linux/args.h
new file mode 100644
index 000000000000..74c9e43345db
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/linux/args.h
@@ -0,0 +1,17 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 The FreeBSD Foundation
+ */
+
+#ifndef	_LINUXKPI_LINUX_ARGS_H_
+#define	_LINUXKPI_LINUX_ARGS_H_
+
+#define	__COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, __count, ...)	\
+    __count
+#define	COUNT_ARGS(X...) \
+    __COUNT_ARGS(, ##X, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+#define	CONCATENATE(a, b)	__CONCAT(a, b)
+
+#endif /* _LINUXKPI_LINUX_ARGS_H_ */