summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-04-26 20:02:07 -0700
committerChromeBot <chrome-bot@google.com>2013-04-29 11:05:08 -0700
commitd9bddaa0722d2b95c9b72c9c3a24c33053381311 (patch)
tree9db87c5dbf220fed30d9caca8a10a0aa2a61039c /util
parent7cebaa0a017d734ae9dda19a39fd867463f785c6 (diff)
downloadchrome-ec-d9bddaa0722d2b95c9b72c9c3a24c33053381311.tar.gz
Improved the BUILD_ASSERT macro to work outside of functions.
This will let us check the size of static array initializers. Also moved this macro definition and ARRAY_SIZE into a new "tricks.h" header, so that userspace utils can use it too. BUG=none BRANCH=none TEST=manual Built everything, tested on Link. Tried various assertions. Change-Id: I612891108ea37dbca3572e0f25ab54a7bc0ed860 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49417 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/ectool.c4
-rw-r--r--util/lbplay.c5
2 files changed, 2 insertions, 7 deletions
diff --git a/util/ectool.c b/util/ectool.c
index b1115aefcd..0315b6dbb1 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -14,13 +14,11 @@
#include "battery.h"
#include "comm-host.h"
+#include "compile_time_macros.h"
#include "ectool.h"
#include "lightbar.h"
#include "lock/gec_lock.h"
-/* Handy tricks */
-#define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2*!(cond)]))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
/* Don't use a macro where an inline will do... */
static inline int MIN(int a, int b) { return a < b ? a : b; }
diff --git a/util/lbplay.c b/util/lbplay.c
index bcf90148e7..9cb853aa75 100644
--- a/util/lbplay.c
+++ b/util/lbplay.c
@@ -11,13 +11,10 @@
#include <unistd.h>
#include "comm-host.h"
+#include "compile_time_macros.h"
#include "lightbar.h"
#include "lock/gec_lock.h"
-/* Handy tricks */
-#define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2*!(cond)]))
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-
#define LB_SIZES(SUBCMD) { \
sizeof(((struct ec_params_lightbar *)0)->SUBCMD) \
+ sizeof(((struct ec_params_lightbar *)0)->cmd), \