Skip to content

Commit 2373829

Browse files
committed
Add a kludge implementation of pthread_condattr_getclock
This function isn't optional, and in any case setclock *is* provided
1 parent ba7cba6 commit 2373829

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

expected/wasm32-wasip1-threads/defined-symbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,7 @@ pthread_cond_signal
10091009
pthread_cond_timedwait
10101010
pthread_cond_wait
10111011
pthread_condattr_destroy
1012+
pthread_condattr_getclock
10121013
pthread_condattr_getpshared
10131014
pthread_condattr_init
10141015
pthread_condattr_setclock

libc-top-half/musl/src/thread/pthread_attr_get.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "pthread_impl.h"
22

3+
#ifndef __wasilibc_unmodified_upstream
4+
#include <common/clock.h>
5+
#endif
6+
37
int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state)
48
{
59
*state = a->_a_detach;
@@ -70,6 +74,15 @@ int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *r
7074
*clk = a->__attr & 0x7fffffff;
7175
return 0;
7276
}
77+
#else
78+
int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
79+
{
80+
if (a->__attr & 0x7fffffff == __WASI_CLOCKID_REALTIME)
81+
*clk = CLOCK_REALTIME;
82+
if (a->__attr & 0x7fffffff == __WASI_CLOCKID_MONOTONIC)
83+
*clk = CLOCK_MONOTONIC;
84+
return 0;
85+
}
7386
#endif
7487

7588
int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)

0 commit comments

Comments
 (0)