about summary refs log tree commit diff
path: root/nptl/pthread_attr_getstack.c
diff options
context:
space:
mode:
authorCarlos O'Donell <carlos@redhat.com>2014-03-05 00:11:01 -0500
committerMike Frysinger <vapier@gentoo.org>2014-03-13 20:38:27 -0400
commit2e03fae7b711b87733f8c897cb42ea74d2dc156a (patch)
treeca1bc47286ee3ce91a2805c72f554bf9f338fc7e /nptl/pthread_attr_getstack.c
parent43ca83ecc482f34e002d5f0accfb4a7cef471e4a (diff)
downloadglibc-2e03fae7b711b87733f8c897cb42ea74d2dc156a.tar.gz
glibc-2e03fae7b711b87733f8c897cb42ea74d2dc156a.tar.xz
glibc-2e03fae7b711b87733f8c897cb42ea74d2dc156a.zip
hppa: Add _STACK_GROWS_* cases to pthread_attr_[sg]etstack.
This is one of a several NPTL patches to build glibc on hppa.

The pthread_attr_[sg]etstack functions are defined by POSIX as
taking a stackaddr that is the lowest addressable byte of the
storage used for the stack. However, the internal iattr variable
of the same name in NPTL is actually the final stack address
as usable in the stack pointer for the machine. Therefore the
NPTL implementation must add and subtract stacksize for
_STACK_GROWS_DOWN architectures. HPPA is a _STACK_GROWS_UP
architecture and doesn't need to add or subtract anything,
the stack address *is* the lowest addressable byte of the
storage.

Tested on hppa-linux-gnu, with no regressions.

Can't impact any other targets because of the conditionals.

If nobody objects I'll check this in at the end of the week.

I can't see there being any objections to this patch except
that it introduces more code to maintain for an old architecture
(perhaps we'll get another _S_G_U target in the future?).
Diffstat (limited to 'nptl/pthread_attr_getstack.c')
-rw-r--r--nptl/pthread_attr_getstack.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/nptl/pthread_attr_getstack.c b/nptl/pthread_attr_getstack.c
index 3f4fd8d40a..0e245a090a 100644
--- a/nptl/pthread_attr_getstack.c
+++ b/nptl/pthread_attr_getstack.c
@@ -32,7 +32,11 @@ __pthread_attr_getstack (attr, stackaddr, stacksize)
   iattr = (struct pthread_attr *) attr;
 
   /* Store the result.  */
+#if _STACK_GROWS_DOWN
   *stackaddr = (char *) iattr->stackaddr - iattr->stacksize;
+#else
+  *stackaddr = (char *) iattr->stackaddr;
+#endif
   *stacksize = iattr->stacksize;
 
   return 0;