]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/sched_getaffinity.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / sched_getaffinity.c
index c0a6eb81b9b855b5ec58679b449ea257dfb597ff..56af56e9fcb0d2467f7dccb588a899d988425ca2 100644 (file)
@@ -1,4 +1,4 @@
-/* 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.  */
@@ -44,6 +49,8 @@ versioned_symbol (libc, __sched_getaffinity_new, sched_getaffinity,
 
 
 # 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)