diff --git a/expected/wasm32-wasip1-threads/defined-symbols.txt b/expected/wasm32-wasip1-threads/defined-symbols.txt index bfdeb3d5..7427fc3c 100644 --- a/expected/wasm32-wasip1-threads/defined-symbols.txt +++ b/expected/wasm32-wasip1-threads/defined-symbols.txt @@ -1009,6 +1009,7 @@ pthread_cond_signal pthread_cond_timedwait pthread_cond_wait pthread_condattr_destroy +pthread_condattr_getclock pthread_condattr_getpshared pthread_condattr_init pthread_condattr_setclock diff --git a/libc-top-half/musl/src/thread/pthread_attr_get.c b/libc-top-half/musl/src/thread/pthread_attr_get.c index 53e6388b..ab8d938c 100644 --- a/libc-top-half/musl/src/thread/pthread_attr_get.c +++ b/libc-top-half/musl/src/thread/pthread_attr_get.c @@ -1,5 +1,9 @@ #include "pthread_impl.h" +#ifndef __wasilibc_unmodified_upstream +#include +#endif + int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state) { *state = a->_a_detach; @@ -70,6 +74,15 @@ int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *r *clk = a->__attr & 0x7fffffff; return 0; } +#else +int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) +{ + if (a->__attr & 0x7fffffff == __WASI_CLOCKID_REALTIME) + *clk = CLOCK_REALTIME; + if (a->__attr & 0x7fffffff == __WASI_CLOCKID_MONOTONIC) + *clk = CLOCK_MONOTONIC; + return 0; +} #endif int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)