tags 297769 patch thanks The attached patch updates sched_[gs]etaffinity to the new interface from glibc 2.3.4. Bastian -- Phasers locked on target, Captain.
diff -ruN glibc-2.3.2.ds1/debian/changelog glibc-2.3.2.ds1.new/debian/changelog
--- glibc-2.3.2.ds1/debian/changelog 2005-03-24 15:16:44.422281391 +0000
+++ glibc-2.3.2.ds1.new/debian/changelog 2005-03-24 12:15:00.113925584 +0000
@@ -1,3 +1,11 @@
+glibc (2.3.2.ds1-20.1) unstable; urgency=low
+
+ * Bastian Blank <waldi@debian.org>
+
+ - Update sched_[gs]etaffinity to new interface. (closes: #297769)
+
+ -- Bastian Blank <waldi@debian.org> Thu, 24 Mar 2005 12:14:44 +0000
+
glibc (2.3.2.ds1-20) unstable; urgency=high
* GOTO Masanori <gotom@debian.org>
diff -ruN glibc-2.3.2.ds1/debian/patches/00list glibc-2.3.2.ds1.new/debian/patches/00list
--- glibc-2.3.2.ds1/debian/patches/00list 2005-03-24 15:16:43.559278442 +0000
+++ glibc-2.3.2.ds1.new/debian/patches/00list 2005-03-24 13:55:17.071976008 +0000
@@ -116,3 +116,5 @@
s390-pthread-fpic
nptl-pthread-c++
hppa-drop-utimes
+libversion
+sched-update
diff -ruN glibc-2.3.2.ds1/debian/patches/libversion.dpatch glibc-2.3.2.ds1.new/debian/patches/libversion.dpatch
--- glibc-2.3.2.ds1/debian/patches/libversion.dpatch 1970-01-01 00:00:00.000000000 +0000
+++ glibc-2.3.2.ds1.new/debian/patches/libversion.dpatch 2005-03-24 13:54:58.736966104 +0000
@@ -0,0 +1,32 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Description: Update library versions
+# DP: Patch author: Bastian Blank <waldi@debian.org>
+# DP: Date: 2005-03-24
+
+PATCHLEVEL=0
+
+if [ $# -ne 2 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch -d "$2" -f --no-backup-if-mismatch -p$PATCHLEVEL < $0;;
+ -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p$PATCHLEVEL < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+--- Versions.def 2005-03-24 12:47:59.279008144 +0000
++++ Versions.def 2005-03-24 13:53:32.651007992 +0000
+@@ -19,6 +19,7 @@
+ GLIBC_2.3.1
+ GLIBC_2.3.2
+ GLIBC_2.3.3
++ GLIBC_2.3.4
+ %ifdef USE_IN_LIBIO
+ HURD_CTHREADS_0.3
+ %endif
diff -ruN glibc-2.3.2.ds1/debian/patches/sched-update.dpatch glibc-2.3.2.ds1.new/debian/patches/sched-update.dpatch
--- glibc-2.3.2.ds1/debian/patches/sched-update.dpatch 1970-01-01 00:00:00.000000000 +0000
+++ glibc-2.3.2.ds1.new/debian/patches/sched-update.dpatch 2005-03-24 14:27:00.818943936 +0000
@@ -0,0 +1,224 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DP:' are a description of the patch.
+# DP: Description: Update sched_[gs]et_affinity to new interface
+# DP: Related bugs: 297769
+# DP: Patch author: Bastian Blank <waldi@debian.org>
+# DP: Upstream status: Released
+# DP: Date: 2005-03-24
+
+PATCHLEVEL=0
+
+if [ $# -ne 2 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch) patch -d "$2" -f --no-backup-if-mismatch -p$PATCHLEVEL < $0;;
+ -unpatch) patch -d "$2" -f --no-backup-if-mismatch -R -p$PATCHLEVEL < $0;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+--- posix/sched.h 2005-03-24 12:08:26.376014592 +0000
++++ posix/sched.h 2005-03-24 12:04:15.878891472 +0000
+@@ -73,11 +73,12 @@
+
+
+ /* Set the CPU affinity for a task */
+-extern int sched_setaffinity (__pid_t __pid, __const cpu_set_t *__mask)
+- __THROW;
++extern int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
++ __const cpu_set_t *__cpuset) __THROW;
+
+ /* Get the CPU affinity for a task */
+-extern int sched_getaffinity (__pid_t __pid, cpu_set_t *__mask) __THROW;
++extern int sched_getaffinity (__pid_t __pid, size_t __cpusetsize,
++ cpu_set_t *__cpuset) __THROW;
+ #endif
+
+ __END_DECLS
+--- sysdeps/generic/sched_getaffinity.c 2005-03-24 12:08:26.502995288 +0000
++++ sysdeps/generic/sched_getaffinity.c 2005-03-24 12:00:21.055915184 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -23,8 +23,9 @@
+
+ /* Retrieve the CPU affinity mask for a particular process. */
+ int
+-sched_getaffinity (pid, cpuset)
++sched_getaffinity (pid, cpusetsize, cpuset)
+ pid_t pid;
++ size_t cpusetsize;
+ cpu_set_t *cpuset;
+ {
+ __set_errno (ENOSYS);
+--- sysdeps/generic/sched_setaffinity.c 2005-03-24 12:08:26.503995136 +0000
++++ sysdeps/generic/sched_setaffinity.c 2005-03-24 12:00:23.306972184 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -23,8 +23,9 @@
+
+ /* Retrieve the CPU affinity mask for a particular process. */
+ int
+-sched_setaffinity (pid, cpuset)
++sched_setaffinity (pid, cpusetsize, cpuset)
+ pid_t pid;
++ size_t cpusetsize;
+ const cpu_set_t *cpuset;
+ {
+ __set_errno (ENOSYS);
+--- sysdeps/unix/sysv/linux/sched_getaffinity.c 2005-03-24 12:08:26.876938440 +0000
++++ sysdeps/unix/sysv/linux/sched_getaffinity.c 2005-03-24 12:00:10.236962456 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -21,25 +21,37 @@
+ #include <string.h>
+ #include <sysdep.h>
+ #include <sys/types.h>
++#include <shlib-compat.h>
+
+
+ #ifdef __NR_sched_getaffinity
+ int
+-sched_getaffinity (pid, cpuset)
+- pid_t pid;
+- cpu_set_t *cpuset;
++__sched_getaffinity_new (pid_t pid, size_t cpusetsize, cpu_set_t *cpuset)
+ {
+ int res = INLINE_SYSCALL (sched_getaffinity, 3, pid, sizeof (cpu_set_t),
+ cpuset);
+ if (res != -1)
+ {
+ /* Clean the rest of the memory the kernel didn't do. */
+- memset ((char *) cpuset + res, '\0', sizeof (cpu_set_t) - res);
++ memset ((char *) cpuset + res, '\0', cpusetsize - res);
+
+ res = 0;
+ }
+ return res;
+ }
++versioned_symbol (libc, __sched_getaffinity_new, sched_getaffinity,
++ GLIBC_2_3_4);
++
++
++# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
++int
++__sched_getaffinity_old (pid_t pid, cpu_set_t *cpuset)
++{
++ /* The old interface by default assumed a 1024 processor bitmap. */
++ return __sched_getaffinity_new (pid, 128, cpuset);
++}
++compat_symbol (libc, __sched_getaffinity_old, sched_getaffinity, GLIBC_2_3_3);
++# endif
+ #else
+ # include <sysdeps/generic/sched_getaffinity.c>
+ #endif
+--- sysdeps/unix/sysv/linux/sched_setaffinity.c 2005-03-24 12:08:26.877938288 +0000
++++ sysdeps/unix/sysv/linux/sched_setaffinity.c 2005-03-24 11:59:07.421926736 +0000
+@@ -1,4 +1,4 @@
+-/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
++/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+@@ -20,18 +20,68 @@
+ #include <sched.h>
+ #include <string.h>
+ #include <sysdep.h>
++#include <unistd.h>
+ #include <sys/types.h>
++#include <shlib-compat.h>
++#include <alloca.h>
+
+
+ #ifdef __NR_sched_setaffinity
++static size_t __kernel_cpumask_size;
++
++
++int
++__sched_setaffinity_new (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
++{
++ if (__builtin_expect (__kernel_cpumask_size == 0, 0))
++ {
++ INTERNAL_SYSCALL_DECL (err);
++ int res;
++
++ size_t psize = 128;
++ void *p = alloca (psize);
++
++ while (res = INTERNAL_SYSCALL (sched_getaffinity, err, 3, getpid (),
++ 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))
++ {
++ __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
++ return -1;
++ }
++
++ __kernel_cpumask_size = res;
++ }
++
++ /* We now know the size of the kernel cpumask_t. Make sure the user
++ does not request to set a bit beyond that. */
++ for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
++ if (((char *) cpuset)[cnt] != '\0')
++ {
++ /* Found a nonzero byte. This means the user request cannot be
++ fulfilled. */
++ __set_errno (EINVAL);
++ return -1;
++ }
++
++ return INLINE_SYSCALL (sched_setaffinity, 3, pid, cpusetsize, cpuset);
++}
++versioned_symbol (libc, __sched_setaffinity_new, sched_setaffinity,
++ GLIBC_2_3_4);
++
++
++# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
+ int
+-sched_setaffinity (pid, cpuset)
+- pid_t pid;
+- const cpu_set_t *cpuset;
++__sched_setaffinity_old (pid_t pid, const cpu_set_t *cpuset)
+ {
+- return INLINE_SYSCALL (sched_setaffinity, 3, pid, sizeof (cpu_set_t),
+- cpuset);
++ /* The old interface by default assumed a 1024 processor bitmap. */
++ return __sched_setaffinity_new (pid, 128, cpuset);
+ }
++compat_symbol (libc, __sched_setaffinity_old, sched_setaffinity, GLIBC_2_3_3);
++# endif
+ #else
+ # include <sysdeps/generic/sched_setaffinity.c>
+ #endif
+--- sysdeps/unix/sysv/linux/Versions 2002-12-16 23:28:17.000000000 +0000
++++ sysdeps/unix/sysv/linux/Versions 2005-03-24 12:05:43.712983888 +0000
+@@ -109,6 +109,9 @@
+ # New kernel interfaces.
+ epoll_create; epoll_ctl; epoll_wait;
+ }
++ GLIBC_2.3.4 {
++ sched_getaffinity; sched_setaffinity;
++ }
+ GLIBC_PRIVATE {
+ # needed by libpthread.
+ __libc_sigaction;
Attachment:
signature.asc
Description: Digital signature