Skip to content

Commit

Permalink
Add a kludge implementation of pthread_condattr_getclock
Browse files Browse the repository at this point in the history
This function isn't optional, and in any case setclock *is* provided
  • Loading branch information
ArcaneNibble committed Aug 6, 2024
1 parent ba7cba6 commit 2373829
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions expected/wasm32-wasip1-threads/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions libc-top-half/musl/src/thread/pthread_attr_get.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "pthread_impl.h"

#ifndef __wasilibc_unmodified_upstream
#include <common/clock.h>
#endif

int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state)
{
*state = a->_a_detach;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 2373829

Please sign in to comment.