summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2014-05-23 11:02:20 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-05-27 23:21:26 +0000
commit56e0e67abe77d161d0b90dbecf7d42ecafdfb43b (patch)
tree715d7f6cf9bb7a5a300543c91f26aca5b73f0e36 /include
parent8c89bcff4dce7f8921ffda1603d6f77bf8465356 (diff)
downloadchrome-ec-56e0e67abe77d161d0b90dbecf7d42ecafdfb43b.tar.gz
move stringify macro to common includestabilize-5899.B
We need to stringify macros arguments in various places in the code, avoid duplicating this definition. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=none TEST=make buildall Change-Id: I03530c06139fad4c60711d041239b396d9ed321e Reviewed-on: https://chromium-review.googlesource.com/201576 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org> Tested-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/common.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index 5f236a1f35..cddcde31fa 100644
--- a/include/common.h
+++ b/include/common.h
@@ -27,6 +27,15 @@
#define CONCAT3(w, x, y) CONCAT_STAGE_1(w, x, y, )
#define CONCAT4(w, x, y, z) CONCAT_STAGE_1(w, x, y, z)
+/*
+ * Macros to turn the argument into a string constant.
+ *
+ * Compared to directly using the preprocessor # operator, this 2-stage macro
+ * is safe with regards to using nested macros and defined arguments.
+ */
+#define STRINGIFY0(name) #name
+#define STRINGIFY(name) STRINGIFY0(name)
+
/* Macros to access registers */
#define REG32(addr) (*(volatile uint32_t *)(addr))
#define REG16(addr) (*(volatile uint16_t *)(addr))