diff options
author | alfred <alfred@FreeBSD.org> | 2002-05-13 07:58:15 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-05-13 07:58:15 +0000 |
commit | 135bb8bda20243a1d25ec3f1957340e0ad3adb78 (patch) | |
tree | 560dda98ad29714a8b86e7627eb2c047ba236df3 /lib/libpthread/thread/thr_init.c | |
parent | 796d01e2a84d0cd774be8511d13ebf2076c43f66 (diff) | |
download | FreeBSD-src-135bb8bda20243a1d25ec3f1957340e0ad3adb78.zip FreeBSD-src-135bb8bda20243a1d25ec3f1957340e0ad3adb78.tar.gz |
Don't use PAGE_SIZE in userland, instead use getpagesize(), this is to
allow running on other arches when the instructions are supported but
the page size granularity is not.
Glanced at by: peter
Diffstat (limited to 'lib/libpthread/thread/thr_init.c')
-rw-r--r-- | lib/libpthread/thread/thr_init.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c index a3d62ae..96fa3f7 100644 --- a/lib/libpthread/thread/thr_init.c +++ b/lib/libpthread/thread/thr_init.c @@ -146,6 +146,8 @@ static void *libgcc_references[] = { &_pthread_mutex_unlock }; +int pthread_guard_default; +int pthread_page_size; /* * Threaded process initialization @@ -158,9 +160,18 @@ _thread_init(void) int i; size_t len; int mib[2]; + int sched_stack_size; /* Size of scheduler stack. */ + struct clockinfo clockinfo; struct sigaction act; + pthread_page_size = getpagesize(); + pthread_guard_default = getpagesize(); + sched_stack_size = getpagesize(); + + pthread_attr_default.guardsize_attr = pthread_guard_default; + + /* Check if this function has already been called: */ if (_thread_initial) /* Only initialise the threaded application once. */ @@ -247,7 +258,7 @@ _thread_init(void) PANIC("Cannot allocate memory for initial thread"); } /* Allocate memory for the scheduler stack: */ - else if ((_thread_kern_sched_stack = malloc(SCHED_STACK_SIZE)) == NULL) + else if ((_thread_kern_sched_stack = malloc(sched_stack_size)) == NULL) PANIC("Failed to allocate stack for scheduler"); else { /* Zero the global kernel thread structure: */ @@ -280,7 +291,7 @@ _thread_init(void) * thread stack that is just beyond. */ if (mmap(_usrstack - PTHREAD_STACK_INITIAL - - PTHREAD_GUARD_DEFAULT, PTHREAD_GUARD_DEFAULT, 0, MAP_ANON, + pthread_guard_default, pthread_guard_default, 0, MAP_ANON, -1, 0) == MAP_FAILED) PANIC("Cannot allocate red zone for initial thread"); @@ -294,7 +305,7 @@ _thread_init(void) /* Setup the context for the scheduler: */ _setjmp(_thread_kern_sched_jb); SET_STACK_JB(_thread_kern_sched_jb, _thread_kern_sched_stack + - SCHED_STACK_SIZE - sizeof(double)); + sched_stack_size - sizeof(double)); SET_RETURN_ADDR_JB(_thread_kern_sched_jb, _thread_kern_scheduler); /* |