Stringify support commas
PATCH 1/1 Stringify support commas
#define MYDEF a, b, c
__stringify(MYDEF) should be replaced by "a, b, c", but compilation fails because the __stringify macro expects only one argument. Fix it by using variable macro arguments in __stringify and __stringify_1.
Needed in my current NMI safe iret paravirt support work so I can expand a macro containing assembly code into a string.
--- include/linux/stringify.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/stringify.h +2 -2
@@ -6,7 +6,7 @@* converts to "bar". */ -#define __stringify_1 (x) #x -#define __stringify (x) __stringify_1(x) +#define __stringify_1(x...) #x +#define __stringify(x...) __stringify_1(x)#endif /* !__LINUX_STRINGIFY_H */
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 8 lines · Mathieu Desnoyers
#define MYDEF a, b, c
__stringify(MYDEF)should be replaced by "a, b, c", but compilation fails because the__stringifymacro expects only one argument. Fix it by using variable macro arguments in__stringifyand__stringify_1.Needed in my current NMI safe iret paravirt support work so I can expand a macro containing assembly code into a string.
This is a no-no for those archs that still use -traditional. I dunno if this is a problem for you at the moment and the right fix is anyway to nuke -traditional.
Sam
Quoted 7 lines · * Sam Ravnborg ([email protected]) wrote:
Quoted 6 lines · Mathieu Desnoyers
#define MYDEF a, b, c
__stringify(MYDEF)should be replaced by "a, b, c", but compilation fails because the__stringifymacro expects only one argument. Fix it by using variable macro arguments in__stringifyand__stringify_1.
Quoted 8 lines
Quoted 2 lines
Needed in my current NMI safe iret paravirt support work so I can expand a macro containing assembly code into a string.
This is a no-no for those archs that still use -traditional. I dunno if this is a problem for you at the moment and the right fix is anyway to nuke -traditional.
Sam
A quick grep through arch/ gives me the following :
arch/cris/arch-v10/boot/compressed/Makefile
@$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@
arch/cris/arch-v10/boot/rescue/Makefile
asflags-y += -traditionalarch/cris/arch-v10/lib/MakefileEXTRA_AFLAGS := -traditionalarch/h8300/boot/compressed/MakefileEXTRA_AFLAGS := -traditionalarch/m32r/boot/compressed/MakefileEXTRA_AFLAGS := -traditionalarch/m32r/kernel/MakefileEXTRA_AFLAGS := -traditionalarch/m68k/fpsp040/MakefileEXTRA_AFLAGS := -traditionalarch/m68k/ifpsp060/MakefileEXTRA_AFLAGS := -traditionalarch/m68k/kernel/MakefileEXTRA_AFLAGS := -traditionalarch/m68k/lib/MakefileEXTRA_AFLAGS := -traditionalarch/m68k/math-emu/MakefileEXTRA_AFLAGS := -traditionalarch/parisc/kernel/Makefile
AFLAGS_entry.o := -traditional
AFLAGS_pacache.o := -traditionalarch/powerpc/boot/Makefile
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdincarch/s390/kernel/MakefileEXTRA_AFLAGS := -traditionalarch/s390/lib/MakefileEXTRA_AFLAGS := -traditionalarch/s390/math-emu/MakefileEXTRA_AFLAGS := -traditionalarch/sh/boot/compressed/Makefile_32EXTRA_AFLAGS := -traditionalarch/sh/boot/compressed/Makefile_64EXTRA_AFLAGS := -traditional
Would their removal break something ?
Mathieu
Signature · 3 lines
Mathieu Desnoyers Computer Engineering Ph.D. Student, Ecole Polytechnique de Montreal OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
Quoted 57 lines · Mathieu Desnoyers
Quoted 7 lines · * Sam Ravnborg ([email protected]) wrote:
Quoted 6 lines · Mathieu Desnoyers
#define MYDEF a, b, c
__stringify(MYDEF)should be replaced by "a, b, c", but compilation fails because the__stringifymacro expects only one argument. Fix it by using variable macro arguments in__stringifyand__stringify_1.Quoted 8 lines
Quoted 2 lines
Needed in my current NMI safe iret paravirt support work so I can expand a macro containing assembly code into a string.
This is a no-no for those archs that still use -traditional. I dunno if this is a problem for you at the moment and the right fix is anyway to nuke -traditional.
Sam
A quick grep through
arch/gives me the following :
arch/cris/arch-v10/boot/compressed/Makefile@$(CC) -D__ASSEMBLY__ -traditional -c $< -o $@
arch/cris/arch-v10/boot/rescue/Makefile
asflags-y += -traditionalarch/cris/arch-v10/lib/MakefileEXTRA_AFLAGS:= -traditionalarch/h8300/boot/compressed/MakefileEXTRA_AFLAGS:= -traditionalarch/m32r/boot/compressed/MakefileEXTRA_AFLAGS:= -traditionalarch/m32r/kernel/MakefileEXTRA_AFLAGS:= -traditionalarch/m68k/fpsp040/MakefileEXTRA_AFLAGS:= -traditionalarch/m68k/ifpsp060/MakefileEXTRA_AFLAGS:= -traditionalarch/m68k/kernel/MakefileEXTRA_AFLAGS:= -traditionalarch/m68k/lib/MakefileEXTRA_AFLAGS:= -traditionalarch/m68k/math-emu/MakefileEXTRA_AFLAGS:= -traditionalarch/parisc/kernel/Makefile
AFLAGS_entry.o := -traditional
AFLAGS_pacache.o := -traditionalarch/powerpc/boot/Makefile
BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdincarch/s390/kernel/MakefileEXTRA_AFLAGS:= -traditionalarch/s390/lib/MakefileEXTRA_AFLAGS:= -traditionalarch/s390/math-emu/MakefileEXTRA_AFLAGS:= -traditionalarch/sh/boot/compressed/Makefile_32EXTRA_AFLAGS:= -traditionalarch/sh/boot/compressed/Makefile_64EXTRA_AFLAGS:= -traditional
Quoted 1 line
Would their removal break something ?
I do not recall why they were added but removing -traditional from x86 was painless.
So a simple approach would be to send a patch towards the arch maintainers. But even better to try it out with a cross toolchain first.
Any breakage should be obvious.
Sam