mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
Update.
2001-07-19 Jakub Jelinek <jakub@redhat.com> * sysdeps/i386/useldt.h: Fix typo in ARCH_STACK_MAX_SIZE comment. * sysdeps/ia64/pt-machine.h (FLOATING_STACKS): Define. (ARCH_STACK_MAX_SIZE): Define. * manager.c (pthread_allocate_stack): Handle FLOATING_STACKS with NEED_SEPARATE_REGISTER_STACK.
This commit is contained in:
@ -1,3 +1,12 @@
|
||||
2001-07-19 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* sysdeps/i386/useldt.h: Fix typo in ARCH_STACK_MAX_SIZE comment.
|
||||
|
||||
* sysdeps/ia64/pt-machine.h (FLOATING_STACKS): Define.
|
||||
(ARCH_STACK_MAX_SIZE): Define.
|
||||
* manager.c (pthread_allocate_stack): Handle FLOATING_STACKS with
|
||||
NEED_SEPARATE_REGISTER_STACK.
|
||||
|
||||
2001-07-16 Andreas Schwab <schwab@suse.de>
|
||||
|
||||
* Makefile (before-compile): Don't add $(objpfx)crti.o.
|
||||
|
@ -353,63 +353,6 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
|
||||
void *map_addr;
|
||||
|
||||
/* Allocate space for stack and thread descriptor at default address */
|
||||
#ifdef NEED_SEPARATE_REGISTER_STACK
|
||||
void *res_addr;
|
||||
|
||||
if (attr != NULL)
|
||||
{
|
||||
guardsize = page_roundup (attr->__guardsize, granularity);
|
||||
stacksize = STACK_SIZE - guardsize;
|
||||
stacksize = MIN (stacksize,
|
||||
page_roundup (attr->__stacksize, granularity));
|
||||
}
|
||||
else
|
||||
{
|
||||
guardsize = granularity;
|
||||
stacksize = STACK_SIZE - granularity;
|
||||
}
|
||||
|
||||
new_thread = default_new_thread;
|
||||
new_thread_bottom = (char *) (new_thread + 1) - stacksize - guardsize;
|
||||
/* Includes guard area, unlike the normal case. Use the bottom
|
||||
end of the segment as backing store for the register stack.
|
||||
Needed on IA64. In this case, we also map the entire stack at
|
||||
once. According to David Mosberger, that's cheaper. It also
|
||||
avoids the risk of intermittent failures due to other mappings
|
||||
in the same region. The cost is that we might be able to map
|
||||
slightly fewer stacks. */
|
||||
|
||||
/* XXX Fix for floating stacks with variable sizes. */
|
||||
|
||||
/* First the main stack: */
|
||||
map_addr = (caddr_t)((char *)(new_thread + 1) - stacksize / 2);
|
||||
res_addr = mmap(map_addr, stacksize / 2,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (res_addr != map_addr)
|
||||
{
|
||||
/* Bad luck, this segment is already mapped. */
|
||||
if (res_addr != MAP_FAILED)
|
||||
munmap(res_addr, stacksize / 2);
|
||||
return -1;
|
||||
}
|
||||
/* Then the register stack: */
|
||||
map_addr = (caddr_t)new_thread_bottom;
|
||||
res_addr = mmap(map_addr, stacksize/2,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (res_addr != map_addr)
|
||||
{
|
||||
if (res_addr != MAP_FAILED)
|
||||
munmap(res_addr, stacksize / 2);
|
||||
munmap((caddr_t)((char *)(new_thread + 1) - stacksize/2),
|
||||
stacksize/2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
guardaddr = new_thread_bottom + stacksize/2;
|
||||
/* We leave the guard area in the middle unmapped. */
|
||||
#else /* !NEED_SEPARATE_REGISTER_STACK */
|
||||
#if FLOATING_STACKS
|
||||
if (attr != NULL)
|
||||
{
|
||||
@ -431,7 +374,15 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
|
||||
/* No more memory available. */
|
||||
return -1;
|
||||
|
||||
# ifdef _STACK_GROWS_DOWN
|
||||
# ifdef NEED_SEPARATE_REGISTER_STACK
|
||||
guardaddr = map_addr + stacksize / 2;
|
||||
if (guardsize > 0)
|
||||
mprotect (guardaddr, guardsize, PROT_NONE);
|
||||
|
||||
new_thread_bottom = (char *) map_addr;
|
||||
new_thread = ((pthread_descr) (new_thread_bottom + stacksize
|
||||
+ guardsize)) - 1;
|
||||
# elif _STACK_GROWS_DOWN
|
||||
guardaddr = map_addr;
|
||||
if (guardsize > 0)
|
||||
mprotect (guardaddr, guardsize, PROT_NONE);
|
||||
@ -464,6 +415,46 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
|
||||
stacksize = STACK_SIZE - granularity;
|
||||
}
|
||||
|
||||
# ifdef NEED_SEPARATE_REGISTER_STACK
|
||||
new_thread = default_new_thread;
|
||||
new_thread_bottom = (char *) (new_thread + 1) - stacksize - guardsize;
|
||||
/* Includes guard area, unlike the normal case. Use the bottom
|
||||
end of the segment as backing store for the register stack.
|
||||
Needed on IA64. In this case, we also map the entire stack at
|
||||
once. According to David Mosberger, that's cheaper. It also
|
||||
avoids the risk of intermittent failures due to other mappings
|
||||
in the same region. The cost is that we might be able to map
|
||||
slightly fewer stacks. */
|
||||
|
||||
/* First the main stack: */
|
||||
map_addr = (caddr_t)((char *)(new_thread + 1) - stacksize / 2);
|
||||
res_addr = mmap(map_addr, stacksize / 2,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (res_addr != map_addr)
|
||||
{
|
||||
/* Bad luck, this segment is already mapped. */
|
||||
if (res_addr != MAP_FAILED)
|
||||
munmap(res_addr, stacksize / 2);
|
||||
return -1;
|
||||
}
|
||||
/* Then the register stack: */
|
||||
map_addr = (caddr_t)new_thread_bottom;
|
||||
res_addr = mmap(map_addr, stacksize/2,
|
||||
PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
if (res_addr != map_addr)
|
||||
{
|
||||
if (res_addr != MAP_FAILED)
|
||||
munmap(res_addr, stacksize / 2);
|
||||
munmap((caddr_t)((char *)(new_thread + 1) - stacksize/2),
|
||||
stacksize/2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
guardaddr = new_thread_bottom + stacksize/2;
|
||||
/* We leave the guard area in the middle unmapped. */
|
||||
# else /* !NEED_SEPARATE_REGISTER_STACK */
|
||||
# ifdef _STACK_GROWS_DOWN
|
||||
new_thread = default_new_thread;
|
||||
new_thread_bottom = (char *) (new_thread + 1) - stacksize;
|
||||
@ -501,8 +492,8 @@ static int pthread_allocate_stack(const pthread_attr_t *attr,
|
||||
mprotect (guardaddr, guardsize, PROT_NONE);
|
||||
|
||||
# endif /* stack direction */
|
||||
# endif
|
||||
# endif /* !NEED_SEPARATE_REGISTER_STACK */
|
||||
#endif /* !FLOATING_STACKS */
|
||||
}
|
||||
*out_new_thread = new_thread;
|
||||
*out_new_thread_bottom = new_thread_bottom;
|
||||
|
@ -31,6 +31,12 @@
|
||||
|
||||
#define NEED_SEPARATE_REGISTER_STACK
|
||||
|
||||
/* We want the OS to assign stack addresses. */
|
||||
#define FLOATING_STACKS 1
|
||||
|
||||
/* Maximum size of the stack if the rlimit is unlimited. */
|
||||
#define ARCH_STACK_MAX_SIZE 32*1024*1024
|
||||
|
||||
/* Get some notion of the current stack. Need not be exactly the top
|
||||
of the stack, just something somewhere in the current frame.
|
||||
r12 (sp) is the stack pointer. */
|
||||
|
Reference in New Issue
Block a user