diff mbox series

[1/2] asm-generic: current: Don't include thread-info.h if building asm

Message ID 20230704083022.692368-1-davidgow@google.com
State Accepted
Commit 760ee8f83825f6b6ee711bb50b61a2e9a89209a0
Headers show
Series [1/2] asm-generic: current: Don't include thread-info.h if building asm | expand

Commit Message

David Gow July 4, 2023, 8:30 a.m. UTC
asm/current.h is included by some assembly files (either directly, or
indirectly). This works on some architectures (such as x86), as their
implementation of current.h is careful to not include any C, but the
asm-generic version includes linux/thread-info.h unconditionally, which
leads to errors when either C code or non-asm-compatible preprocessor
directives are included.

Just wrap the contents behind an #ifndef __ASSEMBLY__ to avoid any C
code making its way in.

Signed-off-by: David Gow <davidgow@google.com>
---

This is requrired for patch #2 here, as UML uses this asm-generic
header, but works with x86 assembly files which are expecting the x86
current.h, which is assembly-friendly.

---
 include/asm-generic/current.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Weinberger Aug. 19, 2023, 9:17 p.m. UTC | #1
----- Ursprüngliche Mail -----
> Von: "davidgow" <davidgow@google.com>
> asm/current.h is included by some assembly files (either directly, or
> indirectly). This works on some architectures (such as x86), as their
> implementation of current.h is careful to not include any C, but the
> asm-generic version includes linux/thread-info.h unconditionally, which
> leads to errors when either C code or non-asm-compatible preprocessor
> directives are included.
> 
> Just wrap the contents behind an #ifndef __ASSEMBLY__ to avoid any C
> code making its way in.
> 
> Signed-off-by: David Gow <davidgow@google.com>
> ---
> 
> This is requrired for patch #2 here, as UML uses this asm-generic
> header, but works with x86 assembly files which are expecting the x86
> current.h, which is assembly-friendly.
> 
> ---
> include/asm-generic/current.h | 2 ++
> 1 file changed, 2 insertions(+)
> 
> diff --git a/include/asm-generic/current.h b/include/asm-generic/current.h
> index 3a2e224b9fa0..9c2aeecbd05a 100644
> --- a/include/asm-generic/current.h
> +++ b/include/asm-generic/current.h
> @@ -2,9 +2,11 @@
> #ifndef __ASM_GENERIC_CURRENT_H
> #define __ASM_GENERIC_CURRENT_H
> 
> +#ifndef __ASSEMBLY__
> #include <linux/thread_info.h>
> 
> #define get_current() (current_thread_info()->task)
> #define current get_current()
> +#endif
> 
> #endif /* __ASM_GENERIC_CURRENT_H */

I'm fine with the UML side of this change but the generic part needs Arnd's ACK.

Thanks,
//richard
Arnd Bergmann Aug. 19, 2023, 11:12 p.m. UTC | #2
On Tue, Jul 4, 2023, at 04:30, David Gow wrote:
> asm/current.h is included by some assembly files (either directly, or
> indirectly). This works on some architectures (such as x86), as their
> implementation of current.h is careful to not include any C, but the
> asm-generic version includes linux/thread-info.h unconditionally, which
> leads to errors when either C code or non-asm-compatible preprocessor
> directives are included.
>
> Just wrap the contents behind an #ifndef __ASSEMBLY__ to avoid any C
> code making its way in.
>
> Signed-off-by: David Gow <davidgow@google.com>

Acked-by: Arnd Bergmann <arnd@arndb.de>
diff mbox series

Patch

diff --git a/include/asm-generic/current.h b/include/asm-generic/current.h
index 3a2e224b9fa0..9c2aeecbd05a 100644
--- a/include/asm-generic/current.h
+++ b/include/asm-generic/current.h
@@ -2,9 +2,11 @@ 
 #ifndef __ASM_GENERIC_CURRENT_H
 #define __ASM_GENERIC_CURRENT_H
 
+#ifndef __ASSEMBLY__
 #include <linux/thread_info.h>
 
 #define get_current() (current_thread_info()->task)
 #define current get_current()
+#endif
 
 #endif /* __ASM_GENERIC_CURRENT_H */