blob: bbfb948004155222dbe6664442ddeef98a203684 [file] [log] [blame]
Thomas Gleixner2874c5f2019-05-27 08:55:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
David Gibson584224e2005-11-09 13:04:06 +11002#ifndef _ASM_POWERPC_CURRENT_H
3#define _ASM_POWERPC_CURRENT_H
Arnd Bergmann88ced032005-12-16 22:43:46 +01004#ifdef __KERNEL__
David Gibson584224e2005-11-09 13:04:06 +11005
6/*
David Gibson584224e2005-11-09 13:04:06 +11007 */
8
9struct task_struct;
10
11#ifdef __powerpc64__
Olaf Heringdbc11f52007-02-25 20:04:18 +010012#include <linux/stddef.h>
David Gibson584224e2005-11-09 13:04:06 +110013#include <asm/paca.h>
14
Hugh Dickins5fe8e8b2006-10-31 18:39:31 +000015static inline struct task_struct *get_current(void)
16{
17 struct task_struct *task;
18
Nicholas Piggine354d7d2019-06-13 00:03:17 +100019 /* get_current can be cached by the compiler, so no volatile */
20 asm ("ld %0,%1(13)"
Hugh Dickins5fe8e8b2006-10-31 18:39:31 +000021 : "=r" (task)
22 : "i" (offsetof(struct paca_struct, __current)));
23
24 return task;
25}
26#define current get_current()
David Gibson584224e2005-11-09 13:04:06 +110027
28#else
29
30/*
31 * We keep `current' in r2 for speed.
32 */
33register struct task_struct *current asm ("r2");
34
35#endif
36
Arnd Bergmann88ced032005-12-16 22:43:46 +010037#endif /* __KERNEL__ */
David Gibson584224e2005-11-09 13:04:06 +110038#endif /* _ASM_POWERPC_CURRENT_H */