aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2003-12-23 23:07:09 +0000
committerRoland McGrath <roland@gnu.org>2003-12-23 23:07:09 +0000
commitd9cabb2f8060f2fb41abff2ea745534a3ad2bf97 (patch)
treefaac1b1f9f0c881b24ac0ce73b8a34609aade930 /nptl
parent8cae99dba5e26eb9fdd118e1bc9abba00d7f8b5b (diff)
downloadglibc-d9cabb2f8060f2fb41abff2ea745534a3ad2bf97.tar
glibc-d9cabb2f8060f2fb41abff2ea745534a3ad2bf97.tar.gz
glibc-d9cabb2f8060f2fb41abff2ea745534a3ad2bf97.tar.bz2
glibc-d9cabb2f8060f2fb41abff2ea745534a3ad2bf97.zip
2003-12-23 Roland McGrath <roland@redhat.com>
* init.c (__pthread_initialize_minimal_internal): Round stack rlimit value up to page size for __default_stacksize.
Diffstat (limited to 'nptl')
-rw-r--r--nptl/init.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/nptl/init.c b/nptl/init.c
index b38b9be550..1f11edb26f 100644
--- a/nptl/init.c
+++ b/nptl/init.c
@@ -255,12 +255,17 @@ __pthread_initialize_minimal_internal (void)
|| limit.rlim_cur == RLIM_INFINITY)
/* The system limit is not usable. Use an architecture-specific
default. */
- limit.rlim_cur = ARCH_STACK_DEFAULT_SIZE;
-
- __default_stacksize = MAX (limit.rlim_cur, PTHREAD_STACK_MIN);
- /* The maximum page size better should be a multiple of the page
- size. */
- assert (__default_stacksize % __sysconf (_SC_PAGESIZE) == 0);
+ __default_stacksize = ARCH_STACK_DEFAULT_SIZE;
+ else if (limit.rlim_cur < PTHREAD_STACK_MIN)
+ /* The system limit is unusably small.
+ Use the minimal size acceptable. */
+ __default_stacksize = PTHREAD_STACK_MIN;
+ else
+ {
+ /* Round the resource limit up to page size. */
+ const uintptr_t pagesz = __sysconf (_SC_PAGESIZE);
+ __default_stacksize = (limit.rlim_cur + pagesz - 1) & -pagesz;
+ }
/* Get the size of the static and alignment requirements for the TLS
block. */