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 */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to