diff options
author | marcus <marcus@FreeBSD.org> | 2005-03-06 07:56:18 +0000 |
---|---|---|
committer | marcus <marcus@FreeBSD.org> | 2005-03-06 07:56:18 +0000 |
commit | a424dc9347b4199bfc24854e05adef230b855449 (patch) | |
tree | bf55900895a5847c1f4598e2931ce955b402e7b7 /lib/libthr/thread/thr_init.c | |
parent | d9a2f9579c8605dc4edb21456e19448dce44f346 (diff) | |
download | FreeBSD-src-a424dc9347b4199bfc24854e05adef230b855449.zip FreeBSD-src-a424dc9347b4199bfc24854e05adef230b855449.tar.gz |
Increase the default stacksizes:
32-bit 64-bit
main thread 2 MB 4 MB
other threads 1 MB 2 MB
Approved by: mtm
Adapted from: libpthread
Diffstat (limited to 'lib/libthr/thread/thr_init.c')
-rw-r--r-- | lib/libthr/thread/thr_init.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c index 3291738..45d238c 100644 --- a/lib/libthr/thread/thr_init.c +++ b/lib/libthr/thread/thr_init.c @@ -154,6 +154,8 @@ static void *libgcc_references[] = { int _pthread_guard_default; int _pthread_page_size; +int _pthread_stack_default; +int _pthread_stack_initial; /* * Initialize the current thread. @@ -252,9 +254,17 @@ _thread_init(void) _pthread_page_size = getpagesize(); _pthread_guard_default = getpagesize(); - - pthread_attr_default.guardsize_attr = _pthread_guard_default; + if (sizeof(void *) == 8) { + _pthread_stack_default = PTHREAD_STACK64_DEFAULT; + _pthread_stack_initial = PTHREAD_STACK64_INITIAL; + } + else { + _pthread_stack_default = PTHREAD_STACK32_DEFAULT; + _pthread_stack_initial = PTHREAD_STACK32_INITIAL; + } + pthread_attr_default.guardsize_attr = _pthread_guard_default; + pthread_attr_default.stacksize_attr = _pthread_stack_default; /* * Make gcc quiescent about {,libgcc_}references not being @@ -317,22 +327,22 @@ _thread_init(void) * this stack needs an explicitly mapped red zone to protect the * thread stack that is just beyond. */ - if (mmap(_usrstack - PTHREAD_STACK_INITIAL - + if (mmap(_usrstack - _pthread_stack_initial - _pthread_guard_default, _pthread_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); /* Set the main thread stack pointer. */ - pthread->stack = _usrstack - PTHREAD_STACK_INITIAL; + pthread->stack = _usrstack - _pthread_stack_initial; /* Set the stack attributes. */ pthread->attr.stackaddr_attr = pthread->stack; - pthread->attr.stacksize_attr = PTHREAD_STACK_INITIAL; + pthread->attr.stacksize_attr = _pthread_stack_initial; /* Setup the context for initial thread. */ getcontext(&pthread->ctx); pthread->ctx.uc_stack.ss_sp = pthread->stack; - pthread->ctx.uc_stack.ss_size = PTHREAD_STACK_INITIAL; + pthread->ctx.uc_stack.ss_size = _pthread_stack_initial; /* Initialize the atfork list and mutex */ TAILQ_INIT(&_atfork_list); |