Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Fix the stack base pointer for the initial th...



details:   https://anonhg.NetBSD.org/src/rev/cb9abbc3c8f8
branches:  trunk
changeset: 777868:cb9abbc3c8f8
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Mar 08 16:33:45 2012 +0000

description:
Fix the stack base pointer for the initial thread on !HPPA.
AT_STACKBASE is pointing to the start of the stack, which is the
upper limit on platforms where the stack grows down.

diffstat:

 lib/libpthread/pthread.c |  13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r e537fce1a528 -r cb9abbc3c8f8 lib/libpthread/pthread.c
--- a/lib/libpthread/pthread.c  Thu Mar 08 14:58:57 2012 +0000
+++ b/lib/libpthread/pthread.c  Thu Mar 08 16:33:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread.c,v 1.126 2012/03/02 18:06:05 joerg Exp $      */
+/*     $NetBSD: pthread.c,v 1.127 2012/03/08 16:33:45 joerg Exp $      */
 
 /*-
  * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread.c,v 1.126 2012/03/02 18:06:05 joerg Exp $");
+__RCSID("$NetBSD: pthread.c,v 1.127 2012/03/08 16:33:45 joerg Exp $");
 
 #define        __EXPOSE_STACK  1
 
@@ -1202,16 +1202,23 @@
 {
        struct rlimit slimit;
        const AuxInfo *aux;
+       size_t size;
 
        _DIAGASSERT(_dlauxinfo() != NULL);
 
        if (getrlimit(RLIMIT_STACK, &slimit) == -1)
                err(1, "Couldn't get stack resource consumption limits");
-       pthread__main.pt_stack.ss_size = slimit.rlim_cur;
+       size = slimit.rlim_cur;
+       pthread__main.pt_stack.ss_size = size;
 
        for (aux = _dlauxinfo(); aux->a_type != AT_NULL; ++aux) {
                if (aux->a_type == AT_STACKBASE) {
                        pthread__main.pt_stack.ss_sp = (void *)aux->a_v;
+#ifdef __MACHINE_STACK_GROWS_UP
+                       pthread__main.pt_stack.ss_sp = (void *)aux->a_v;
+#else
+                       pthread__main.pt_stack.ss_sp = (char *)aux->a_v - size;
+#endif
                        break;
                }
        }



Home | Main Index | Thread Index | Old Index