x86: undef REG_IN/REG_OUT to avoid define collisions
PATCH 1/1 x86: undef REG_IN/REG_OUT to avoid define collisions
These defines are only used in the inline functions declared in the arch_hweight.h file, and collides with internal defines of the Amlogic Mes pinctrl driver when COMPILE_TEST is enabled:
arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant 9 | #define REG_OUT "a"
| ^~~drivers/pinctrl/meson/pinctrl-meson.h:69:9: note: in expansion of macro ‘REG_OUT’
69 | REG_OUT,
--- arch/x86/include/asm/arch_hweight.h | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/include/asm/arch_hweight.h +3 -0
@@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w) }#endif /* CONFIG_X86_32 */ +#undef REG_IN +#undef REG_OUT +#endif
Signature · 1 line
2.25.1
Quoted 21 lines · Neil Armstrong
These defines are only used in the inline functions declared in the
arch_hweight.hfile, and collides with internal defines of the Amlogic Mes pinctrl driver whenCOMPILE_TESTis enabled:
arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant 9 | #defineREG_OUT"a"
| ^~~drivers/pinctrl/meson/pinctrl-meson.h:69:9: note: in expansion of macro ‘REG_OUT’
69 |REG_OUT,Reported-by Andy Shevchenko <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- arch/x86/include/asm/arch_hweight.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/arch_hweight.h +0
-0
arch/x86/include/asm/arch_hweight.h static __always_inline unsigned long __arch_hweight64(__u64 w) · line 56
Quoted 5 lines
arch/x86/include/asm/arch_hweight.h +2
-0@@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w) }#endif /* CONFIG_X86_32 */ +#undef REG_IN +#undef REG_OUT
Wouldn't it be a bit less hackish to give these a more qualified name like HWEIGHT_REG_IN?
Quoted 10 lines · Dave Hansen
Quoted 9 lines · Neil Armstrong
These defines are only used in the inline functions declared in the
arch_hweight.hfile, and collides with internal defines of the Amlogic Mes pinctrl driver whenCOMPILE_TESTis enabled:
arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant 9 | #defineREG_OUT"a"
| ^~~drivers/pinctrl/meson/pinctrl-meson.h:69:9: note: in expansion of macro ‘REG_OUT’
69 |REG_OUT,
Thanks for the patch!
Quoted 14 lines
Quoted 14 lines
Reported-by Andy Shevchenko <[email protected]>Signed-off-by Neil Armstrong <[email protected]>--- arch/x86/include/asm/arch_hweight.h | 3 +++ 1 file changed, 3 insertions(+)arch/x86/include/asm/arch_hweight.h +0
-0@@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w) }#endif /* CONFIG_X86_32 */
Quoted 5 lines
arch/x86/include/asm/arch_hweight.h static __always_inline unsigned long __arch_hweight64(__u64 w) · line 56
Quoted 2 lines
arch/x86/include/asm/arch_hweight.h +2
-0+#undef REG_IN +#undef REG_OUTWouldn't it be a bit less hackish to give these a more qualified name like
HWEIGHT_REG_IN?
Either way, would it be good to undef them here anyway?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 10 lines · Andy Shevchenko
Quoted 9 lines · Dave Hansen
Quoted 8 lines · Neil Armstrong
arch/x86/include/asm/arch_hweight.h +0
-0@@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w) }#endif /* CONFIG_X86_32 */
Quoted 5 lines
Quoted 5 lines
arch/x86/include/asm/arch_hweight.h static __always_inline unsigned long __arch_hweight64(__u64 w) · line 56
Quoted 2 lines
arch/x86/include/asm/arch_hweight.h +2
-0+#undef REG_IN +#undef REG_OUTWouldn't it be a bit less hackish to give these a more qualified name like
HWEIGHT_REG_IN?
Absolutely.
Quoted 1 line
Either way, would it be good to undef them here anyway?
No. Unconditional #undef is a guarantee for hard to diagnose trouble because it papers over namespace collisions. You can end up with the wrong constants in your binary which might work well except for the once in the blue moon corner case.
Been there and stared at such nonsense for weeks...
Name spaces exist for a reason and we are not short of characters here.
Thanks,
tglx