diff options
author | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-07-25 19:13:20 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@uclibc-ng.org> | 2016-07-31 12:49:30 +0200 |
commit | 5478c44ceb136a4dc7166bd287684cdbef6ca9ce (patch) | |
tree | d62ed9d4190419f75ed3397cff76510b6b190f6b /test/tls/tls-macros-x86_64.h | |
parent | 345181fb9a36ad18c0a40ccb74bff9ee4d03819b (diff) |
test: reorganize tls macros in separate architecture files
To be more consistent separate all TLS macros in separate files and
remove obsolete macros for not supported architectures.
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'test/tls/tls-macros-x86_64.h')
-rw-r--r-- | test/tls/tls-macros-x86_64.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/tls/tls-macros-x86_64.h b/test/tls/tls-macros-x86_64.h new file mode 100644 index 000000000..b8a8b71f4 --- /dev/null +++ b/test/tls/tls-macros-x86_64.h @@ -0,0 +1,40 @@ +#define TLS_LE(x) \ + ({ int *__l; \ + __asm__ ("mov %%fs:0,%0\n\t" \ + "lea " #x "@tpoff(%0), %0" \ + : "=r" (__l)); \ + __l; }) + +#define TLS_IE(x) \ + ({ int *__l; \ + __asm__ ("mov %%fs:0,%0\n\t" \ + "add " #x "@gottpoff(%%rip),%0" \ + : "=r" (__l)); \ + __l; }) + +#define TLS_LD(x) \ + ({ int *__l, __c, __d; \ + __asm__ ("leaq " #x "@tlsld(%%rip),%%rdi\n\t" \ + "call __tls_get_addr@plt\n\t" \ + "leaq " #x "@dtpoff(%%rax), %%rax" \ + : "=a" (__l), "=&c" (__c), "=&d" (__d) \ + : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \ + __l; }) + +#ifdef __ILP32__ +# define TLS_GD_PREFIX +#else +# define TLS_GD_PREFIX ".byte 0x66\n\t" +#endif + +#define TLS_GD(x) \ + ({ int *__l, __c, __d; \ + __asm__ (TLS_GD_PREFIX \ + "leaq " #x "@tlsgd(%%rip),%%rdi\n\t" \ + ".word 0x6666\n\t" \ + "rex64\n\t" \ + "call __tls_get_addr@plt" \ + : "=a" (__l), "=&c" (__c), "=&d" (__d) \ + : : "rdi", "rsi", "r8", "r9", "r10", "r11"); \ + __l; }) + |