Skip to content

Commit cf0769d

Browse files
anchaoxiaoxiang781216
authored andcommitted
include: Add nitems() definition to sys/param.h
Signed-off-by: chao an <[email protected]>
1 parent 3f3e090 commit cf0769d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

include/sys/param.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@
4343
# define MAX(a,b) (((a) > (b)) ? (a) : (b))
4444
#endif /* MAX */
4545

46+
/* Macros for number of items.
47+
* (aka. ARRAY_SIZE, ArraySize, Size of an Array)
48+
*/
49+
50+
#ifndef nitems
51+
# define nitems(_a) (sizeof(_a) / sizeof(0[(_a)]))
52+
#endif /* nitems */
53+
4654
/****************************************************************************
4755
* Public Type Definitions
4856
****************************************************************************/

0 commit comments

Comments
 (0)