-/* Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2019 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
#include <errno.h>
#include <sched.h>
#include <string.h>
#include <sysdep.h>
+#include <sys/param.h>
#include <sys/types.h>
#include <shlib-compat.h>
#ifdef __NR_sched_getaffinity
+# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
+extern int __sched_getaffinity_new (pid_t, size_t, cpu_set_t *);
+libc_hidden_proto (__sched_getaffinity_new)
+# endif
+
int
__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);
+ int res = INLINE_SYSCALL (sched_getaffinity, 3, pid,
+ MIN (INT_MAX, cpusetsize), cpuset);
if (res != -1)
{
/* Clean the rest of the memory the kernel didn't do. */
# if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_3_4)
+libc_hidden_def (__sched_getaffinity_new)
+
int
attribute_compat_text_section
__sched_getaffinity_old (pid_t pid, cpu_set_t *cpuset)