]> xenbits.xensource.com Git - people/liuw/xtf.git/commitdiff
Fix _ASM_EXTABLE_HANDLER() to expand preprocessor tokens in its parameters
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Jun 2016 11:54:40 +0000 (11:54 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 6 Jun 2016 11:57:04 +0000 (12:57 +0100)
Currently it stringises the literal parameter, which can result in a
non-expanded token ending up in at the assembler, causing a build failure.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
include/xtf/extable.h
include/xtf/macro_magic.h

index 5585181034b2391d8b51ae104e43517f47e03a0f..aaa205361e27e66c74b6e1900ca4f0d0525dbc2f 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <xtf/types.h>
 #include <xtf/asm_macros.h>
+#include <xtf/macro_magic.h>
 
 #ifdef __ASSEMBLY__
 
@@ -45,7 +46,7 @@
  */
 #define _ASM_EXTABLE(fault, fixup)              \
     ".pushsection .ex_table, \"a\";\n"          \
-    _WORD #fault ", " #fixup ", 0;\n"           \
+    _WORD STR(fault) ", " STR(fixup) ", 0;\n"   \
     ".popsection;\n"
 
 /**
@@ -54,9 +55,9 @@
  * @param fixup Fixup address.
  * @param handler Handler to call.
  */
-#define _ASM_EXTABLE_HANDLER(fault, fixup, handler) \
-    ".pushsection .ex_table, \"a\";\n"              \
-    _WORD #fault ", " #fixup ", " #handler ";\n"    \
+#define _ASM_EXTABLE_HANDLER(fault, fixup, handler)             \
+    ".pushsection .ex_table, \"a\";\n"                          \
+    _WORD STR(fault) ", " STR(fixup) ", " STR(handler) ";\n"    \
     ".popsection;\n"
 
 struct cpu_regs;
index c2a1143ceb7471bffe72dcbd1bf3c251db626095..b498fecaececc8756e73cf325515b91edf524be6 100644 (file)
@@ -6,6 +6,16 @@
 #ifndef XTF_MACRO_MAGIC_H
 #define XTF_MACRO_MAGIC_H
 
+/**
+ * Stringise an expression, expanding preprocessor tokens.
+ *
+ * @param x Expression to stringise.
+ */
+/** @cond */
+#define _STR(x) #x
+/** @endcond */
+#define STR(x) _STR(x)
+
 /**
  * Count the number of varadic arguments provided.
  *