diff options
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r-- | nptl/pthread_getattr_np.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index e79f282fee..2ec27484c8 100644 --- a/nptl/pthread_getattr_np.c +++ b/nptl/pthread_getattr_np.c @@ -60,7 +60,11 @@ pthread_getattr_np (thread_id, attr) if (__builtin_expect (thread->stackblock != NULL, 1)) { iattr->stacksize = thread->stackblock_size; +#ifdef _STACK_GROWS_DOWN iattr->stackaddr = (char *) thread->stackblock + iattr->stacksize; +#else + iattr->stackaddr = (char *) thread->stackblock; +#endif } else { @@ -129,12 +133,17 @@ pthread_getattr_np (thread_id, attr) stack extension request. */ iattr->stacksize = (iattr->stacksize & -(intptr_t) GLRO(dl_pagesize)); - +#if _STACK_GROWS_DOWN /* The limit might be too high. */ if ((size_t) iattr->stacksize > (size_t) iattr->stackaddr - last_to) iattr->stacksize = (size_t) iattr->stackaddr - last_to; - +#else + /* The limit might be too high. */ + if ((size_t) iattr->stacksize + > to - (size_t) iattr->stackaddr) + iattr->stacksize = to - (size_t) iattr->stackaddr; +#endif /* We succeed and no need to look further. */ ret = 0; break; |