Skip to content

Commit

Permalink
util: add common ARRAY_SIZE define
Browse files Browse the repository at this point in the history
I want to use this in more places, so put it in util.h rather than
copying & pasting it into another file.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
  • Loading branch information
vapier authored and dgibson committed May 24, 2013
1 parent b9e8065 commit 4ad49c3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 0 additions & 2 deletions convert-dtsv0-lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ static int saw_hyphen; /* = 0 */
static unsigned long long last_val;
static char *last_name; /* = NULL */

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

const struct {
const char *pattern;
int obase, width;
Expand Down
1 change: 0 additions & 1 deletion dtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ typedef uint32_t cell_t;
#define strneq(a, b, n) (strncmp((a), (b), (n)) == 0)

#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

/* Data blobs */
enum markertype {
Expand Down
2 changes: 2 additions & 0 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* USA
*/

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

static inline void __attribute__((noreturn)) die(const char *str, ...)
{
va_list ap;
Expand Down

0 comments on commit 4ad49c3

Please sign in to comment.