From 9a06876072b9ccb023d4a14426ccb587f10882f3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 1 Apr 2019 10:27:11 +0300 Subject: Added JIT compiler for x86 and x86_64 --- TSRM/TSRM.c | 20 ++++++++++++++++++++ TSRM/TSRM.h | 1 + 2 files changed, 21 insertions(+) (limited to 'TSRM') 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; diff --git a/TSRM/TSRM.h b/TSRM/TSRM.h index d5d9065530..c399e243c0 100644 --- a/TSRM/TSRM.h +++ b/TSRM/TSRM.h @@ -137,6 +137,7 @@ TSRM_API void *tsrm_set_new_thread_end_handler(tsrm_thread_end_func_t new_thread TSRM_API void *tsrm_set_shutdown_handler(tsrm_shutdown_func_t shutdown_handler); TSRM_API void *tsrm_get_ls_cache(void); +TSRM_API size_t tsrm_get_ls_cache_tcb_offset(void); TSRM_API uint8_t tsrm_is_main_thread(void); TSRM_API const char *tsrm_api_name(void); -- cgit v1.2.1