Skip to content

Commit 501c620

Browse files
abrownjohn-sharratt
authored andcommitted
threads: enable access to pthread_attr_get functions (WebAssembly#357)
The pthreads API exposes functions for querying the attributes of a thread. This change allows these functions to be compiled in the `THREAD_MODEL=posix` build. Some functions are skipped (and documented); they can be added if/when needed. This change is motivated by a `libc-test` test that uses these functions.
1 parent 3b3d762 commit 501c620

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
228228
thread/__timedwait.c \
229229
thread/default_attr.c \
230230
thread/pthread_attr_destroy.c \
231+
thread/pthread_attr_get.c \
231232
thread/pthread_attr_init.c \
232233
thread/pthread_attr_setstack.c \
233234
thread/pthread_attr_setstacksize.c \

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ int pthread_attr_getinheritsched(const pthread_attr_t *restrict a, int *restrict
1717
return 0;
1818
}
1919

20+
#ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */
2021
int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param)
2122
{
2223
param->sched_priority = a->_a_prio;
@@ -28,6 +29,7 @@ int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict
2829
*policy = a->_a_policy;
2930
return 0;
3031
}
32+
#endif
3133

3234
int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope)
3335
{
@@ -56,6 +58,7 @@ int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int
5658
return 0;
5759
}
5860

61+
#ifdef __wasilibc_unmodified_upstream /* Forward declaration of WASI's `__clockid` type. */
5962
int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
6063
{
6164
#ifdef __wasilibc_unmodified_upstream
@@ -65,6 +68,7 @@ int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *r
6568
#endif
6669
return 0;
6770
}
71+
#endif
6872

6973
int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
7074
{

0 commit comments

Comments
 (0)