@@ -233,6 +233,7 @@ blobs="yes"
pkgversion=""
check_utests="no"
user_pie="no"
+tls_thread="yes"
# OS specific
if check_define __linux__ ; then
@@ -1017,6 +1018,19 @@ EOF
fi
##########################################
+# Check for availability of the __thread keyword
+cat > $TMPC <<EOF
+__thread void *ptr;
+int main(void) { return 0;}
+EOF
+
+if compile_prog; then
+ tls_thread="yes"
+else
+ tls_thread="no"
+fi
+
+##########################################
# VNC TLS detection
if test "$vnc_tls" != "no" ; then
cat > $TMPC <<EOF
@@ -1969,6 +1983,9 @@ echo "CONFIG_BDRV_WHITELIST=$block_drv_whitelist" >> $config_host_mak
if test "$mixemu" = "yes" ; then
echo "CONFIG_MIXEMU=y" >> $config_host_mak
fi
+if test "$tls_thread" = "yes" ; then
+ echo "CONFIG_TLS_HAS_THREAD=y" >> $config_host_mak
+fi
if test "$vnc_tls" = "yes" ; then
echo "CONFIG_VNC_TLS=y" >> $config_host_mak
echo "VNC_TLS_CFLAGS=$vnc_tls_cflags" >> $config_host_mak
@@ -3445,21 +3445,37 @@ static void block_io_signals(void);
static void unblock_io_signals(void);
static int tcg_has_work(void);
+#ifdef CONFIG_TLS_HAS_THREAD
+static __thread CPUState *current_env;
+#else
static pthread_key_t current_env;
+#endif
static CPUState *qemu_get_current_env(void)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ return current_env;
+#else
return pthread_getspecific(current_env);
+#endif
}
static void qemu_set_current_env(CPUState *env)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ current_env = env;
+#else
pthread_setspecific(current_env, env);
+#endif
}
static void qemu_init_current_env(void)
{
+#ifdef CONFIG_TLS_HAS_THREAD
+ current_env = NULL;
+#else
pthread_key_create(¤t_env, NULL);
+#endif
}
static int qemu_init_main_loop(void)
It is much faster than pthread_{g,s}et_specific. Signed-off-by: Glauber Costa <glommer@redhat.com> --- configure | 17 +++++++++++++++++ vl.c | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 0 deletions(-)