Fix supported autotools versions in README.md
[librseq.git] / include / rseq / rseq-x86-thread-pointer.h
1 /* SPDX-License-Identifier: MIT */
2 /* SPDX-FileCopyrightText: 2021 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> */
3
4 /*
5 * rseq-x86-thread-pointer.h
6 */
7
8 #ifndef _RSEQ_X86_THREAD_POINTER
9 #define _RSEQ_X86_THREAD_POINTER
10
11 #include <features.h>
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17 #if __GNUC_PREREQ (11, 1)
18 static inline void *rseq_thread_pointer(void)
19 {
20 return __builtin_thread_pointer();
21 }
22 #else
23 static inline void *rseq_thread_pointer(void)
24 {
25 void *__result;
26
27 # ifdef __x86_64__
28 __asm__ ("mov %%fs:0, %0" : "=r" (__result));
29 # else
30 __asm__ ("mov %%gs:0, %0" : "=r" (__result));
31 # endif
32 return __result;
33 }
34 #endif /* !GCC 11 */
35
36 #ifdef __cplusplus
37 }
38 #endif
39
40 #endif
This page took 0.029835 seconds and 4 git commands to generate.