include: Add nitems() definition to sys/param.h

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-02-02 20:30:31 +08:00 committed by Xiang Xiao
parent 3f3e090716
commit cf0769d613

View File

@ -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
****************************************************************************/