From a032a6587011cbdac8c2f7e11f15dc4e592bbb55 Mon Sep 17 00:00:00 2001 From: Austin Foxley Date: Tue, 16 Feb 2010 12:27:18 -0800 Subject: mass sync with glibc nptl Signed-off-by: Austin Foxley --- libpthread/nptl/pthread_getattr_np.c | 88 ++++++++++++++++++++---------------- 1 file changed, 48 insertions(+), 40 deletions(-) (limited to 'libpthread/nptl/pthread_getattr_np.c') diff --git a/libpthread/nptl/pthread_getattr_np.c b/libpthread/nptl/pthread_getattr_np.c index 00b9ba357..e0e6251c2 100644 --- a/libpthread/nptl/pthread_getattr_np.c +++ b/libpthread/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. @@ -39,7 +39,7 @@ pthread_getattr_np ( struct pthread_attr *iattr = (struct pthread_attr *) attr; int ret = 0; - lll_lock (thread->lock); + lll_lock (thread->lock, LLL_PRIVATE); /* The thread library is responsible for keeping the values in the thread desriptor up-to-date in case the user changes them. */ @@ -79,51 +79,55 @@ pthread_getattr_np ( 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); } } @@ -160,12 +164,16 @@ pthread_getattr_np ( { 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; + } } } - lll_unlock (thread->lock); + lll_unlock (thread->lock, LLL_PRIVATE); return ret; } -- cgit v1.2.3