$(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
thread/__wait.c \
thread/__timedwait.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 \
# Specify the tls-model until LLVM 15 is released (which should contain
# https://reviews.llvm.org/D130053).
CFLAGS += -mthread-model posix -pthread -ftls-model=local-exec
+
+# Include cloudlib's directory to access the structure definition of clockid_t
+CFLAGS += -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
endif
# Expose the public headers to the implementation. We use `-isystem` for
program_invocation_short_name
pselect
psignal
+pthread_condattr_destroy
+pthread_condattr_init
+pthread_condattr_setclock
+pthread_condattr_setpshared
pthread_mutex_consistent
pthread_mutex_destroy
pthread_mutex_getprioceiling
#include "pthread_impl.h"
+#ifndef __wasilibc_unmodified_upstream
+#include <common/clock.h>
+#endif
+
int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk)
{
+#ifdef __wasilibc_unmodified_upstream
if (clk < 0 || clk-2U < 2) return EINVAL;
+#else
+ if (clk->id < 0 || clk->id-2U < 2) return EINVAL;
+#endif
a->__attr &= 0x80000000;
+#ifdef __wasilibc_unmodified_upstream
a->__attr |= clk;
+#else
+ a->__attr |= clk->id;
+#endif
return 0;
}