From 23614b0fcb4cd4d7b2e4148d3b1887b642169765 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sun, 7 Sep 2014 10:28:08 -0400 Subject: add C11 thread creation and related thread functions based on patch by Jens Gustedt. the main difficulty here is handling the difference between start function signatures and thread return types for C11 threads versus POSIX threads. pointers to void are assumed to be able to represent faithfully all values of int. the function pointer for the thread start function is cast to an incorrect type for passing through pthread_create, but is cast back to its correct type before calling so that the behavior of the call is well-defined. changes to the existing threads implementation were kept minimal to reduce the risk of regressions, and duplication of code that carries implementation-specific assumptions was avoided for ease and safety of future maintenance. --- src/thread/pthread_detach.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/thread/pthread_detach.c') diff --git a/src/thread/pthread_detach.c b/src/thread/pthread_detach.c index 4e454634..ed77f74d 100644 --- a/src/thread/pthread_detach.c +++ b/src/thread/pthread_detach.c @@ -1,8 +1,9 @@ #include "pthread_impl.h" +#include int __pthread_join(pthread_t, void **); -int __pthread_detach(pthread_t t) +static int __pthread_detach(pthread_t t) { /* Cannot detach a thread that's already exiting */ if (a_swap(t->exitlock, 1)) @@ -13,3 +14,4 @@ int __pthread_detach(pthread_t t) } weak_alias(__pthread_detach, pthread_detach); +weak_alias(__pthread_detach, thrd_detach); -- cgit v1.2.1