X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fhelper%2Ftypes.h;h=03ab5f0c2edd03ef2c8afa168c1b9f8343c54691;hp=8f6283b57bdd8878a8c4b5dfddfb6e45568f6f17;hb=4d8d1d32d0f0e0b8866a06cb1d3f304563fa6796;hpb=a94748ec6da9bdc6e25a7f73bbea723b8b55fa33 diff --git a/src/helper/types.h b/src/helper/types.h index 8f6283b57b..03ab5f0c2e 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -60,6 +60,16 @@ typedef bool _Bool; #define __stringify(s) #s +/** + * Compute the number of elements of a variable length array. + * + * const char *strs[] = { "a", "b", "c" }; + * unsigned num_strs = ARRAY_SIZE(strs); + * + */ +#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. @@ -75,8 +85,8 @@ typedef bool _Bool; /** * Rounds @c m up to the nearest multiple of @c n using division. - * @params m The value to round up to @c n. - * @params n Round @c m up to a multiple of this number. + * @param m The value to round up to @c n. + * @param n Round @c m up to a multiple of this number. * @returns The rounded integer value. */ #define DIV_ROUND_UP(m, n) (((m) + (n) - 1) / (n))