diff mbox series

[v5,2/3] Adding a shared ARRAY_SIZE macro.

Message ID 20200107012820.158721-2-alainm@chromium.org
State New
Headers show
Series None | expand

Commit Message

Alain Michaud Jan. 7, 2020, 1:28 a.m. UTC
This will allow other implementations within src/ to use a single
definition of the ARRAY_SIZE macro.
---

 src/shared/util.h | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/src/shared/util.h b/src/shared/util.h
index 604dc3be4..9193068d1 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -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)