[PATCH 02/34] scripts/include: Add ARRAY_SIZE

Sascha Hauer s.hauer at pengutronix.de
Tue Feb 2 06:47:45 PST 2016


ARRAY_SIZE is another define commonly used in tools. Add it to the
kernel includes.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 scripts/include/linux/kernel.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/include/linux/kernel.h b/scripts/include/linux/kernel.h
index 76df535..5d94e98 100644
--- a/scripts/include/linux/kernel.h
+++ b/scripts/include/linux/kernel.h
@@ -6,6 +6,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
 
 #define PERF_ALIGN(x, a)	__PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
-- 
2.7.0.rc3




More information about the barebox mailing list