From 234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 5 Aug 2000 06:15:04 +0000 Subject: Update. * internals.h: Declare __pthread_max_stacksize. * pthread.c (__pthread_max_stacksize): New variable. (__pthread_initialize_manager): Determine __pthread_initialize_manager value. * manager.c (thread_segment): Return always NULL if FLOATING_STACKS. (pthread_allocate_stack): Allow kernel to choose stack address if FLOATING_STACKS. This also handles variable-sized stacks. Always allocate stack and guardoage together. Use mprotect to change guardpage access. * sysdeps/i386/useldt.h: Define FLOATING_STACKS and ARCH_STACK_MAX_SIZE. * attr.c (__pthread_attr_setstacksize): Also test value against upper limit. --- linuxthreads/attr.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'linuxthreads/attr.c') diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c index 966cea1..90ab019 100644 --- a/linuxthreads/attr.c +++ b/linuxthreads/attr.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "pthread.h" #include "internals.h" #include @@ -184,6 +185,30 @@ weak_alias (__pthread_attr_getstackaddr, pthread_attr_getstackaddr) int __pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) { +#ifdef FLOATING_STACKS + /* We have to check against the maximum allowed stack size. This is no + problem if the manager is already started and we determined it. If + this hasn't happened, we have to find the limit outself. */ + if (__pthread_max_stacksize == 0) + { + struct rlimit limit; + + getrlimit(RLIMIT_STACK, &limit); +# ifdef NEED_SEPARATE_REGISTER_STACK + __pthread_max_stacksize = limit.rlim_max / 2; +# else + __pthread_max_stacksize = limit.rlim_max; +# endif + } + + if (stacksize > __pthread_max_stacksize) + return EINVAL; +#else + /* We have a fixed size limit. */ + if (stacksize > STACK_SIZE) + return EINVAL; +#endif + /* We don't accept value smaller than PTHREAD_STACK_MIN. */ if (stacksize < PTHREAD_STACK_MIN) return EINVAL; -- cgit v1.1