summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_stack.c
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-05-13 07:58:15 +0000
committeralfred <alfred@FreeBSD.org>2002-05-13 07:58:15 +0000
commit135bb8bda20243a1d25ec3f1957340e0ad3adb78 (patch)
tree560dda98ad29714a8b86e7627eb2c047ba236df3 /lib/libpthread/thread/thr_stack.c
parent796d01e2a84d0cd774be8511d13ebf2076c43f66 (diff)
downloadFreeBSD-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_stack.c')
-rw-r--r--lib/libpthread/thread/thr_stack.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/libpthread/thread/thr_stack.c b/lib/libpthread/thread/thr_stack.c
index 86f0a2d..1913b09 100644
--- a/lib/libpthread/thread/thr_stack.c
+++ b/lib/libpthread/thread/thr_stack.c
@@ -122,13 +122,13 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
size_t stack_size;
/*
- * Round up stack size to nearest multiple of PAGE_SIZE, so that mmap()
+ * Round up stack size to nearest multiple of pthread_page_size, so that mmap()
* will work. If the stack size is not an even multiple, we end up
* initializing things such that there is unused space above the
* beginning of the stack, so the stack sits snugly against its guard.
*/
- if (stacksize % PAGE_SIZE != 0)
- stack_size = ((stacksize / PAGE_SIZE) + 1) * PAGE_SIZE;
+ if (stacksize % pthread_page_size != 0)
+ stack_size = ((stacksize / pthread_page_size) + 1) * pthread_page_size;
else
stack_size = stacksize;
@@ -137,7 +137,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
* from the default-size stack cache:
*/
if (stack_size == PTHREAD_STACK_DEFAULT &&
- guardsize == PTHREAD_GUARD_DEFAULT) {
+ guardsize == pthread_guard_default) {
/*
* Use the garbage collector mutex for synchronization of the
* spare stack list.
@@ -187,7 +187,7 @@ _thread_stack_alloc(size_t stacksize, size_t guardsize)
if (last_stack == NULL)
last_stack = _usrstack - PTHREAD_STACK_INITIAL -
- PTHREAD_GUARD_DEFAULT;
+ pthread_guard_default;
/* Allocate a new stack. */
stack = last_stack - stack_size;
@@ -217,17 +217,17 @@ _thread_stack_free(void *stack, size_t stacksize, size_t guardsize)
struct stack *spare_stack;
spare_stack = (stack + stacksize - sizeof(struct stack));
- /* Round stacksize up to nearest multiple of PAGE_SIZE. */
- if (stacksize % PAGE_SIZE != 0) {
- spare_stack->stacksize = ((stacksize / PAGE_SIZE) + 1) *
- PAGE_SIZE;
+ /* Round stacksize up to nearest multiple of pthread_page_size. */
+ if (stacksize % pthread_page_size != 0) {
+ spare_stack->stacksize = ((stacksize / pthread_page_size) + 1) *
+ pthread_page_size;
} else
spare_stack->stacksize = stacksize;
spare_stack->guardsize = guardsize;
spare_stack->stackaddr = stack;
if (spare_stack->stacksize == PTHREAD_STACK_DEFAULT &&
- spare_stack->guardsize == PTHREAD_GUARD_DEFAULT) {
+ spare_stack->guardsize == pthread_guard_default) {
/* Default stack/guard size. */
LIST_INSERT_HEAD(&_dstackq, spare_stack, qe);
} else {
OpenPOWER on IntegriCloud