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