1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00
* 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.
This commit is contained in:
Ulrich Drepper
2000-08-05 06:15:04 +00:00
parent 0a8d92310f
commit 234dd7a6ba
6 changed files with 133 additions and 34 deletions

View File

@@ -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;