diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-01-13 20:05:08 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2020-02-09 13:56:48 +0100 |
commit | 0c0361235ca7d4f5be0f88fe9b03afcf6a3cb8c6 (patch) | |
tree | 1a891e5c28f899d5490a7068b36d17f0515e023a /htl/pt-create.c | |
parent | 95669bbf2c20518cbbcd31681e2dc954c5233b79 (diff) | |
download | glibc-0c0361235ca7d4f5be0f88fe9b03afcf6a3cb8c6.tar.gz glibc-0c0361235ca7d4f5be0f88fe9b03afcf6a3cb8c6.tar.xz glibc-0c0361235ca7d4f5be0f88fe9b03afcf6a3cb8c6.zip |
htl: Add support for C11 threads behavior
Essentially properly calling the thread function which returns an int instead of a void*. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'htl/pt-create.c')
-rw-r--r-- | htl/pt-create.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/htl/pt-create.c b/htl/pt-create.c index 0b3237f46a..090d394f53 100644 --- a/htl/pt-create.c +++ b/htl/pt-create.c @@ -59,7 +59,17 @@ entry_point (struct __pthread *self, void *(*start_routine) (void *), void *arg) __pthread_startup (); - __pthread_exit (start_routine (arg)); + if (self->c11) + { + /* The function pointer of the c11 thread start is cast to an incorrect + type on __pthread_create call, however it is casted back to correct + one so the call behavior is well-defined (it is assumed that pointers + to void are able to represent all values of int). */ + int (*start)(void*) = (int (*) (void*)) start_routine; + __pthread_exit ((void*) (uintptr_t) start (arg)); + } + else + __pthread_exit (start_routine (arg)); } /* Create a thread with attributes given by ATTR, executing @@ -99,6 +109,14 @@ __pthread_create_internal (struct __pthread **thread, if (err) goto failed; + if (attr == ATTR_C11_THREAD) + { + attr = NULL; + pthread->c11 = true; + } + else + pthread->c11 = false; + /* Use the default attributes if ATTR is NULL. */ setup = attr ? attr : &__pthread_default_attr; |