public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] COMMON: Add __stringify() function
@ 2012-07-28 13:47 Marek Vasut
  2012-07-28 13:47 ` [U-Boot] [RFC] [PATCH 2/2] crazy: Sort u_boot_cmd at runtime Marek Vasut
  2012-07-28 19:36 ` [U-Boot] [PATCH 1/2] COMMON: Add __stringify() function Wolfgang Denk
  0 siblings, 2 replies; 15+ messages in thread
From: Marek Vasut @ 2012-07-28 13:47 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2012-07-31 14:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-28 13:47 [U-Boot] [PATCH 1/2] COMMON: Add __stringify() function Marek Vasut
2012-07-28 13:47 ` [U-Boot] [RFC] [PATCH 2/2] crazy: Sort u_boot_cmd at runtime Marek Vasut
2012-07-28 17:46   ` Wolfgang Denk
2012-07-28 18:39     ` Marek Vasut
2012-07-28 19:53       ` Wolfgang Denk
2012-07-28 20:54         ` Marek Vasut
2012-07-28 19:36 ` [U-Boot] [PATCH 1/2] COMMON: Add __stringify() function Wolfgang Denk
2012-07-28 19:39   ` Marek Vasut
2012-07-28 19:57     ` Wolfgang Denk
2012-07-28 20:59       ` Marek Vasut
2012-07-31  8:01       ` Mike Frysinger
2012-07-31 13:55         ` Marek Vasut
2012-07-31 14:06           ` Mike Frysinger
2012-07-31 14:08             ` Marek Vasut
2012-07-31 14:16               ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox