aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac15
-rw-r--r--src/lib/eo/eo.c14
2 files changed, 26 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 69edd17f76..cb8e9505c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -984,6 +984,20 @@ if test "x${efl_have_threads}" = "xno"; then
CFOPT_WARNING="xyes"
fi
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[ ]],
+ [[
+ static __thread int a = 0;
+ ]])],
+ [have_thread_specifier="yes"],
+ [have_thread_specifier="no"])
+AC_MSG_CHECKING([for __thread specifier])
+AC_MSG_RESULT([${have_thread_specifier}])
+if test "x${have_thread_specifier}" = "xyes" ; then
+ AC_DEFINE([HAVE_THREAD_SPECIFIER], [1], [Have the __thread specifier])
+fi
+
EFL_ADD_PUBLIC_LIBS([EINA], [${EFL_PTHREAD_LIBS}])
EFL_ADD_CFLAGS([EINA], [${EFL_PTHREAD_CFLAGS}])
@@ -4868,6 +4882,7 @@ EFL_ADD_FEATURE([thread], [spinlocks], [${efl_have_spinlock}])
EFL_ADD_FEATURE([thread], [barrier], [${efl_have_pthread_barrier}])
EFL_ADD_FEATURE([thread], [affinity], [${efl_have_setaffinity}])
EFL_ADD_FEATURE([thread], [setname], [${efl_have_setname}])
+EFL_ADD_FEATURE([thread], [__thread], [${have_thread_specifier}])
echo
echo
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index bc71108963..ee72b742e6 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -378,6 +378,13 @@ _eo_call_stack_free(void *ptr)
free(stack);
}
+#ifdef HAVE_THREAD_SPECIFIER
+static __thread Eo_Call_Stack *_eo_thread_stack = NULL;
+
+#define _EO_CALL_STACK_GET() ((_eo_thread_stack) ? _eo_thread_stack : (_eo_thread_stack = _eo_call_stack_create()))
+
+#else
+
static Eo_Call_Stack *main_loop_stack = NULL;
#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread())
@@ -385,9 +392,7 @@ static Eo_Call_Stack *main_loop_stack = NULL;
static inline Eo_Call_Stack *
_eo_call_stack_get_thread(void)
{
- Eo_Call_Stack *stack;
-
- stack = eina_tls_get(_eo_call_stack_key);
+ Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key);
if (stack) return stack;
@@ -396,6 +401,7 @@ _eo_call_stack_get_thread(void)
return stack;
}
+#endif
EAPI EINA_CONST void *
_eo_stack_get(void)
@@ -1777,12 +1783,14 @@ eo_init(void)
}
}
+#ifndef HAVE_THREAD_SPECIFIER
main_loop_stack = _eo_call_stack_create();
if (!main_loop_stack)
{
EINA_LOG_ERR("Could not alloc eo call stack.");
return EINA_FALSE;
}
+#endif
return EINA_TRUE;
}