current.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. #ifndef __ASM_CURRENT_H
  17. #define __ASM_CURRENT_H
  18. #include <linux/bug.h>
  19. #include <linux/compiler.h>
  20. #ifndef __ASSEMBLY__
  21. struct task_struct;
  22. /*
  23. * This only works because "struct thread_info" is at offset 0 from "struct
  24. * task_struct". This constraint seems to be necessary on other architectures
  25. * as well, but __switch_to enforces it. We can't check TASK_TI here because
  26. * <asm/asm-offsets.h> includes this, and I can't get the definition of "struct
  27. * task_struct" here due to some header ordering problems.
  28. */
  29. static __always_inline struct task_struct *get_current(void)
  30. {
  31. register struct task_struct *tp __asm__("tp");
  32. return tp;
  33. }
  34. #define current get_current()
  35. #endif /* __ASSEMBLY__ */
  36. #endif /* __ASM_CURRENT_H */