Commit | Line | Data |
---|---|---|
7db91e57 PD |
1 | /* |
2 | * Based on arm/arm64/include/asm/current.h | |
3 | * | |
4 | * Copyright (C) 2016 ARM | |
5 | * Copyright (C) 2017 SiFive | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or | |
8 | * modify it under the terms of the GNU General Public License | |
9 | * as published by the Free Software Foundation, version 2. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | */ | |
16 | ||
17 | ||
18 | #ifndef __ASM_CURRENT_H | |
19 | #define __ASM_CURRENT_H | |
20 | ||
21 | #include <linux/bug.h> | |
22 | #include <linux/compiler.h> | |
23 | ||
24 | #ifndef __ASSEMBLY__ | |
25 | ||
26 | struct task_struct; | |
27 | ||
28 | /* | |
29 | * This only works because "struct thread_info" is at offset 0 from "struct | |
30 | * task_struct". This constraint seems to be necessary on other architectures | |
31 | * as well, but __switch_to enforces it. We can't check TASK_TI here because | |
32 | * <asm/asm-offsets.h> includes this, and I can't get the definition of "struct | |
33 | * task_struct" here due to some header ordering problems. | |
34 | */ | |
35 | static __always_inline struct task_struct *get_current(void) | |
36 | { | |
37 | register struct task_struct *tp __asm__("tp"); | |
38 | return tp; | |
39 | } | |
40 | ||
41 | #define current get_current() | |
42 | ||
43 | #endif /* __ASSEMBLY__ */ | |
44 | ||
45 | #endif /* __ASM_CURRENT_H */ |