diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-08-05 06:15:04 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-08-05 06:15:04 +0000 |
commit | 234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a (patch) | |
tree | 7b78bb63ef3d2c1ebfc89b59759068f2e394df5c /linuxthreads/attr.c | |
parent | 0a8d92310f5c5e0c09c8ff9a79ac652a66d5b3da (diff) | |
download | glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.zip glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.tar.gz glibc-234dd7a6ba1a9783f43d500f8ee745b2f5b4db5a.tar.bz2 |
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.
Diffstat (limited to 'linuxthreads/attr.c')
-rw-r--r-- | linuxthreads/attr.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 <string.h> #include <unistd.h> #include <sys/param.h> +#include <sys/resource.h> #include "pthread.h" #include "internals.h" #include <shlib-compat.h> @@ -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; |