]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
kconfig: move ARRAY_SIZE to a header
authorMasahiro Yamada <masahiroy@kernel.org>
Fri, 2 Feb 2024 15:58:21 +0000 (00:58 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Mon, 19 Feb 2024 09:20:41 +0000 (18:20 +0900)
To use ARRAY_SIZE from other files, move it to its own header,
just like include/linux/array_size.h.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/array_size.h [new file with mode: 0644]
scripts/kconfig/preprocess.c

diff --git a/scripts/kconfig/array_size.h b/scripts/kconfig/array_size.h
new file mode 100644 (file)
index 0000000..26ba78d
--- /dev/null
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef ARRAY_SIZE_H
+#define ARRAY_SIZE_H
+
+/**
+ * ARRAY_SIZE - get the number of elements in array @arr
+ * @arr: array to be sized
+ */
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+#endif /* ARRAY_SIZE_H */
index 69b806a6d8b7c79193a8e22f48142c87ee9b0ff4..f0a4a218c4a5178a87722cc12e6ed6cb71baa82d 100644 (file)
@@ -9,13 +9,12 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include "array_size.h"
 #include "internal.h"
 #include "list.h"
 #include "lkc.h"
 #include "preprocess.h"
 
-#define ARRAY_SIZE(arr)                (sizeof(arr) / sizeof((arr)[0]))
-
 static char *expand_string_with_args(const char *in, int argc, char *argv[]);
 static char *expand_string(const char *in);