xref: /linux/arch/loongarch/include/asm/current.h (revision 7b5944d6ed369e43aeaf37beba9f89f7fb6c633b)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_LOONGARCH_CURRENT_H
3 #define __ASM_LOONGARCH_CURRENT_H
4 
5 #include <linux/compiler.h>
6 
7 #ifndef __ASSEMBLER__
8 
9 #include <asm/percpu.h>
10 
11 struct task_struct;
12 
13 DECLARE_PER_CPU(struct task_struct *, cpu_tasks);
14 
15 register struct task_struct *current_thread_pointer __asm__("$tp");
16 
17 static __always_inline struct task_struct *get_current(void)
18 {
19 	return current_thread_pointer;
20 }
21 
22 #define current get_current()
23 
24 static __always_inline void set_current(struct task_struct *task)
25 {
26 	__this_cpu_write(cpu_tasks, task);
27 }
28 
29 #endif /* __ASSEMBLER__ */
30 
31 #endif /* __ASM_LOONGARCH_CURRENT_H */
32