summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-09-09 12:45:47 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-09-09 12:45:47 +0900
commit5625aac4d4860730428a0bca421f447425292aec (patch)
tree53049cbf421cea4b8f83b7b88f36729182b550d1 /src
parent712db856a2738505f245f2c0c98b3419993246de (diff)
eina thread - add wrapper for setting thread name and fix affinity
added support to set thread names for debugging. this wraps the gnu extension to set a thread name of up to 15 chars (16 inc nul byte). eina_thread_name_set() is the new api. @feature in the process i found the autofoo wasnt enabling cpu affinity support at all in reality, so i had to fix that at the same time.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eina/eina_config.h.in10
-rw-r--r--src/lib/eina/eina_thread.c10
-rw-r--r--src/lib/eina/eina_thread.h17
3 files changed, 37 insertions, 0 deletions
diff --git a/src/lib/eina/eina_config.h.in b/src/lib/eina/eina_config.h.in
index af65f3b6b6..9ec3b29372 100644
--- a/src/lib/eina/eina_config.h.in
+++ b/src/lib/eina/eina_config.h.in
@@ -42,11 +42,21 @@
42#define EINA_HAVE_THREADS 42#define EINA_HAVE_THREADS
43#endif 43#endif
44 44
45#ifdef EINA_HAVE_PTHREAD_AFFINITY
46# undef EINA_HAVE_PTHREAD_AFFINITY
47#endif
48@EINA_CONFIGURE_HAVE_PTHREAD_AFFINITY@
49
45#ifdef EINA_HAVE_PTHREAD_BARRIER 50#ifdef EINA_HAVE_PTHREAD_BARRIER
46# undef EINA_HAVE_PTHREAD_BARRIER 51# undef EINA_HAVE_PTHREAD_BARRIER
47#endif 52#endif
48@EINA_CONFIGURE_HAVE_PTHREAD_BARRIER@ 53@EINA_CONFIGURE_HAVE_PTHREAD_BARRIER@
49 54
55#ifdef EINA_HAVE_PTHREAD_SETNAME
56# undef EINA_HAVE_PTHREAD_SETNAME
57#endif
58@EINA_CONFIGURE_HAVE_PTHREAD_SETNAME@
59
50#ifdef EINA_HAVE_DEBUG_THREADS 60#ifdef EINA_HAVE_DEBUG_THREADS
51# undef EINA_HAVE_DEBUG_THREADS 61# undef EINA_HAVE_DEBUG_THREADS
52#endif 62#endif
diff --git a/src/lib/eina/eina_thread.c b/src/lib/eina/eina_thread.c
index cbc52ade83..2730662cd9 100644
--- a/src/lib/eina/eina_thread.c
+++ b/src/lib/eina/eina_thread.c
@@ -25,6 +25,7 @@
25#include "eina_config.h" 25#include "eina_config.h"
26#include "eina_thread.h" 26#include "eina_thread.h"
27#include "eina_sched.h" 27#include "eina_sched.h"
28#include "eina_cpu.h"
28 29
29/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */ 30/* undefs EINA_ARG_NONULL() so NULL checks are not compiled out! */
30#include "eina_safety_checks.h" 31#include "eina_safety_checks.h"
@@ -169,6 +170,15 @@ eina_thread_join(Eina_Thread t)
169 return _eina_thread_join(t); 170 return _eina_thread_join(t);
170} 171}
171 172
173EAPI Eina_Bool
174eina_thread_name_set(Eina_Thread t, const char *name)
175{
176#ifdef EINA_HAVE_PTHREAD_SETNAME
177 if (pthread_setname_np((pthread_t)t, name) == 0) return EINA_TRUE;
178#endif
179 return EINA_FALSE;
180}
181
172Eina_Bool 182Eina_Bool
173eina_thread_init(void) 183eina_thread_init(void)
174{ 184{
diff --git a/src/lib/eina/eina_thread.h b/src/lib/eina/eina_thread.h
index adbf34566b..6a2c26d02d 100644
--- a/src/lib/eina/eina_thread.h
+++ b/src/lib/eina/eina_thread.h
@@ -115,6 +115,23 @@ EAPI Eina_Bool eina_thread_create(Eina_Thread *t,
115EAPI void *eina_thread_join(Eina_Thread t); 115EAPI void *eina_thread_join(Eina_Thread t);
116 116
117/** 117/**
118 * Set the name of a given thread for debugging purposes.
119 *
120 * This maps to the pthread_setname_np() GNU extension or similar
121 * if available. The name may be limited in size (possibly 16
122 * characters including the nul byte terminator). This is useful
123 * for debugging to name a thread so external tools can display a
124 * meaningful name attached to the thread.
125 *
126 * @param t thread to set the name of
127 * @param name a string to name the thread - this cannot be NULL
128 * @return EINA_TRUE if it succeeds in setting the name or EINA_FALSE
129 * otherwise.
130 * @since 1.16
131 */
132EAPI Eina_Bool eina_thread_name_set(Eina_Thread t, const char *name);
133
134/**
118 * @} 135 * @}
119 */ 136 */
120 137