projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix integer overflow in elf.h macro SHF_EXCLUDE
[musl]
/
src
/
thread
/
pthread_detach.c
diff --git
a/src/thread/pthread_detach.c
b/src/thread/pthread_detach.c
index
f0eae3e
..
ed77f74
100644
(file)
--- a/
src/thread/pthread_detach.c
+++ b/
src/thread/pthread_detach.c
@@
-1,11
+1,17
@@
#include "pthread_impl.h"
#include "pthread_impl.h"
+#include <threads.h>
-int pthread_detach(pthread_t t)
+int __pthread_join(pthread_t, void **);
+
+static int __pthread_detach(pthread_t t)
{
/* Cannot detach a thread that's already exiting */
{
/* Cannot detach a thread that's already exiting */
- if (a_
xchg(&
t->exitlock, 1))
- return pthread_join(t, 0);
- t->detached =
1
;
-
t->exitlock = 0
;
+ if (a_
swap(
t->exitlock, 1))
+ return
__
pthread_join(t, 0);
+ t->detached =
2
;
+
__unlock(t->exitlock)
;
return 0;
}
return 0;
}
+
+weak_alias(__pthread_detach, pthread_detach);
+weak_alias(__pthread_detach, thrd_detach);