Skip to content

Commit 9d2f5a8

Browse files
authored
threads: enable pthread_join (#336)
1 parent d02cec6 commit 9d2f5a8

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
205205
thread/pthread_condattr_setclock.c \
206206
thread/pthread_condattr_setpshared.c \
207207
thread/pthread_create.c \
208+
thread/pthread_join.c \
208209
thread/pthread_mutex_consistent.c \
209210
thread/pthread_mutex_destroy.c \
210211
thread/pthread_mutex_init.c \

expected/wasm32-wasi/posix/defined-symbols.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ __progname_full
187187
__pthread_cond_timedwait
188188
__pthread_create
189189
__pthread_exit
190+
__pthread_join
190191
__pthread_mutex_lock
191192
__pthread_mutex_timedlock
192193
__pthread_mutex_trylock
@@ -964,6 +965,7 @@ pthread_condattr_setclock
964965
pthread_condattr_setpshared
965966
pthread_create
966967
pthread_exit
968+
pthread_join
967969
pthread_mutex_consistent
968970
pthread_mutex_destroy
969971
pthread_mutex_getprioceiling
@@ -992,6 +994,8 @@ pthread_rwlockattr_init
992994
pthread_rwlockattr_setpshared
993995
pthread_setcancelstate
994996
pthread_testcancel
997+
pthread_timedjoin_np
998+
pthread_tryjoin_np
995999
putc
9961000
putc_unlocked
9971001
putchar

libc-top-half/musl/src/thread/pthread_join.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#define _GNU_SOURCE
22
#include "pthread_impl.h"
3+
#ifdef __wasilibc_unmodified_upstream
34
#include <sys/mman.h>
5+
#endif
46

57
static void dummy1(pthread_t t)
68
{
@@ -21,7 +23,11 @@ static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec
2123
if (r == ETIMEDOUT || r == EINVAL) return r;
2224
__tl_sync(t);
2325
if (res) *res = t->result;
26+
#ifdef __wasilibc_unmodified_upstream
2427
if (t->map_base) __munmap(t->map_base, t->map_size);
28+
#else
29+
if (t->map_base) free(t->map_base);
30+
#endif
2531
return 0;
2632
}
2733

0 commit comments

Comments
 (0)