am 9a74e36f
: Use kernel default for initial thread size
* commit '9a74e36f4810ca22cb12f8eafe4f929edfa57e58': Use kernel default for initial thread size
This commit is contained in:
commit
0890436da9
@ -37,6 +37,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/auxv.h>
|
#include <sys/auxv.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "atexit.h"
|
#include "atexit.h"
|
||||||
@ -62,6 +64,21 @@ uintptr_t __stack_chk_guard = 0;
|
|||||||
unsigned int __page_size = PAGE_SIZE;
|
unsigned int __page_size = PAGE_SIZE;
|
||||||
unsigned int __page_shift = PAGE_SHIFT;
|
unsigned int __page_shift = PAGE_SHIFT;
|
||||||
|
|
||||||
|
static size_t get_stack_size() {
|
||||||
|
const size_t minimal_stack_size = 128 * 1024;
|
||||||
|
size_t stack_size = minimal_stack_size;
|
||||||
|
struct rlimit stack_limit;
|
||||||
|
int rlimit_result = getrlimit(RLIMIT_STACK, &stack_limit);
|
||||||
|
if ((rlimit_result == 0) && (stack_limit.rlim_cur != RLIM_INFINITY)) {
|
||||||
|
stack_size = stack_limit.rlim_cur;
|
||||||
|
stack_size = (stack_size & ~(PAGE_SIZE - 1));
|
||||||
|
if (stack_size < minimal_stack_size) {
|
||||||
|
stack_size = minimal_stack_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stack_size;
|
||||||
|
}
|
||||||
|
|
||||||
/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped
|
/* Init TLS for the initial thread. Called by the linker _before_ libc is mapped
|
||||||
* in memory. Beware: all writes to libc globals from this function will
|
* in memory. Beware: all writes to libc globals from this function will
|
||||||
* apply to linker-private copies and will not be visible from libc later on.
|
* apply to linker-private copies and will not be visible from libc later on.
|
||||||
@ -76,9 +93,9 @@ unsigned int __page_shift = PAGE_SHIFT;
|
|||||||
void __libc_init_tls(KernelArgumentBlock& args) {
|
void __libc_init_tls(KernelArgumentBlock& args) {
|
||||||
__libc_auxv = args.auxv;
|
__libc_auxv = args.auxv;
|
||||||
|
|
||||||
unsigned stack_top = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE;
|
uintptr_t stack_top = (__get_sp() & ~(PAGE_SIZE - 1)) + PAGE_SIZE;
|
||||||
unsigned stack_size = 128 * 1024;
|
size_t stack_size = get_stack_size();
|
||||||
unsigned stack_bottom = stack_top - stack_size;
|
uintptr_t stack_bottom = stack_top - stack_size;
|
||||||
|
|
||||||
static void* tls[BIONIC_TLS_SLOTS];
|
static void* tls[BIONIC_TLS_SLOTS];
|
||||||
static pthread_internal_t thread;
|
static pthread_internal_t thread;
|
||||||
|
Loading…
Reference in New Issue
Block a user