diff options
author | marius <marius@FreeBSD.org> | 2012-06-02 19:30:49 +0000 |
---|---|---|
committer | marius <marius@FreeBSD.org> | 2012-06-02 19:30:49 +0000 |
commit | f77bb430b978d6d77c19a7b3ff50b5c4d662b8df (patch) | |
tree | 9e1c93a252cdb5b36dcbbb47e45dfdb86a3b345e | |
parent | e32a51888c8ecea8864ed7973d94a54c7dadeebf (diff) | |
download | FreeBSD-src-f77bb430b978d6d77c19a7b3ff50b5c4d662b8df.zip FreeBSD-src-f77bb430b978d6d77c19a7b3ff50b5c4d662b8df.tar.gz |
Add nitems(), a macro for determining the number of elements in a
statically-allocated array.
Obtained from: OpenBSD (in principle)
MFC after: 3 days
-rw-r--r-- | sys/sys/param.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/sys/param.h b/sys/sys/param.h index 240fd26..b04f6b8 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -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 */ |