path: root/src/thread/pthread_equal.c
diff options
authorRich Felker <>2014-09-07 10:28:08 -0400
committerRich Felker <>2014-09-07 10:28:08 -0400
commit23614b0fcb4cd4d7b2e4148d3b1887b642169765 (patch)
treeffee3db90209dedcc61b1afdd255be2af2d39b8a /src/thread/pthread_equal.c
parent14397cec2c8429b504b17aaf92509b48da3681b9 (diff)
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.
Diffstat (limited to 'src/thread/pthread_equal.c')
1 files changed, 6 insertions, 1 deletions
diff --git a/src/thread/pthread_equal.c b/src/thread/pthread_equal.c
index 3e3df4fd..7c31482a 100644
--- a/src/thread/pthread_equal.c
+++ b/src/thread/pthread_equal.c
@@ -1,6 +1,11 @@
#include <pthread.h>
+#include <threads.h>
+#include "libc.h"
-int (pthread_equal)(pthread_t a, pthread_t b)
+static int __pthread_equal(pthread_t a, pthread_t b)
return a==b;
+weak_alias(__pthread_equal, pthread_equal);
+weak_alias(__pthread_equal, thrd_equal);