aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-16 15:13:51 +0100
committerTom Hacohen <tom@stosb.com>2015-10-19 10:22:41 +0100
commitb9a6a8e7384fc79fced2132407208abfedf77fe1 (patch)
tree4878ab1a8abfc9573a8a2518fa21e02c4198cb51 /src
parentEo: Remove extra paranoid-never could happen safety checks. (diff)
downloadefl-b9a6a8e7384fc79fced2132407208abfedf77fe1.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eo/eo.c14
1 files changed, 11 insertions, 3 deletions
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;
}