current.h 517 B

1234567891011121314151617181920212223242526272829
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __ASM_CURRENT_H
  3. #define __ASM_CURRENT_H
  4. #include <linux/compiler.h>
  5. #ifndef __ASSEMBLY__
  6. struct task_struct;
  7. /*
  8. * We don't use read_sysreg() as we want the compiler to cache the value where
  9. * possible.
  10. */
  11. static __always_inline struct task_struct *get_current(void)
  12. {
  13. unsigned long sp_el0;
  14. asm ("mrs %0, sp_el0" : "=r" (sp_el0));
  15. return (struct task_struct *)sp_el0;
  16. }
  17. #define current get_current()
  18. #endif /* __ASSEMBLY__ */
  19. #endif /* __ASM_CURRENT_H */