This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.21-216-g98734cc
- From: fw at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 23 Mar 2015 15:41:41 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.21-216-g98734cc
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via 98734cc50153c80047f4ed9c6772bc7e1e68c9f7 (commit)
from 2b028564f14d20cdda0c00d8ba100695b40501f5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=98734cc50153c80047f4ed9c6772bc7e1e68c9f7
commit 98734cc50153c80047f4ed9c6772bc7e1e68c9f7
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Mar 23 16:34:48 2015 +0100
pthread_setaffinity (Linux variant): Rewrite to use VLA instead of alloca
extend_alloca was used to emulate VLA deallocation. The new version
also handles the res == 0 corner case more explicitly, by returning 0
instead of the (potentially undefined, but usually zero) system call
error.
diff --git a/ChangeLog b/ChangeLog
index c1b9106..5686701 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2015-03-23 Florian Weimer <fweimer@redhat.com>
+ * sysdeps/unix/sysv/linux/pthread_setaffinity.c
+ (__determine_cpumask_size): Replace extend_alloca with a
+ variable-length array. Do not treat res == 0 as an error.
+
+2015-03-23 Florian Weimer <fweimer@redhat.com>
+
[BZ #18100]
* posix/wordexp.c (eval_expr_multdiv): Check for division by zero
and integer overflow.
diff --git a/sysdeps/unix/sysv/linux/pthread_setaffinity.c b/sysdeps/unix/sysv/linux/pthread_setaffinity.c
index 37997e9..e891818 100644
--- a/sysdeps/unix/sysv/linux/pthread_setaffinity.c
+++ b/sysdeps/unix/sysv/linux/pthread_setaffinity.c
@@ -16,7 +16,6 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <alloca.h>
#include <errno.h>
#include <pthreadP.h>
#include <sysdep.h>
@@ -27,26 +26,30 @@
size_t __kernel_cpumask_size attribute_hidden;
-/* Determine the current affinity. As a side affect we learn
- about the size of the cpumask_t in the kernel. */
+/* Determine the size of cpumask_t in the kernel. */
int
__determine_cpumask_size (pid_t tid)
{
- INTERNAL_SYSCALL_DECL (err);
+ size_t psize;
int res;
- size_t psize = 128;
- void *p = alloca (psize);
-
- while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, tid, psize, p),
- INTERNAL_SYSCALL_ERROR_P (res, err)
- && INTERNAL_SYSCALL_ERRNO (res, err) == EINVAL)
- p = extend_alloca (p, psize, 2 * psize);
-
- if (res == 0 || INTERNAL_SYSCALL_ERROR_P (res, err))
- return INTERNAL_SYSCALL_ERRNO (res, err);
+ for (psize = 128; ; psize *= 2)
+ {
+ char buf[psize];
+ INTERNAL_SYSCALL_DECL (err);
+
+ res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, tid, psize, buf);
+ if (INTERNAL_SYSCALL_ERROR_P (res, err))
+ {
+ if (INTERNAL_SYSCALL_ERRNO (res, err) != EINVAL)
+ return INTERNAL_SYSCALL_ERRNO (res, err);
+ }
+ else
+ break;
+ }
- __kernel_cpumask_size = res;
+ if (res != 0)
+ __kernel_cpumask_size = res;
return 0;
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 ++++
sysdeps/unix/sysv/linux/pthread_setaffinity.c | 33 +++++++++++++-----------
2 files changed, 24 insertions(+), 15 deletions(-)
hooks/post-receive
--
GNU C Library master sources