Add nitems(), a macro for determining the number of elements in a

statically-allocated array.

Obtained from:	OpenBSD (in principle)
MFC after:	3 days
This commit is contained in:
marius 2012-06-02 19:30:49 +00:00
parent e32a51888c
commit f77bb430b9

View File

@ -273,6 +273,7 @@
#ifndef howmany
#define howmany(x, y) (((x)+((y)-1))/(y))
#endif
#define nitems(x) (sizeof((x)) / sizeof((x)[0]))
#define rounddown(x, y) (((x)/(y))*(y))
#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */