summaryrefslogtreecommitdiff
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 69edd17..cb8e950 100644
--- a/configure.ac
+++ b/configure.ac
@@ -984,6 +984,20 @@ if test "x${efl_have_threads}" = "xno"; then
984 CFOPT_WARNING="xyes" 984 CFOPT_WARNING="xyes"
985fi 985fi
986 986
987AC_COMPILE_IFELSE(
988 [AC_LANG_PROGRAM(
989 [[ ]],
990 [[
991 static __thread int a = 0;
992 ]])],
993 [have_thread_specifier="yes"],
994 [have_thread_specifier="no"])
995AC_MSG_CHECKING([for __thread specifier])
996AC_MSG_RESULT([${have_thread_specifier}])
997if test "x${have_thread_specifier}" = "xyes" ; then
998 AC_DEFINE([HAVE_THREAD_SPECIFIER], [1], [Have the __thread specifier])
999fi
1000
987EFL_ADD_PUBLIC_LIBS([EINA], [${EFL_PTHREAD_LIBS}]) 1001EFL_ADD_PUBLIC_LIBS([EINA], [${EFL_PTHREAD_LIBS}])
988EFL_ADD_CFLAGS([EINA], [${EFL_PTHREAD_CFLAGS}]) 1002EFL_ADD_CFLAGS([EINA], [${EFL_PTHREAD_CFLAGS}])
989 1003
@@ -4868,6 +4882,7 @@ EFL_ADD_FEATURE([thread], [spinlocks], [${efl_have_spinlock}])
4868EFL_ADD_FEATURE([thread], [barrier], [${efl_have_pthread_barrier}]) 4882EFL_ADD_FEATURE([thread], [barrier], [${efl_have_pthread_barrier}])
4869EFL_ADD_FEATURE([thread], [affinity], [${efl_have_setaffinity}]) 4883EFL_ADD_FEATURE([thread], [affinity], [${efl_have_setaffinity}])
4870EFL_ADD_FEATURE([thread], [setname], [${efl_have_setname}]) 4884EFL_ADD_FEATURE([thread], [setname], [${efl_have_setname}])
4885EFL_ADD_FEATURE([thread], [__thread], [${have_thread_specifier}])
4871 4886
4872echo 4887echo
4873echo 4888echo
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index bc71108..ee72b74 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -378,6 +378,13 @@ _eo_call_stack_free(void *ptr)
378 free(stack); 378 free(stack);
379} 379}
380 380
381#ifdef HAVE_THREAD_SPECIFIER
382static __thread Eo_Call_Stack *_eo_thread_stack = NULL;
383
384#define _EO_CALL_STACK_GET() ((_eo_thread_stack) ? _eo_thread_stack : (_eo_thread_stack = _eo_call_stack_create()))
385
386#else
387
381static Eo_Call_Stack *main_loop_stack = NULL; 388static Eo_Call_Stack *main_loop_stack = NULL;
382 389
383#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread()) 390#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;
385static inline Eo_Call_Stack * 392static inline Eo_Call_Stack *
386_eo_call_stack_get_thread(void) 393_eo_call_stack_get_thread(void)
387{ 394{
388 Eo_Call_Stack *stack; 395 Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key);
389
390 stack = eina_tls_get(_eo_call_stack_key);
391 396
392 if (stack) return stack; 397 if (stack) return stack;
393 398
@@ -396,6 +401,7 @@ _eo_call_stack_get_thread(void)
396 401
397 return stack; 402 return stack;
398} 403}
404#endif
399 405
400EAPI EINA_CONST void * 406EAPI EINA_CONST void *
401_eo_stack_get(void) 407_eo_stack_get(void)
@@ -1777,12 +1783,14 @@ eo_init(void)
1777 } 1783 }
1778 } 1784 }
1779 1785
1786#ifndef HAVE_THREAD_SPECIFIER
1780 main_loop_stack = _eo_call_stack_create(); 1787 main_loop_stack = _eo_call_stack_create();
1781 if (!main_loop_stack) 1788 if (!main_loop_stack)
1782 { 1789 {
1783 EINA_LOG_ERR("Could not alloc eo call stack."); 1790 EINA_LOG_ERR("Could not alloc eo call stack.");
1784 return EINA_FALSE; 1791 return EINA_FALSE;
1785 } 1792 }
1793#endif
1786 1794
1787 return EINA_TRUE; 1795 return EINA_TRUE;
1788} 1796}