|
56 | 56 | typedef pthread_t pthreadpool_thread_t; |
57 | 57 | typedef pthread_mutex_t pthreadpool_mutex_t; |
58 | 58 | typedef pthread_cond_t pthreadpool_cond_t; |
| 59 | +typedef void* pthreadpool_thread_return_t; |
59 | 60 | static inline void pthreadpool_mutex_init(pthreadpool_mutex_t* mutex) { |
60 | 61 | pthread_mutex_init(mutex, NULL); |
61 | 62 | } |
@@ -84,18 +85,20 @@ static inline void pthreadpool_cond_signal(pthreadpool_cond_t* cond) { |
84 | 85 | static inline void pthreadpool_cond_broadcast(pthreadpool_cond_t* cond) { |
85 | 86 | pthread_cond_broadcast(cond); |
86 | 87 | } |
87 | | -static inline void pthreadpool_thread_create(pthreadpool_thread_t* thread, |
88 | | - void*(fun)(void*), void* arg) { |
| 88 | +static inline void pthreadpool_thread_create( |
| 89 | + pthreadpool_thread_t* thread, pthreadpool_thread_return_t(fun)(void*), |
| 90 | + void* arg) { |
89 | 91 | pthread_create(thread, NULL, fun, arg); |
90 | 92 | } |
91 | | -static inline void pthreadpool_thread_join(pthreadpool_thread_t thread, |
92 | | - void* return_value) { |
93 | | - pthread_join(thread, (void**)return_value); |
| 93 | +static inline void pthreadpool_thread_join( |
| 94 | + pthreadpool_thread_t thread, pthreadpool_thread_return_t* return_value) { |
| 95 | + pthread_join(thread, return_value); |
94 | 96 | } |
95 | 97 | #else |
96 | 98 | typedef thrd_t pthreadpool_thread_t; |
97 | 99 | typedef mtx_t pthreadpool_mutex_t; |
98 | 100 | typedef cnd_t pthreadpool_cond_t; |
| 101 | +typedef int pthreadpool_thread_return_t; |
99 | 102 | static inline void pthreadpool_mutex_init(pthreadpool_mutex_t* mutex) { |
100 | 103 | mtx_init(mutex, mtx_plain); |
101 | 104 | } |
@@ -124,12 +127,13 @@ static inline void pthreadpool_cond_signal(pthreadpool_cond_t* cond) { |
124 | 127 | static inline void pthreadpool_cond_broadcast(pthreadpool_cond_t* cond) { |
125 | 128 | cnd_broadcast(cond); |
126 | 129 | } |
127 | | -static inline void pthreadpool_thread_create(pthreadpool_thread_t* thread, |
128 | | - void*(fun)(void*), void* arg) { |
| 130 | +static inline void pthreadpool_thread_create( |
| 131 | + pthreadpool_thread_t* thread, pthreadpool_thread_return_t(fun)(void*), |
| 132 | + void* arg) { |
129 | 133 | thrd_create(thread, fun, arg); |
130 | 134 | } |
131 | | -static inline void pthreadpool_thread_join(pthreadpool_thread_t thread, |
132 | | - void* return_value) { |
| 135 | +static inline void pthreadpool_thread_join( |
| 136 | + pthreadpool_thread_t thread, pthreadpool_thread_return_t* return_value) { |
133 | 137 | thrd_join(thread, return_value); |
134 | 138 | } |
135 | 139 | #endif // PTHREADPOOL_USE_PTHREADS |
|
0 commit comments