Skip to content

Commit

Permalink
Improve some pthreads stub functions, batch 0 (WebAssembly#519)
Browse files Browse the repository at this point in the history
This is one part of breaking up WebAssembly#518 into smaller PRs. This should be
(IMO) the least-controversial batch of commits
  • Loading branch information
ArcaneNibble authored Aug 2, 2024
1 parent b9ef79d commit 5d3c5e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,16 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
thread/pthread_attr_destroy.c \
thread/pthread_attr_get.c \
thread/pthread_attr_init.c \
thread/pthread_attr_setstack.c \
thread/pthread_attr_setdetachstate.c \
thread/pthread_attr_setguardsize.c \
thread/pthread_attr_setstack.c \
thread/pthread_attr_setstacksize.c \
thread/pthread_barrier_destroy.c \
thread/pthread_barrier_init.c \
thread/pthread_barrier_wait.c \
thread/pthread_barrierattr_destroy.c \
thread/pthread_barrierattr_init.c \
thread/pthread_barrierattr_setpshared.c \
thread/pthread_cleanup_push.c \
thread/pthread_cond_broadcast.c \
thread/pthread_cond_destroy.c \
Expand Down
4 changes: 4 additions & 0 deletions expected/wasm32-wasip1-threads/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -992,12 +992,16 @@ pthread_attr_getstack
pthread_attr_getstacksize
pthread_attr_init
pthread_attr_setdetachstate
pthread_attr_setguardsize
pthread_attr_setstack
pthread_attr_setstacksize
pthread_barrier_destroy
pthread_barrier_init
pthread_barrier_wait
pthread_barrierattr_destroy
pthread_barrierattr_getpshared
pthread_barrierattr_init
pthread_barrierattr_setpshared
pthread_cond_broadcast
pthread_cond_destroy
pthread_cond_init
Expand Down
5 changes: 5 additions & 0 deletions libc-top-half/musl/src/thread/pthread_attr_setguardsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

int pthread_attr_setguardsize(pthread_attr_t *a, size_t size)
{
#ifdef __wasilibc_unmodified_upstream
if (size > SIZE_MAX/8) return EINVAL;
#else
/* WASI doesn't have memory protection required for stack guards. */
if (size > 0) return EINVAL;
#endif
a->_a_guardsize = size;
return 0;
}
3 changes: 2 additions & 1 deletion libc-top-half/musl/src/thread/pthread_mutexattr_setrobust.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust)
a->__attr &= ~4;
return 0;
#else
return EINVAL;
if (robust) return EINVAL;
return 0;
#endif
}

0 comments on commit 5d3c5e9

Please sign in to comment.