This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit cf0769d6135dafdd7ed25e315b68c7005dfe808e
Author: chao an <anc...@xiaomi.com>
AuthorDate: Thu Feb 2 20:30:31 2023 +0800

    include: Add nitems() definition to sys/param.h
    
    Signed-off-by: chao an <anc...@xiaomi.com>
---
 include/sys/param.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/sys/param.h b/include/sys/param.h
index 4e94f51bbc..831a552eae 100644
--- a/include/sys/param.h
+++ b/include/sys/param.h
@@ -43,6 +43,14 @@
 #  define MAX(a,b)      (((a) > (b)) ? (a) : (b))
 #endif  /* MAX */
 
+/* Macros for number of items.
+ * (aka. ARRAY_SIZE, ArraySize, Size of an Array)
+ */
+
+#ifndef nitems
+#  define nitems(_a)    (sizeof(_a) / sizeof(0[(_a)]))
+#endif /* nitems */
+
 /****************************************************************************
  * Public Type Definitions
  ****************************************************************************/

Reply via email to