rseq-ppc-thread-pointer.h 517 B

123456789101112131415161718192021222324252627282930
  1. /* SPDX-License-Identifier: LGPL-2.1-only OR MIT */
  2. /*
  3. * rseq-ppc-thread-pointer.h
  4. *
  5. * (C) Copyright 2021 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  6. */
  7. #ifndef _RSEQ_PPC_THREAD_POINTER
  8. #define _RSEQ_PPC_THREAD_POINTER
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. static inline void *rseq_thread_pointer(void)
  13. {
  14. #ifdef __powerpc64__
  15. register void *__result asm ("r13");
  16. #else
  17. register void *__result asm ("r2");
  18. #endif
  19. asm ("" : "=r" (__result));
  20. return __result;
  21. }
  22. #ifdef __cplusplus
  23. }
  24. #endif
  25. #endif