diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2018-12-07 09:17:37 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2018-12-07 09:17:50 -0800 |
commit | a092ca9453df677053787b376322362e3bbe91ca (patch) | |
tree | 949e1751f3547cb2628420f06e4dc48c2c6f4934 /sysdeps/unix/sysv/linux/getcpu.c | |
parent | 7c857b6f0db01e8d6876e601f0cbcd21d23e4dd5 (diff) | |
download | glibc-a092ca9453df677053787b376322362e3bbe91ca.tar glibc-a092ca9453df677053787b376322362e3bbe91ca.tar.gz glibc-a092ca9453df677053787b376322362e3bbe91ca.tar.bz2 glibc-a092ca9453df677053787b376322362e3bbe91ca.zip |
Add getcpu
Add
#include <sched.h>
int getcpu (unsigned int *cpu, unsigned int *node);
to return currently used CPU and NUMA node.
Tested on x86-64, x32 and i686 as well as with build-many-glibcs.py.
* NEWS: Mention getcpu.
* include/sched.h (__getcpu): New libc_hidden_proto.
* manual/resource.texi: Document getcpu.
* sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add getcpu.
* sysdeps/unix/sysv/linux/Versions (GLIBC_2.29): Add getcpu.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add getcpu.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
Likewise.
* sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/bits/sched.h (getcpu): New prototype.
* sysdeps/unix/sysv/linux/getcpu.c: New file.
* sysdeps/unix/sysv/linux/tst-skeleton-affinity.c (test_size):
Also check getcpu.
Diffstat (limited to 'sysdeps/unix/sysv/linux/getcpu.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/getcpu.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/getcpu.c b/sysdeps/unix/sysv/linux/getcpu.c new file mode 100644 index 0000000000..59c6cc4a14 --- /dev/null +++ b/sysdeps/unix/sysv/linux/getcpu.c @@ -0,0 +1,38 @@ +/* Copyright (C) 2007-2018 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + 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, see + <http://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 +__getcpu (unsigned int *cpu, unsigned int *node) +{ +#ifdef __NR_getcpu + return INLINE_VSYSCALL (getcpu, 3, cpu, node, NULL); +#else + __set_errno (ENOSYS); + return -1; +#endif +} +weak_alias (__getcpu, getcpu) +libc_hidden_def (__getcpu) |