summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcarlos <caiosignor@gmail.com>2020-04-17 14:35:29 -0300
committerJoão Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com>2020-04-29 12:13:38 -0300
commit2a29c410aa6c1d23b69649b0f685e6dbcf7bf7c5 (patch)
tree66463a8d2a6ea040229319d7fb4d552ddad6c7fe
parent4cee97de7e1becb523ccf70bab60241ec4404cf2 (diff)
eina_inline_thread_posix code convention
-rw-r--r--src/lib/eina/eina_inline_thread_posix.x34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/lib/eina/eina_inline_thread_posix.x b/src/lib/eina/eina_inline_thread_posix.x
index 8f51f2b55e..7c8dcac8ee 100644
--- a/src/lib/eina/eina_inline_thread_posix.x
+++ b/src/lib/eina/eina_inline_thread_posix.x
@@ -28,7 +28,8 @@ _eina_thread_join(Eina_Thread t)
28 return NULL; 28 return NULL;
29} 29}
30 30
31static inline Eina_Bool _eina_thread_name_set(Eina_Thread thread, char *buf) 31static inline Eina_Bool
32_eina_thread_name_set(Eina_Thread thread, char *buf)
32{ 33{
33#ifndef __linux__ 34#ifndef __linux__
34 pthread_set_name_np((pthread_t)t, buf); 35 pthread_set_name_np((pthread_t)t, buf);
@@ -48,15 +49,14 @@ _eina_thread_create(Eina_Thread *t, int affinity, void *(*func)(void *data), voi
48 49
49 pthread_attr_init(&attr); 50 pthread_attr_init(&attr);
50 if (affinity >= 0) 51 if (affinity >= 0)
51 { 52 {
52#ifdef EINA_HAVE_PTHREAD_AFFINITY 53 #ifdef EINA_HAVE_PTHREAD_AFFINITY
53 cpu_set_t cpu; 54 cpu_set_t cpu;
54 55 CPU_ZERO(&cpu);
55 CPU_ZERO(&cpu); 56 CPU_SET(affinity, &cpu);
56 CPU_SET(affinity, &cpu); 57 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu);
57 pthread_attr_setaffinity_np(&attr, sizeof(cpu), &cpu); 58 #endif
58#endif 59 }
59 }
60 60
61 /* setup initial locks */ 61 /* setup initial locks */
62 62
@@ -92,7 +92,8 @@ _eina_thread_equal(Eina_Thread t1, Eina_Thread t2)
92 return !!pthread_equal((pthread_t)t1, (pthread_t)t2); 92 return !!pthread_equal((pthread_t)t1, (pthread_t)t2);
93} 93}
94 94
95static inline Eina_Bool _eina_thread_cancel(Eina_Thread thread) 95static inline Eina_Bool
96_eina_thread_cancel(Eina_Thread thread)
96{ 97{
97 return pthread_cancel((pthread_t)thread); 98 return pthread_cancel((pthread_t)thread);
98} 99}
@@ -103,14 +104,18 @@ _eina_thread_self(void)
103 return (Eina_Thread)pthread_self(); 104 return (Eina_Thread)pthread_self();
104} 105}
105 106
106static inline void _eina_thread_setcanceltype(int type, int *oldtype) 107static inline void
108_eina_thread_setcanceltype(int type, int *oldtype)
107{ 109{
108 pthread_setcanceltype(EINA_THREAD_CANCEL_DEFERRED, &oldtype); 110 pthread_setcanceltype(EINA_THREAD_CANCEL_DEFERRED, &oldtype);
109} 111}
110static inline int _eina_thread_setcancelstate(int type, int *oldtype) 112
113static inline int
114_eina_thread_setcancelstate(int type, int *oldtype)
111{ 115{
112 return pthread_setcancelstate(type, &oldtype); 116 return pthread_setcancelstate(type, &oldtype);
113} 117}
118
114static inline Eina_Bool 119static inline Eina_Bool
115_eina_thread_cancellable_set(Eina_Bool cancellable, Eina_Bool *was_cancellable) 120_eina_thread_cancellable_set(Eina_Bool cancellable, Eina_Bool *was_cancellable)
116{ 121{
@@ -124,9 +129,10 @@ _eina_thread_cancellable_set(Eina_Bool cancellable, Eina_Bool *was_cancellable)
124 129
125 r = _eina_thread_setcancelstate(state, &old); 130 r = _eina_thread_setcancelstate(state, &old);
126 if (was_cancellable && r == 0) 131 if (was_cancellable && r == 0)
127 *was_cancellable = (old == EINA_THREAD_CANCEL_ENABLE); 132 *was_cancellable = (old == EINA_THREAD_CANCEL_ENABLE);
128 return r == 0; 133 return r == 0;
129} 134}
135
130static inline void _eina_thread_cancel_checkpoint(){ 136static inline void _eina_thread_cancel_checkpoint(){
131 pthread_testcancel(); 137 pthread_testcancel();
132} \ No newline at end of file 138} \ No newline at end of file