diff options
author | Zachary T Welch <zw@superlucidity.net> | 2009-11-16 03:29:30 -0800 |
---|---|---|
committer | Zachary T Welch <zw@superlucidity.net> | 2009-11-16 09:58:11 -0800 |
commit | dc1685ca25567fe75c8d50c825fb0303fbb66fac (patch) | |
tree | e51e63fe1e40d3c60673f57784f88c43277f5eba /src/helper | |
parent | 10cce4a5fe85bfd680bc338c900b0033d7174b6a (diff) | |
download | openocd_libswd-dc1685ca25567fe75c8d50c825fb0303fbb66fac.tar.gz openocd_libswd-dc1685ca25567fe75c8d50c825fb0303fbb66fac.tar.bz2 openocd_libswd-dc1685ca25567fe75c8d50c825fb0303fbb66fac.tar.xz openocd_libswd-dc1685ca25567fe75c8d50c825fb0303fbb66fac.zip |
move ARRAY_SIZE macro to types.h
The ARRAY_SIZE macro was defined in several target files, so move it
to types.h.
This patch also removes two other identical macros: DIM (from jtag.h)
and asizeof (from arm11.h).
Diffstat (limited to 'src/helper')
-rw-r--r-- | src/helper/types.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/helper/types.h b/src/helper/types.h index 8f6283b5..96a923b8 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -61,6 +61,16 @@ typedef bool _Bool; /** + * Compute the number of elements of a variable length array. + * <code> + * const char *strs[] = { "a", "b", "c" }; + * unsigned num_strs = ARRAY_SIZE(strs); + * </code> + */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) + + +/** * Cast a member of a structure out to the containing structure. * @param ptr The pointer to the member. * @param type The type of the container struct this is embedded in. |