From 0ecb606cb6cf65de1d9fc8a919bceb4be476c602 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 12 Jul 2007 18:26:36 +0000 Subject: 2.5-18.1 --- nptl/pthread_getattr_np.c | 84 ++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 38 deletions(-) (limited to 'nptl/pthread_getattr_np.c') diff --git a/nptl/pthread_getattr_np.c b/nptl/pthread_getattr_np.c index ba720af6cd..f6cd8899d8 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 , 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; + } } } -- cgit 1.4.1