$(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
thread/__wait.c \
thread/__timedwait.c \
+ thread/pthread_cleanup_push.c \
+ thread/pthread_cond_broadcast.c \
+ thread/pthread_cond_destroy.c \
+ thread/pthread_cond_init.c \
+ thread/pthread_cond_signal.c \
+ thread/pthread_cond_timedwait.c \
+ thread/pthread_cond_wait.c \
thread/pthread_condattr_destroy.c \
thread/pthread_condattr_init.c \
thread/pthread_condattr_setclock.c \
thread/pthread_condattr_setpshared.c \
- thread/pthread_cleanup_push.c \
thread/pthread_mutex_consistent.c \
thread/pthread_mutex_destroy.c \
thread/pthread_mutex_init.c \
#include "pthread_impl.h"
+#ifndef __wasilibc_unmodified_upstream
+#include <common/clock.h>
+#endif
+
/*
* struct waiter
*
static inline void unlock_requeue(volatile int *l, volatile int *r, int w)
{
a_store(l, 0);
+#ifdef __wasilibc_unmodified_upstream
if (w) __wake(l, 1, 1);
else __syscall(SYS_futex, l, FUTEX_REQUEUE|FUTEX_PRIVATE, 0, 1, r) != -ENOSYS
|| __syscall(SYS_futex, l, FUTEX_REQUEUE, 0, 1, r);
+#else
+ // Always wake due to lack of requeue system call in WASI
+ // This can impact the performance, so we might need to re-visit that decision
+ __wake(l, 1, 1);
+#endif
}
enum {
{
struct waiter node = { 0 };
int e, seq, clock = c->_c_clock, cs, shared=0, oldstate, tmp;
+#ifndef __wasilibc_unmodified_upstream
+ struct __clockid clock_id = { .id = clock };
+#endif
volatile int *fut;
if ((m->_m_type&15) && (m->_m_lock&INT_MAX) != __pthread_self()->tid)
__pthread_setcancelstate(PTHREAD_CANCEL_MASKED, &cs);
if (cs == PTHREAD_CANCEL_DISABLE) __pthread_setcancelstate(cs, 0);
+#ifdef __wasilibc_unmodified_upstream
do e = __timedwait_cp(fut, seq, clock, ts, !shared);
+#else
+ do e = __timedwait_cp(fut, seq, &clock_id, ts, !shared);
+#endif
while (*fut==seq && (!e || e==EINTR));
if (e == EINTR) e = 0;