From e082ab0e741c49fd8fee11be94f460a001befa9e Mon Sep 17 00:00:00 2001 From: Vincent Torri Date: Thu, 25 Oct 2012 05:21:58 +0000 Subject: [PATCH] Eina: add affinity to win32 code. It's not working yet: * eina_thread.c:152:33: error: 'index' undeclared (first use in this function) * eina_thread.c:295:4: warning: passing argument 3 of '_eina_thread_win32_create' from incompatible pointer type [enabled by default] also: * line 142, is it normal that we call eina_list_append() with tw being NULL ? * is what I did in the close_thread label correct ? SVN revision: 78416 --- m4/efl_threads.m4 | 1 + src/lib/eina/eina_thread.c | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/m4/efl_threads.m4 b/m4/efl_threads.m4 index a1bcc0308d..bba617f955 100644 --- a/m4/efl_threads.m4 +++ b/m4/efl_threads.m4 @@ -24,6 +24,7 @@ _efl_have_win32_threads="no" case "$host_os" in mingw*) _efl_have_win32_threads="yes" + efl_have_setaffinity="yes" AC_DEFINE([EFL_HAVE_WIN32_THREADS], [1], [Define to mention that Win32 threads are supported]) AC_DEFINE([EFL_HAVE_THREADS], [1], [Define to mention that POSIX or Win32 threads are supported]) ;; diff --git a/src/lib/eina/eina_thread.c b/src/lib/eina/eina_thread.c index 993b47912d..4015681219 100644 --- a/src/lib/eina/eina_thread.c +++ b/src/lib/eina/eina_thread.c @@ -22,10 +22,6 @@ #include -#ifdef HAVE_EVIL -# include -#endif - #include "eina_config.h" #include "eina_thread.h" #include "eina_sched.h" @@ -35,6 +31,8 @@ # elif defined(_WIN32) +# include "eina_list.h" + # define WIN32_LEAN_AND_MEAN # include # undef WIN32_LEAN_AND_MEAN @@ -72,6 +70,8 @@ static Eina_Thread _eina_thread_win32_self(void) { HANDLE t; + Eina_Thread_Win32 *tw; + Eina_List *l; t = GetCurrentThread(); EINA_LIST_FOREACH(_thread_running, l, tw) @@ -121,20 +121,26 @@ _eina_thread_win32_create(Eina_Thread *t, } while (tw->index == 0); /* prevent having a "false" main loop */ } - tw->func = f; - tw->data = d; + tw->func = func; + tw->data = (void *)data; tw->thread = CreateThread(NULL, 0, _eina_thread_win32_cb, tw, 0, NULL); if (!tw->thread) goto on_error; + if (!SetThreadAffinityMask(tw->thread, 1 << affinity)) + goto close_thread; + _thread_running = eina_list_append(_thread_running, tw); *t = tw->index; return EINA_TRUE; + close_thread: + Closehandle(tw->thread); + tw->thread = NULL; on_error: _thread_pool = eina_list_append(_thread_pool, tw); - return EINA_FALSE; + return EINA_FALSE; } static void *