]>
Commit | Line | Data |
---|---|---|
320054e8 DG |
1 | #include "pthread_impl.h" |
2 | ||
3 | int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state) | |
4 | { | |
5 | *state = a->_a_detach; | |
6 | return 0; | |
7 | } | |
8 | int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) | |
9 | { | |
10 | *size = a->_a_guardsize; | |
11 | return 0; | |
12 | } | |
13 | ||
14 | int pthread_attr_getinheritsched(const pthread_attr_t *restrict a, int *restrict inherit) | |
15 | { | |
16 | *inherit = a->_a_sched; | |
17 | return 0; | |
18 | } | |
19 | ||
627654f0 | 20 | #ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */ |
320054e8 DG |
21 | int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param) |
22 | { | |
23 | param->sched_priority = a->_a_prio; | |
24 | return 0; | |
25 | } | |
26 | ||
27 | int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict policy) | |
28 | { | |
29 | *policy = a->_a_policy; | |
30 | return 0; | |
31 | } | |
627654f0 | 32 | #endif |
320054e8 DG |
33 | |
34 | int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope) | |
35 | { | |
36 | *scope = PTHREAD_SCOPE_SYSTEM; | |
37 | return 0; | |
38 | } | |
39 | ||
40 | int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size) | |
41 | { | |
42 | if (!a->_a_stackaddr) | |
43 | return EINVAL; | |
44 | *size = a->_a_stacksize; | |
45 | *addr = (void *)(a->_a_stackaddr - *size); | |
46 | return 0; | |
47 | } | |
48 | ||
49 | int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size) | |
50 | { | |
51 | *size = a->_a_stacksize; | |
52 | return 0; | |
53 | } | |
54 | ||
55 | int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared) | |
56 | { | |
57 | *pshared = !!a->__attr; | |
58 | return 0; | |
59 | } | |
60 | ||
627654f0 | 61 | #ifdef __wasilibc_unmodified_upstream /* Forward declaration of WASI's `__clockid` type. */ |
320054e8 DG |
62 | int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) |
63 | { | |
64 | *clk = a->__attr & 0x7fffffff; | |
65 | return 0; | |
66 | } | |
627654f0 | 67 | #endif |
320054e8 DG |
68 | |
69 | int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared) | |
70 | { | |
71 | *pshared = a->__attr>>31; | |
72 | return 0; | |
73 | } | |
74 | ||
75 | int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol) | |
76 | { | |
322bd4ff | 77 | *protocol = a->__attr / 8U % 2; |
320054e8 DG |
78 | return 0; |
79 | } | |
80 | int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) | |
81 | { | |
82 | *pshared = a->__attr / 128U % 2; | |
83 | return 0; | |
84 | } | |
85 | ||
86 | int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust) | |
87 | { | |
88 | *robust = a->__attr / 4U % 2; | |
89 | return 0; | |
90 | } | |
91 | ||
92 | int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type) | |
93 | { | |
94 | *type = a->__attr & 3; | |
95 | return 0; | |
96 | } | |
97 | ||
98 | int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared) | |
99 | { | |
100 | *pshared = a->__attr[0]; | |
101 | return 0; | |
102 | } |