]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/unix/sysv/linux/sched_getcpu.c
Prefer https to http for gnu.org and fsf.org URLs
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / sched_getcpu.c
index d0c0132eb9a2af604366f2edff1e855f780a6530..65dd9fdda79e096521215faa1c7ea8b06cd1ccf9 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2007-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 <sysdep.h>
 
+#ifdef HAVE_GETCPU_VSYSCALL
+# define HAVE_VSYSCALL
+#endif
+#include <sysdep-vdso.h>
 
 int
 sched_getcpu (void)
 {
 #ifdef __NR_getcpu
   unsigned int cpu;
-  INTERNAL_SYSCALL_DECL (err);
-  int r = INTERNAL_SYSCALL (getcpu, err, &cpu, NULL, NULL);
+  int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL);
 
-  return (INTERNAL_SYSCALL_ERROR (r, err)
-         ? INTERNAL_SYSCALL_ERRNO (r, err) : cpu);
+  return r == -1 ? r : cpu;
 #else
   __set_errno (ENOSYS);
   return -1;