While the current code operates correctly, one needs to wrap all the typecasting via intptr_t to prevent compiler warnings such as
warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> --- AFAICS the warnings make things look scarier that what they truly are. Carry on reading for more details. The C11 threads API uses void* in order to be to move flexible while the POSIX threads uses int throughout. As we consistently typecast from void * to int and back we are practically safe. -Emil third_party/threads/threads_posix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/third_party/threads/threads_posix.c b/third_party/threads/threads_posix.c index f2c8bf5..6e6b983 100644 --- a/third_party/threads/threads_posix.c +++ b/third_party/threads/threads_posix.c @@ -66,7 +66,7 @@ static void *impl_thrd_routine(void *p) { struct impl_thrd_param pack = *((struct impl_thrd_param *)p); free(p); - return (void*)pack.func(pack.arg); + return (void*)(intptr_t)pack.func(pack.arg); } @@ -253,7 +253,7 @@ int thrd_equal(thrd_t thr0, thrd_t thr1) // 7.25.5.5 void thrd_exit(int res) { - pthread_exit((void*)res); + pthread_exit((void*)(intptr_t)res); } // 7.25.5.6 @@ -263,7 +263,7 @@ int thrd_join(thrd_t thr, int *res) if (pthread_join(thr, &code) != 0) return thrd_error; if (res) - *res = (int)code; + *res = (int)(intptr_t)code; return thrd_success; } -- 2.0.0 _______________________________________________ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle