fix omission of non-stub pthread_mutexattr_getprotocol
[musl.git] / src / thread / pthread_attr_get.c
blobf12ff442548dd65e85410a2606bb2904f511b256
1 #include "pthread_impl.h"
3 int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state)
5 *state = a->_a_detach;
6 return 0;
8 int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size)
10 *size = a->_a_guardsize;
11 return 0;
14 int pthread_attr_getinheritsched(const pthread_attr_t *restrict a, int *restrict inherit)
16 *inherit = a->_a_sched;
17 return 0;
20 int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param)
22 param->sched_priority = a->_a_prio;
23 return 0;
26 int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict policy)
28 *policy = a->_a_policy;
29 return 0;
32 int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope)
34 *scope = PTHREAD_SCOPE_SYSTEM;
35 return 0;
38 int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size)
40 if (!a->_a_stackaddr)
41 return EINVAL;
42 *size = a->_a_stacksize;
43 *addr = (void *)(a->_a_stackaddr - *size);
44 return 0;
47 int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size)
49 *size = a->_a_stacksize;
50 return 0;
53 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared)
55 *pshared = !!a->__attr;
56 return 0;
59 int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
61 *clk = a->__attr & 0x7fffffff;
62 return 0;
65 int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
67 *pshared = a->__attr>>31;
68 return 0;
71 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol)
73 *protocol = a->__attr / 8U % 2;
74 return 0;
76 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared)
78 *pshared = a->__attr / 128U % 2;
79 return 0;
82 int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
84 *robust = a->__attr / 4U % 2;
85 return 0;
88 int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
90 *type = a->__attr & 3;
91 return 0;
94 int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
96 *pshared = a->__attr[0];
97 return 0;