sys/stat.h: fix typo in statx member name stx_dio_offset_align
[musl.git] / src / thread / pthread_setattr_default_np.c
blob58486220e026c778988b68398191c7ec177d0f88
1 #define _GNU_SOURCE
2 #include "pthread_impl.h"
3 #include <string.h>
5 #define MIN(a,b) ((a)<(b) ? (a) : (b))
6 #define MAX(a,b) ((a)>(b) ? (a) : (b))
8 int pthread_setattr_default_np(const pthread_attr_t *attrp)
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;
17 unsigned stack = MIN(attrp->_a_stacksize, DEFAULT_STACK_MAX);
18 unsigned guard = MIN(attrp->_a_guardsize, DEFAULT_GUARD_MAX);
20 __inhibit_ptc();
21 __default_stacksize = MAX(__default_stacksize, stack);
22 __default_guardsize = MAX(__default_guardsize, guard);
23 __release_ptc();
25 return 0;
28 int pthread_getattr_default_np(pthread_attr_t *attrp)
30 __acquire_ptc();
31 *attrp = (pthread_attr_t) {
32 ._a_stacksize = __default_stacksize,
33 ._a_guardsize = __default_guardsize,
35 __release_ptc();
36 return 0;