shared/util: Adding a shared ARRAY_SIZE macro
authorAlain Michaud <alainm@chromium.org>
Tue, 7 Jan 2020 01:28:20 +0000 (01:28 +0000)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 12 Apr 2021 09:00:48 +0000 (14:30 +0530)
This will allow other implementations within src/ to use a single
definition of the ARRAY_SIZE macro.

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
src/shared/util.h

index 604dc3b..9193068 100755 (executable)
@@ -27,6 +27,8 @@
 #include <byteswap.h>
 #include <string.h>
 
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
 #if __BYTE_ORDER == __LITTLE_ENDIAN
 #define le16_to_cpu(val) (val)
 #define le32_to_cpu(val) (val)