0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _RSEQ_X86_THREAD_POINTER
0009 #define _RSEQ_X86_THREAD_POINTER
0010
0011 #include <features.h>
0012
0013 #ifdef __cplusplus
0014 extern "C" {
0015 #endif
0016
0017 #if __GNUC_PREREQ (11, 1)
0018 static inline void *rseq_thread_pointer(void)
0019 {
0020 return __builtin_thread_pointer();
0021 }
0022 #else
0023 static inline void *rseq_thread_pointer(void)
0024 {
0025 void *__result;
0026
0027 # ifdef __x86_64__
0028 __asm__ ("mov %%fs:0, %0" : "=r" (__result));
0029 # else
0030 __asm__ ("mov %%gs:0, %0" : "=r" (__result));
0031 # endif
0032 return __result;
0033 }
0034 #endif
0035
0036 #ifdef __cplusplus
0037 }
0038 #endif
0039
0040 #endif