fix use of uninitialized pointer in gettext core
[musl.git] / src / thread / pthread_setattr_default_np.c
blobffd2712b05602445068ec3edb9d9a2b9fc82c6cd
1 #include "pthread_impl.h"
2 #include <string.h>
4 extern size_t __default_stacksize;
5 extern size_t __default_guardsize;
7 int pthread_setattr_default_np(const pthread_attr_t *attrp)
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;
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();
23 return 0;
26 int pthread_getattr_default_np(pthread_attr_t *attrp)
28 __acquire_ptc();
29 *attrp = (pthread_attr_t) {
30 ._a_stacksize = __default_stacksize,
31 ._a_guardsize = __default_guardsize,
33 __release_ptc();
34 return 0;