2012-02-09 00:59:11 +00:00
|
|
|
/* Macros to support TLS testing in times of missing compiler support. */
|
|
|
|
|
|
|
|
extern void *__tls_get_addr (void *);
|
|
|
|
|
2014-01-24 17:07:04 +00:00
|
|
|
# define TLS_GD(x) \
|
|
|
|
({ register void *__gp asm ("$29"); void *__result; \
|
|
|
|
asm ("lda %0, " #x "($gp) !tlsgd" : "=r" (__result) : "r"(__gp)); \
|
2012-02-09 00:59:11 +00:00
|
|
|
__tls_get_addr (__result); })
|
|
|
|
|
2014-01-24 17:07:04 +00:00
|
|
|
# define TLS_LD(x) \
|
|
|
|
({ register void *__gp asm ("$29"); void *__result; \
|
|
|
|
asm ("lda %0, " #x "($gp) !tlsldm" : "=r" (__result) : "r"(__gp)); \
|
|
|
|
__result = __tls_get_addr (__result); \
|
|
|
|
asm ("lda %0, " #x "(%0) !dtprel" : "+r" (__result)); \
|
2012-02-09 00:59:11 +00:00
|
|
|
__result; })
|
|
|
|
|
2014-01-24 17:07:04 +00:00
|
|
|
# define TLS_IE(x) \
|
|
|
|
({ register void *__gp asm ("$29"); long ofs; \
|
|
|
|
asm ("ldq %0, " #x "($gp) !gottprel" : "=r"(ofs) : "r"(__gp)); \
|
2012-02-09 00:59:11 +00:00
|
|
|
__builtin_thread_pointer () + ofs; })
|
|
|
|
|
|
|
|
# define TLS_LE(x) \
|
|
|
|
({ void *__result = __builtin_thread_pointer (); \
|
|
|
|
asm ("lda %0, " #x "(%0) !tprel" : "+r" (__result)); \
|
|
|
|
__result; })
|