make linking of thread-start with explicit scheduling conditional
[musl] / src / thread / pthread_setattr_default_np.c
1 #include "pthread_impl.h"
2 #include <string.h>
3
4 extern size_t __default_stacksize;
5 extern size_t __default_guardsize;
6
7 int pthread_setattr_default_np(const pthread_attr_t *attrp)
8 {
9         /* Reject anything in the attr object other than stack/guard size. */
10         pthread_attr_t tmp = *attrp, zero = { 0 };
11         tmp._a_stacksize = 0;
12         tmp._a_guardsize = 0;
13         if (memcmp(&tmp, &zero, sizeof tmp))
14                 return EINVAL;
15
16         __inhibit_ptc();
17         if (attrp->_a_stacksize >= __default_stacksize)
18                 __default_stacksize = attrp->_a_stacksize;
19         if (attrp->_a_guardsize >= __default_guardsize)
20                 __default_guardsize = attrp->_a_guardsize;
21         __release_ptc();
22
23         return 0;
24 }
25
26 int pthread_getattr_default_np(pthread_attr_t *attrp)
27 {
28         __acquire_ptc();
29         *attrp = (pthread_attr_t) {
30                 ._a_stacksize = __default_stacksize,
31                 ._a_guardsize = __default_guardsize,
32         };
33         __release_ptc();
34         return 0;
35 }