Add ARRAY_SIZE() helper macro

There are many scenarios where it is convenient to have a helper to
evaluate the number of elements in an array. Having this helper in a
common place helps avoid duplicated code.

Change-Id: I05e9513bca756675483276cb6ae777c487f5a949
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2015-05-12 11:15:11 +03:00 committed by Anas Nashif
commit 85921c9d25

View file

@ -42,6 +42,8 @@ Misc utilities usable by nanokernel, microkernel, and application code.
extern "C" {
#endif
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#ifndef _ASMLANGUAGE
/* round "x" up/down to next multiple of "align" (which must be a power of 2) */