summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcarlos <caiosignor@gmail.com>2020-04-20 10:29:25 -0300
committerJoão Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>2020-04-29 12:13:38 -0300
commit8b4b7d0e641691310536cbaa5a8cb47695003d92 (patch)
treeb82eb9d8f9969c7c484007396e450b3003e99bdf
parent0c7d90a12cd4fefc02c39104e38ea21485afc364 (diff)
meson.build verify if exists symbols thread_setname and thread_setaffinity for win32
-rw-r--r--src/lib/eina/eina_debug.c6
-rw-r--r--src/lib/eina/eina_debug_timer.c4
-rw-r--r--src/lib/eina/eina_inline_thread_win32.x9
-rw-r--r--src/lib/eina/eina_thread.c4
-rw-r--r--src/lib/eina/eina_thread_posix.h2
-rw-r--r--src/lib/eina/meson.build10
6 files changed, 24 insertions, 11 deletions
diff --git a/src/lib/eina/eina_debug.c b/src/lib/eina/eina_debug.c
index 78808656a2..2ce74cb190 100644
--- a/src/lib/eina/eina_debug.c
+++ b/src/lib/eina/eina_debug.c
@@ -71,8 +71,8 @@
71#include "eina_debug_private.h" 71#include "eina_debug_private.h"
72#include "eina_vpath.h" 72#include "eina_vpath.h"
73#include "eina_internal.h" 73#include "eina_internal.h"
74// #include "eina_thread.h" 74#include "eina_thread.h"
75#ifdef EINA_HAVE_THREAD_SETNAME 75#ifdef EINA_HAVE_PTHREAD_SETNAME
76# ifndef __linux__ 76# ifndef __linux__
77# include <pthread_np.h> 77# include <pthread_np.h>
78# endif 78# endif
@@ -554,7 +554,7 @@ _monitor(void *_data)
554 _opcodes_register_all(session); 554 _opcodes_register_all(session);
555 555
556 // set a name for this thread for system debugging 556 // set a name for this thread for system debugging
557#ifdef EINA_HAVE_THREAD_SETNAME 557#ifdef EINA_HAVE_PTHREAD_SETNAME || EINA_HAVE_WIN32_THREAD_SETNAME
558 eina_thread_name_set(eina_thread_self(), "Edbg-mon"); 558 eina_thread_name_set(eina_thread_self(), "Edbg-mon");
559#endif 559#endif
560 560
diff --git a/src/lib/eina/eina_debug_timer.c b/src/lib/eina/eina_debug_timer.c
index 6521ef5281..9bbe7214f5 100644
--- a/src/lib/eina/eina_debug_timer.c
+++ b/src/lib/eina/eina_debug_timer.c
@@ -94,7 +94,7 @@ _monitor(void *_data EINA_UNUSED)
94 event.events = EPOLLIN; 94 event.events = EPOLLIN;
95 ret = epoll_ctl(epfd, EPOLL_CTL_ADD, event.data.fd, &event); 95 ret = epoll_ctl(epfd, EPOLL_CTL_ADD, event.data.fd, &event);
96 if (ret) perror("epoll_ctl/add"); 96 if (ret) perror("epoll_ctl/add");
97# ifdef EINA_HAVE_THREAD_SETNAME 97# ifdef EINA_HAVE_PTHREAD_SETNAME || EINA_HAVE_WIN32_THREAD_SETNAME
98 eina_thread_name_set(eina_thread_self(), "Edbg-tim"); 98 eina_thread_name_set(eina_thread_self(), "Edbg-tim");
99# endif 99# endif
100 100
@@ -177,7 +177,7 @@ eina_debug_timer_add(unsigned int timeout_ms, Eina_Debug_Timer_Cb cb, void *data
177 # endif 177 # endif
178 pthread_sigmask(SIG_BLOCK, &newset, &oldset); 178 pthread_sigmask(SIG_BLOCK, &newset, &oldset);
179 #endif 179 #endif
180 int err = eina_thread_create(&_thread, EINA_THREAD_BACKGROUND, NULL, _monitor, NULL); 180 int err = eina_thread_create(&_thread, EINA_THREAD_BACKGROUND, NULL,(Eina_Thread_Cb)_monitor, NULL);
181 #ifndef _WIN32 181 #ifndef _WIN32
182 pthread_sigmask(SIG_SETMASK, &oldset, NULL); 182 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
183 #endif 183 #endif
diff --git a/src/lib/eina/eina_inline_thread_win32.x b/src/lib/eina/eina_inline_thread_win32.x
index 8046dba0a8..4c01c394ab 100644
--- a/src/lib/eina/eina_inline_thread_win32.x
+++ b/src/lib/eina/eina_inline_thread_win32.x
@@ -102,8 +102,13 @@ _eina_thread_create(Eina_Thread *t, int affinity, void *(*func)(void *data), voi
102 102
103 ret = (*t != NULL) ? EINA_TRUE : EINA_FALSE; 103 ret = (*t != NULL) ? EINA_TRUE : EINA_FALSE;
104 104
105 if (affinity >= 0 && ret) SetThreadAffinityMask(*t, (DWORD_PTR *)&affinity); 105 if (affinity >= 0 && ret)
106 106 {
107 #ifdef EINA_HAVE_WIN32_THREAD_AFFINITY
108 SetThreadAffinityMask(*t, (DWORD_PTR *)&affinity);
109 #endif
110 }
111
107 return ret; 112 return ret;
108} 113}
109 114
diff --git a/src/lib/eina/eina_thread.c b/src/lib/eina/eina_thread.c
index c8fb773418..49984b2e33 100644
--- a/src/lib/eina/eina_thread.c
+++ b/src/lib/eina/eina_thread.c
@@ -41,7 +41,7 @@
41#endif 41#endif
42# include <string.h> 42# include <string.h>
43 43
44#if defined(EINA_HAVE_PTHREAD_AFFINITY) || defined(EINA_HAVE_THREAD_SETNAME) 44#if defined(EINA_HAVE_PTHREAD_AFFINITY) || defined(EINA_HAVE_PTHREAD_SETNAME)
45# define cpu_set_t cpuset_t 45# define cpu_set_t cpuset_t
46#endif 46#endif
47 47
@@ -117,7 +117,7 @@ eina_thread_join(Eina_Thread t)
117EAPI Eina_Bool 117EAPI Eina_Bool
118eina_thread_name_set(Eina_Thread t, const char *name) 118eina_thread_name_set(Eina_Thread t, const char *name)
119{ 119{
120#ifdef EINA_HAVE_THREAD_SETNAME 120#if defined(EINA_HAVE_PTHREAD_SETNAME) || defined(EINA_HAVE_WIN32_THREAD_SETNAME)
121 char buf[16]; 121 char buf[16];
122 if (name) 122 if (name)
123 { 123 {
diff --git a/src/lib/eina/eina_thread_posix.h b/src/lib/eina/eina_thread_posix.h
index d198e12f1e..470e5a359f 100644
--- a/src/lib/eina/eina_thread_posix.h
+++ b/src/lib/eina/eina_thread_posix.h
@@ -34,7 +34,7 @@
34#define EINA_THREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS 34#define EINA_THREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
35#define EINA_THREAD_CANCELED PTHREAD_CANCELED 35#define EINA_THREAD_CANCELED PTHREAD_CANCELED
36 36
37#if defined(EINA_HAVE_PTHREAD_AFFINITY) || defined(EINA_HAVE_THREAD_SETNAME) 37#if defined(EINA_HAVE_PTHREAD_AFFINITY) || defined(EINA_HAVE_PTHREAD_SETNAME)
38# ifndef __linux__ 38# ifndef __linux__
39# include <pthread_np.h> 39# include <pthread_np.h>
40# define cpu_set_t cpuset_t 40# define cpu_set_t cpuset_t
diff --git a/src/lib/eina/meson.build b/src/lib/eina/meson.build
index 71eda3d95c..5d52682d58 100644
--- a/src/lib/eina/meson.build
+++ b/src/lib/eina/meson.build
@@ -304,13 +304,21 @@ else
304endif 304endif
305 305
306if cc.has_header_symbol(pthread_np_header_file, pthread_setname_np_api, args : pthread_args) 306if cc.has_header_symbol(pthread_np_header_file, pthread_setname_np_api, args : pthread_args)
307 eina_config.set('EINA_HAVE_THREAD_SETNAME', '1') 307 eina_config.set('EINA_HAVE_PTHREAD_SETNAME', '1')
308endif
309
310if cc.has_header_symbol('precessthreadspi.h', 'SetThreadDescription')
311 eina_config.set('EINA_HAVE_WIN32_THREAD_SETNAME', '1')
308endif 312endif
309 313
310if cc.has_header_symbol(pthread_np_header_file, 'pthread_attr_setaffinity_np', args : pthread_args) 314if cc.has_header_symbol(pthread_np_header_file, 'pthread_attr_setaffinity_np', args : pthread_args)
311 eina_config.set('EINA_HAVE_PTHREAD_AFFINITY', '1') 315 eina_config.set('EINA_HAVE_PTHREAD_AFFINITY', '1')
312endif 316endif
313 317
318if cc.has_header_symbol('WinBase.h', 'SetThreadAffinityMask')
319 eina_config.set('EINA_HAVE_WIN32_THREAD_AFFINITY', '1')
320endif
321
314if debug_threads or get_option('debug-threads') 322if debug_threads or get_option('debug-threads')
315 if cc.has_header_symbol('execinfo.h', 'backtrace') 323 if cc.has_header_symbol('execinfo.h', 'backtrace')
316 eina_config.set('EINA_HAVE_DEBUG_THREADS', '1') 324 eina_config.set('EINA_HAVE_DEBUG_THREADS', '1')