Skip to content

Commit 5d3c5e9

Browse files
authoredAug 2, 2024··
Improve some pthreads stub functions, batch 0 (#519)
This is one part of breaking up #518 into smaller PRs. This should be (IMO) the least-controversial batch of commits
1 parent b9ef79d commit 5d3c5e9

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed
 

‎Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,16 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
288288
thread/pthread_attr_destroy.c \
289289
thread/pthread_attr_get.c \
290290
thread/pthread_attr_init.c \
291-
thread/pthread_attr_setstack.c \
292291
thread/pthread_attr_setdetachstate.c \
292+
thread/pthread_attr_setguardsize.c \
293+
thread/pthread_attr_setstack.c \
293294
thread/pthread_attr_setstacksize.c \
294295
thread/pthread_barrier_destroy.c \
295296
thread/pthread_barrier_init.c \
296297
thread/pthread_barrier_wait.c \
298+
thread/pthread_barrierattr_destroy.c \
299+
thread/pthread_barrierattr_init.c \
300+
thread/pthread_barrierattr_setpshared.c \
297301
thread/pthread_cleanup_push.c \
298302
thread/pthread_cond_broadcast.c \
299303
thread/pthread_cond_destroy.c \

‎expected/wasm32-wasip1-threads/defined-symbols.txt

+4
Original file line numberDiff line numberDiff line change
@@ -992,12 +992,16 @@ pthread_attr_getstack
992992
pthread_attr_getstacksize
993993
pthread_attr_init
994994
pthread_attr_setdetachstate
995+
pthread_attr_setguardsize
995996
pthread_attr_setstack
996997
pthread_attr_setstacksize
997998
pthread_barrier_destroy
998999
pthread_barrier_init
9991000
pthread_barrier_wait
1001+
pthread_barrierattr_destroy
10001002
pthread_barrierattr_getpshared
1003+
pthread_barrierattr_init
1004+
pthread_barrierattr_setpshared
10011005
pthread_cond_broadcast
10021006
pthread_cond_destroy
10031007
pthread_cond_init

‎libc-top-half/musl/src/thread/pthread_attr_setguardsize.c

+5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
int pthread_attr_setguardsize(pthread_attr_t *a, size_t size)
44
{
5+
#ifdef __wasilibc_unmodified_upstream
56
if (size > SIZE_MAX/8) return EINVAL;
7+
#else
8+
/* WASI doesn't have memory protection required for stack guards. */
9+
if (size > 0) return EINVAL;
10+
#endif
611
a->_a_guardsize = size;
712
return 0;
813
}

‎libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust)
2222
a->__attr &= ~4;
2323
return 0;
2424
#else
25-
return EINVAL;
25+
if (robust) return EINVAL;
26+
return 0;
2627
#endif
2728
}

0 commit comments

Comments
 (0)
Please sign in to comment.