forked from enlightenment/efl
Eo do: use the __thread directive when available to manage call stack.
This is faster in most cases, and to be honest, should be much faster than it is. I don't understand why there's no better directive to mark a variable as *really* important thread storage that is used all the time.
This commit is contained in:
parent
3e40b45be6
commit
0bebaed0ac
15
configure.ac
15
configure.ac
|
@ -984,6 +984,20 @@ if test "x${efl_have_threads}" = "xno"; then
|
||||||
CFOPT_WARNING="xyes"
|
CFOPT_WARNING="xyes"
|
||||||
fi
|
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_PUBLIC_LIBS([EINA], [${EFL_PTHREAD_LIBS}])
|
||||||
EFL_ADD_CFLAGS([EINA], [${EFL_PTHREAD_CFLAGS}])
|
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], [barrier], [${efl_have_pthread_barrier}])
|
||||||
EFL_ADD_FEATURE([thread], [affinity], [${efl_have_setaffinity}])
|
EFL_ADD_FEATURE([thread], [affinity], [${efl_have_setaffinity}])
|
||||||
EFL_ADD_FEATURE([thread], [setname], [${efl_have_setname}])
|
EFL_ADD_FEATURE([thread], [setname], [${efl_have_setname}])
|
||||||
|
EFL_ADD_FEATURE([thread], [__thread], [${have_thread_specifier}])
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo
|
echo
|
||||||
|
|
|
@ -375,6 +375,13 @@ _eo_call_stack_free(void *ptr)
|
||||||
free(stack);
|
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;
|
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())
|
#define _EO_CALL_STACK_GET() ((EINA_LIKELY(eina_main_loop_is())) ? main_loop_stack : _eo_call_stack_get_thread())
|
||||||
|
@ -382,9 +389,7 @@ static Eo_Call_Stack *main_loop_stack = NULL;
|
||||||
static inline Eo_Call_Stack *
|
static inline Eo_Call_Stack *
|
||||||
_eo_call_stack_get_thread(void)
|
_eo_call_stack_get_thread(void)
|
||||||
{
|
{
|
||||||
Eo_Call_Stack *stack;
|
Eo_Call_Stack *stack = eina_tls_get(_eo_call_stack_key);
|
||||||
|
|
||||||
stack = eina_tls_get(_eo_call_stack_key);
|
|
||||||
|
|
||||||
if (stack) return stack;
|
if (stack) return stack;
|
||||||
|
|
||||||
|
@ -393,6 +398,7 @@ _eo_call_stack_get_thread(void)
|
||||||
|
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
EAPI EINA_CONST void *
|
EAPI EINA_CONST void *
|
||||||
_eo_stack_get(void)
|
_eo_stack_get(void)
|
||||||
|
@ -1826,12 +1832,14 @@ eo_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HAVE_THREAD_SPECIFIER
|
||||||
main_loop_stack = _eo_call_stack_create();
|
main_loop_stack = _eo_call_stack_create();
|
||||||
if (!main_loop_stack)
|
if (!main_loop_stack)
|
||||||
{
|
{
|
||||||
EINA_LOG_ERR("Could not alloc eo call stack.");
|
EINA_LOG_ERR("Could not alloc eo call stack.");
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue