[U-Boot] [PATCH 1/2] COMMON: Add __stringify() function

Marek Vasut
2012-07-28T13:47:58Z

This function converts static number to string in preprocessor.
This is useful as it allows higher usage of puts() in favour of printf()

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Mike Frysinger <vapier@gentoo.org>
---
include/common.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/common.h b/include/common.h
index d1dd65a..451917d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -268,6 +268,13 @@ typedef void (interrupt_handler_t)(void *);
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})

+/**
+ * __stringify - preprocessor magic to return string from number
+ * @x: constant number
+ */
+#define __stringify_1(x...) #x
+#define __stringify(x...) __stringify_1(x)
+
/*
* Function Prototypes
*/
--
1.7.10.4