From 56e0e67abe77d161d0b90dbecf7d42ecafdfb43b Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Fri, 23 May 2014 11:02:20 -0700 Subject: move stringify macro to common include We need to stringify macros arguments in various places in the code, avoid duplicating this definition. Signed-off-by: Vincent Palatin BRANCH=none BUG=none TEST=make buildall Change-Id: I03530c06139fad4c60711d041239b396d9ed321e Reviewed-on: https://chromium-review.googlesource.com/201576 Reviewed-by: Alec Berg Reviewed-by: Randall Spangler Commit-Queue: Vincent Palatin Tested-by: Vincent Palatin --- include/common.h | 9 +++++++++ 1 file changed, 9 insertions(+) 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)) -- cgit v1.2.1