summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_init.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>1999-12-28 18:12:07 +0000
committerdeischen <deischen@FreeBSD.org>1999-12-28 18:12:07 +0000
commit9321f383a24bce8e6555df4e36441e9bfcff4a27 (patch)
treee0b9cc982b20ee21e845e703f20fa492e2abb29c /lib/libpthread/thread/thr_init.c
parent2a6c7913a06dc521fa0fdb7e0fcc2a1ccd24800e (diff)
downloadFreeBSD-src-9321f383a24bce8e6555df4e36441e9bfcff4a27.zip
FreeBSD-src-9321f383a24bce8e6555df4e36441e9bfcff4a27.tar.gz
Change stack allocation algorithm to make better use of memory
(it was leaving an unused block). Also protect the global stack pointer from context changes while fiddling with it.
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r--lib/libpthread/thread/thr_init.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c
index bab7e5b..c888697 100644
--- a/lib/libpthread/thread/thr_init.c
+++ b/lib/libpthread/thread/thr_init.c
@@ -187,13 +187,11 @@ _thread_init(void)
SLIST_INIT(&_stackq);
/* Create the red zone for the main stack. */
- if (mmap((void *) USRSTACK
- - PTHREAD_STACK_INITIAL,
- PTHREAD_STACK_GUARD, 0, MAP_ANON,
- -1, 0) == MAP_FAILED) {
+ if (mmap((void *) USRSTACK - PTHREAD_STACK_INITIAL -
+ PTHREAD_STACK_GUARD, PTHREAD_STACK_GUARD, 0, MAP_ANON,
+ -1, 0) == MAP_FAILED)
PANIC("Cannot allocate red zone for initial thread");
- }
-
+
/*
* Write a magic value to the thread structure
* to help identify valid ones:
@@ -248,7 +246,7 @@ _thread_init(void)
/* Get the signal handler details: */
else if (_thread_sys_sigaction(i, NULL,
- &_thread_sigact[i - 1]) != 0) {
+ &_thread_sigact[i - 1]) != 0) {
/*
* Abort this process if signal
* initialisation fails:
OpenPOWER on IntegriCloud