git: 25caac4d4566 - stable/14 - sched_getcpu: Add man page

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Wed, 04 Dec 2024 18:34:33 UTC
The branch stable/14 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=25caac4d456665e4f05f018a15e8ad98bb5d3d9f

commit 25caac4d456665e4f05f018a15e8ad98bb5d3d9f
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-11-13 22:04:06 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2024-12-04 18:32:58 +0000

    sched_getcpu: Add man page
    
    Moved from libsys to libc for stable/14.
    
    Reviewed by: kib
    Sponsored by: The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D47556
    
    (cherry picked from commit 36887e04947fedfebb9b648fadd0dd6cc03142ea)
---
 lib/libc/sys/Makefile.inc   |  1 +
 lib/libc/sys/sched_getcpu.3 | 51 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index e964e3dcff26..7628f121feac 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -299,6 +299,7 @@ MAN+=	abort2.2 \
 	rmdir.2 \
 	rtprio.2 \
 	sched_get_priority_max.2 \
+	sched_getcpu.3 \
 	sched_setparam.2 \
 	sched_setscheduler.2 \
 	sched_yield.2 \
diff --git a/lib/libc/sys/sched_getcpu.3 b/lib/libc/sys/sched_getcpu.3
new file mode 100644
index 000000000000..050a8f3facb4
--- /dev/null
+++ b/lib/libc/sys/sched_getcpu.3
@@ -0,0 +1,51 @@
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" Copyright (c) 2024 The FreeBSD Foundation
+.\"
+.\" This documentation was written by Ed Maste <emaste@FreeBSD.org>
+.\" under sponsorship from the FreeBSD Foundation.
+.\"
+.Dd November 13, 2024
+.Dt SCHED_GETCPU 3
+.Os
+.Sh NAME
+.Nm sched_getcpu
+.Nd get current CPU
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In sched.h
+.Ft int
+.Fn sched_getcpu void
+.Sh DESCRIPTION
+The
+.Fn sched_getcpu
+function returns the current CPU on which the calling thread is running.
+.Sh RETURN VALUES
+.Fn sched_getcpu
+returns the 0-based index of the current CPU at the time of the call.
+The value may become invalid immediately after return, unless the thread is
+pinned to a specific CPU.
+CPU numbering is the same as used by
+.Xr cpuset 2
+and CPU affinity calls.
+.Pp
+There are no error values as
+.Fn sched_getcpu
+does not fail.
+.Sh SEE ALSO
+.Xr cpuset 2 ,
+.Xr cpuset_getaffinity 2 ,
+.Xr cpuset_setaffinity 2 ,
+.Xr pthread_getaffinity_np 3 ,
+.Xr pthread_setaffinity_np
+.Sh STANDARDS
+The
+.Nm
+function originated in Linux.
+This implementation aims to be source-compatible with the Linux implementation.
+.Sh HISTORY
+The
+.Nm
+function was introduced in
+.Fx 13.1 .