diff options
Diffstat (limited to 'TSRM/TSRM.c')
-rw-r--r-- | TSRM/TSRM.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TSRM/TSRM.c b/TSRM/TSRM.c index fa8e5f7736..2d17ffcabc 100644 --- a/TSRM/TSRM.c +++ b/TSRM/TSRM.c @@ -761,6 +761,26 @@ TSRM_API void *tsrm_get_ls_cache(void) return tsrm_tls_get(); }/*}}}*/ +/* Returns offset of tsrm_ls_cache slot from Thread Control Block address */ +TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void) +{/*{{{*/ +#if defined(__x86_64__) && defined(__GNUC__) + size_t ret; + + asm ("movq _tsrm_ls_cache@gottpoff(%%rip),%0" + : "=r" (ret)); + return ret; +#elif defined(__i386__) && defined(__GNUC__) + size_t ret; + + asm ("leal _tsrm_ls_cache@ntpoff,%0" + : "=r" (ret)); + return ret; +#else + return 0; +#endif +}/*}}}*/ + TSRM_API uint8_t tsrm_is_main_thread(void) {/*{{{*/ return in_main_thread; |