1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_CURRENT_H
3 #define _ASM_X86_CURRENT_H
4 
5 #include <linux/build_bug.h>
6 #include <linux/compiler.h>
7 
8 #ifndef __ASSEMBLER__
9 
10 #include <linux/cache.h>
11 #include <asm/percpu.h>
12 
13 struct task_struct;
14 
15 DECLARE_PER_CPU_CACHE_HOT(struct task_struct *, current_task);
16 /* const-qualified alias provided by the linker. */
17 DECLARE_PER_CPU_CACHE_HOT(struct task_struct * const __percpu_seg_override,
18 			  const_current_task);
19 
get_current(void)20 static __always_inline struct task_struct *get_current(void)
21 {
22 	if (IS_ENABLED(CONFIG_USE_X86_SEG_SUPPORT))
23 		return this_cpu_read_const(const_current_task);
24 
25 	return this_cpu_read_stable(current_task);
26 }
27 
28 #define current get_current()
29 
30 #endif /* __ASSEMBLER__ */
31 
32 #endif /* _ASM_X86_CURRENT_H */
33