about summary refs log tree commit diff
path: root/manual
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-12-07 09:17:37 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-12-07 09:17:50 -0800
commita092ca9453df677053787b376322362e3bbe91ca (patch)
tree949e1751f3547cb2628420f06e4dc48c2c6f4934 /manual
parent7c857b6f0db01e8d6876e601f0cbcd21d23e4dd5 (diff)
downloadglibc-a092ca9453df677053787b376322362e3bbe91ca.tar.gz
glibc-a092ca9453df677053787b376322362e3bbe91ca.tar.xz
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 'manual')
-rw-r--r--manual/resource.texi21
1 files changed, 21 insertions, 0 deletions
diff --git a/manual/resource.texi b/manual/resource.texi
index 8bc2a803d4..8c4c92a184 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -1429,6 +1429,27 @@ not leave a processor for the process or thread to run on.
 This function is a GNU extension and is declared in @file{sched.h}.
 @end deftypefun
 
+@deftypefun int getcpu (unsigned int *cpu, unsigned int *node)
+@standards{Linux, <sched.h>}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+The @code{getcpu} function identifies the processor and node on which
+the calling thread or process is currently running and writes them into
+the integers pointed to by the @var{cpu} and @var{node} arguments.  The
+processor is a unique nonnegative integer identifying a CPU.  The node
+is a unique nonnegative integer identifying a NUMA node.  When either
+@var{cpu} or @var{node} is @code{NULL}, nothing is written to the
+respective pointer.
+
+The return value is @code{0} on success and @code{-1} on failure.  The
+following @code{errno} error condition is defined for this function:
+
+@table @code
+@item ENOSYS
+The operating system does not support this function.
+@end table
+
+This function is Linux-specific and is declared in @file{sched.h}.
+@end deftypefun
 
 @node Memory Resources
 @section Querying memory available resources