• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "pthread_impl.h"
2 
pthread_attr_getdetachstate(const pthread_attr_t * a,int * state)3 int pthread_attr_getdetachstate(const pthread_attr_t *a, int *state)
4 {
5 	*state = a->_a_detach;
6 	return 0;
7 }
pthread_attr_getguardsize(const pthread_attr_t * restrict a,size_t * restrict size)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 
pthread_attr_getinheritsched(const pthread_attr_t * restrict a,int * restrict inherit)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 
pthread_attr_getschedparam(const pthread_attr_t * restrict a,struct sched_param * restrict param)20 int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param)
21 {
22 	param->sched_priority = a->_a_prio;
23 	return 0;
24 }
25 
pthread_attr_getschedpolicy(const pthread_attr_t * restrict a,int * restrict policy)26 int pthread_attr_getschedpolicy(const pthread_attr_t *restrict a, int *restrict policy)
27 {
28 	*policy = a->_a_policy;
29 	return 0;
30 }
31 
pthread_attr_getscope(const pthread_attr_t * restrict a,int * restrict scope)32 int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope)
33 {
34 	*scope = PTHREAD_SCOPE_SYSTEM;
35 	return 0;
36 }
37 
pthread_attr_getstack(const pthread_attr_t * restrict a,void ** restrict addr,size_t * restrict size)38 int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size)
39 {
40 	if (!a->_a_stackaddr)
41 		return EINVAL;
42 	*size = a->_a_stacksize;
43 	*addr = (void *)(a->_a_stackaddr - *size);
44 	return 0;
45 }
46 
pthread_attr_getstacksize(const pthread_attr_t * restrict a,size_t * restrict size)47 int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size)
48 {
49 	*size = a->_a_stacksize;
50 	return 0;
51 }
52 
pthread_barrierattr_getpshared(const pthread_barrierattr_t * restrict a,int * restrict pshared)53 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared)
54 {
55 	*pshared = !!a->__attr;
56 	return 0;
57 }
58 
pthread_condattr_getclock(const pthread_condattr_t * restrict a,clockid_t * restrict clk)59 int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
60 {
61 	*clk = a->__attr & 0x7fffffff;
62 	return 0;
63 }
64 
pthread_condattr_getpshared(const pthread_condattr_t * restrict a,int * restrict pshared)65 int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
66 {
67 	*pshared = a->__attr>>31;
68 	return 0;
69 }
70 
pthread_mutexattr_getprotocol(const pthread_mutexattr_t * restrict a,int * restrict protocol)71 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *restrict protocol)
72 {
73 	*protocol = a->__attr / 8U % 2;
74 	return 0;
75 }
pthread_mutexattr_getpshared(const pthread_mutexattr_t * restrict a,int * restrict pshared)76 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared)
77 {
78 	*pshared = a->__attr / 128U % 2;
79 	return 0;
80 }
81 
pthread_mutexattr_getrobust(const pthread_mutexattr_t * restrict a,int * restrict robust)82 int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
83 {
84 	*robust = a->__attr / 4U % 2;
85 	return 0;
86 }
87 
pthread_mutexattr_gettype(const pthread_mutexattr_t * restrict a,int * restrict type)88 int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
89 {
90 	*type = a->__attr & 3;
91 	return 0;
92 }
93 
pthread_rwlockattr_getpshared(const pthread_rwlockattr_t * restrict a,int * restrict pshared)94 int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
95 {
96 	*pshared = a->__attr[0];
97 	return 0;
98 }
99