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