diff options
Diffstat (limited to 'src/thread')
-rw-r--r-- | src/thread/default_attr.c | 4 | ||||
-rw-r--r-- | src/thread/pthread_setattr_default_np.c | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/thread/default_attr.c b/src/thread/default_attr.c index 46fe98ee..dce96409 100644 --- a/src/thread/default_attr.c +++ b/src/thread/default_attr.c @@ -1,4 +1,4 @@ #include "pthread_impl.h" -size_t __default_stacksize = DEFAULT_STACK_SIZE; -size_t __default_guardsize = DEFAULT_GUARD_SIZE; +unsigned __default_stacksize = DEFAULT_STACK_SIZE; +unsigned __default_guardsize = DEFAULT_GUARD_SIZE; diff --git a/src/thread/pthread_setattr_default_np.c b/src/thread/pthread_setattr_default_np.c index 256f0685..58486220 100644 --- a/src/thread/pthread_setattr_default_np.c +++ b/src/thread/pthread_setattr_default_np.c @@ -2,6 +2,9 @@ #include "pthread_impl.h" #include <string.h> +#define MIN(a,b) ((a)<(b) ? (a) : (b)) +#define MAX(a,b) ((a)>(b) ? (a) : (b)) + int pthread_setattr_default_np(const pthread_attr_t *attrp) { /* Reject anything in the attr object other than stack/guard size. */ @@ -11,11 +14,12 @@ int pthread_setattr_default_np(const pthread_attr_t *attrp) if (memcmp(&tmp, &zero, sizeof tmp)) return EINVAL; + unsigned stack = MIN(attrp->_a_stacksize, DEFAULT_STACK_MAX); + unsigned guard = MIN(attrp->_a_guardsize, DEFAULT_GUARD_MAX); + __inhibit_ptc(); - if (attrp->_a_stacksize >= __default_stacksize) - __default_stacksize = attrp->_a_stacksize; - if (attrp->_a_guardsize >= __default_guardsize) - __default_guardsize = attrp->_a_guardsize; + __default_stacksize = MAX(__default_stacksize, stack); + __default_guardsize = MAX(__default_guardsize, guard); __release_ptc(); return 0; |