Date: Sat, 2 Jun 2012 19:30:49 +0000 (UTC) From: Marius Strobl <marius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r236486 - head/sys/sys Message-ID: <201206021930.q52JUnOY009540@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: marius Date: Sat Jun 2 19:30:49 2012 New Revision: 236486 URL: http://svn.freebsd.org/changeset/base/236486 Log: Add nitems(), a macro for determining the number of elements in a statically-allocated array. Obtained from: OpenBSD (in principle) MFC after: 3 days Modified: head/sys/sys/param.h Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Sat Jun 2 19:21:34 2012 (r236485) +++ head/sys/sys/param.h Sat Jun 2 19:30:49 2012 (r236486) @@ -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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206021930.q52JUnOY009540>