1 #ifndef _TLS_H 2 #define _TLS_H 1 3 4 #include <BeBuild.h> 5 #include <SupportDefs.h> 6 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 extern _IMPEXP_ROOT int32 tls_allocate(void); 13 14 #if __INTEL__ 15 16 static inline void * tls_get(int32 index) { 17 void *ret; 18 __asm__ __volatile__ ( 19 "movl %%fs:(,%%edx, 4), %%eax \n\t" 20 : "=a"(ret) : "d"(index) ); 21 return ret; 22 } 23 24 static inline void * tls_address(int32 index) { 25 void *ret; 26 __asm__ __volatile__ ( 27 "movl %%fs:0, %%eax \n\t" 28 "leal (%%eax, %%edx, 4), %%eax \n\t" 29 : "=a"(ret) : "d"(index) ); 30 return ret; 31 } 32 33 static inline void tls_set(int32 index, void *value) { 34 __asm__ __volatile__ ( 35 "movl %%eax, %%fs:(,%%edx, 4) \n\t" 36 : : "d"(index), "a"(value) ); 37 } 38 39 #else 40 41 extern _IMPEXP_ROOT void * tls_get(int32 index); 42 extern _IMPEXP_ROOT void ** tls_address(int32 index); 43 extern _IMPEXP_ROOT void tls_set(int32 index, void *value); 44 45 #endif 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif 52