summaryrefslogtreecommitdiff
path: root/nptl/pthread_getattr_np.c
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r--nptl/pthread_getattr_np.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index dfacd887c9..9cc948f4c6 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -114,6 +114,11 @@ pthread_getattr_np (thread_id, attr)
iattr->stacksize = rl.rlim_cur;
iattr->stackaddr = (void *) to;
+ /* The limit might be too high. This is a bogus
+ situation but try to avoid making it worse. */
+ if ((size_t) iattr->stacksize > (size_t) iattr->stackaddr)
+ iattr->stacksize = (size_t) iattr->stackaddr;
+
/* We succeed and no need to look further. */
ret = 0;
break;
@@ -127,6 +132,23 @@ pthread_getattr_np (thread_id, attr)
iattr->flags |= ATTR_FLAG_STACKADDR;
+ if (ret == 0)
+ {
+ iattr->cpuset = (cpu_set_t *) malloc (sizeof (cpu_set_t));
+ if (iattr->cpuset == NULL)
+ ret = ENOMEM;
+ else
+ {
+ ret = pthread_getaffinity_np (thread_id, iattr->cpuset);
+ if (ret == ENOSYS)
+ {
+ free (iattr->cpuset);
+ iattr->cpuset = NULL;
+ ret = 0;
+ }
+ }
+ }
+
lll_unlock (thread->lock);
pthread_cleanup_pop (0);