aboutsummaryrefslogtreecommitdiff
path: root/nptl/pthread_getattr_np.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
committerJakub Jelinek <jakub@redhat.com>2007-07-12 18:26:36 +0000
commit0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (patch)
tree2ea1f8305970753e4a657acb2ccc15ca3eec8e2c /nptl/pthread_getattr_np.c
parent7d58530341304d403a6626d7f7a1913165fe2f32 (diff)
downloadglibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.zip
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.gz
glibc-0ecb606cb6cf65de1d9fc8a919bceb4be476c602.tar.bz2
2.5-18.1
Diffstat (limited to 'nptl/pthread_getattr_np.c')
-rw-r--r--nptl/pthread_getattr_np.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c
index ba720af..f6cd889 100644
--- a/nptl/pthread_getattr_np.c
+++ b/nptl/pthread_getattr_np.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -83,51 +83,55 @@ pthread_getattr_np (thread_id, attr)
if (fp == NULL)
ret = errno;
/* We need the limit of the stack in any case. */
- else if (getrlimit (RLIMIT_STACK, &rl) != 0)
- ret = errno;
else
{
- /* We need no locking. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
+ if (getrlimit (RLIMIT_STACK, &rl) != 0)
+ ret = errno;
+ else
+ {
+ /* We need no locking. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
- /* Until we found an entry (which should always be the case)
- mark the result as a failure. */
- ret = ENOENT;
+ /* Until we found an entry (which should always be the case)
+ mark the result as a failure. */
+ ret = ENOENT;
- char *line = NULL;
- size_t linelen = 0;
- uintptr_t last_to = 0;
+ char *line = NULL;
+ size_t linelen = 0;
+ uintptr_t last_to = 0;
- while (! feof_unlocked (fp))
- {
- if (__getdelim (&line, &linelen, '\n', fp) <= 0)
- break;
-
- uintptr_t from;
- uintptr_t to;
- if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
- continue;
- if (from <= (uintptr_t) __libc_stack_end
- && (uintptr_t) __libc_stack_end < to)
+ while (! feof_unlocked (fp))
{
- /* Found the entry. Now we have the info we need. */
- iattr->stacksize = rl.rlim_cur;
- iattr->stackaddr = (void *) to;
-
- /* 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;
-
- /* We succeed and no need to look further. */
- ret = 0;
- break;
+ if (__getdelim (&line, &linelen, '\n', fp) <= 0)
+ break;
+
+ uintptr_t from;
+ uintptr_t to;
+ if (sscanf (line, "%" SCNxPTR "-%" SCNxPTR, &from, &to) != 2)
+ continue;
+ if (from <= (uintptr_t) __libc_stack_end
+ && (uintptr_t) __libc_stack_end < to)
+ {
+ /* Found the entry. Now we have the info we need. */
+ iattr->stacksize = rl.rlim_cur;
+ iattr->stackaddr = (void *) to;
+
+ /* 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;
+
+ /* We succeed and no need to look further. */
+ ret = 0;
+ break;
+ }
+ last_to = to;
}
- last_to = to;
+
+ free (line);
}
fclose (fp);
- free (line);
}
}
@@ -164,8 +168,12 @@ pthread_getattr_np (thread_id, attr)
{
free (cpuset);
if (ret == ENOSYS)
- /* There is no such functionality. */
- ret = 0;
+ {
+ /* There is no such functionality. */
+ ret = 0;
+ iattr->cpuset = NULL;
+ iattr->cpusetsize = 0;
+ }
}
}