git: 58865d5f8d68 - stable/13 - sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Fri, 14 Jan 2022 18:10:22 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=58865d5f8d689e6bae843b47831999a2dd78081d

commit 58865d5f8d689e6bae843b47831999a2dd78081d
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-11-11 08:01:54 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-01-14 16:17:29 +0000

    sched.h: Hide all Linux compat sched_* functions under _WITH_CPU_SET_T
    
    (cherry picked from commit 90fa9705d5cd29cf11c5dc7319299788dec2546a)
---
 include/sched.h                     | 7 +++----
 lib/libc/gen/sched_getaffinity.c    | 1 +
 lib/libc/gen/sched_getcpu_gen.c     | 1 +
 lib/libc/gen/sched_setaffinity.c    | 1 +
 lib/libc/x86/sys/sched_getcpu_x86.c | 1 +
 5 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/include/sched.h b/include/sched.h
index 1c41cda79046..460d3bfed154 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -32,12 +32,9 @@
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/sched.h>
-#if __BSD_VISIBLE
-#include <sys/cpuset.h>
-#endif /* __BSD_VISIBLE */
-
 #if __BSD_VISIBLE
 #ifdef _WITH_CPU_SET_T
+#include <sys/cpuset.h>
 struct _cpuset;
 typedef struct _cpuset cpu_set_t;
 #endif /* _WITH_CPU_SET_T */
@@ -45,9 +42,11 @@ typedef struct _cpuset cpu_set_t;
 
 __BEGIN_DECLS
 #if __BSD_VISIBLE
+#ifdef _WITH_CPU_SET_T
 int sched_getaffinity(pid_t pid, size_t cpusetsz, cpuset_t *cpuset);
 int sched_setaffinity(int pid, size_t cpusetsz, const cpuset_t *cpuset);
 int sched_getcpu(void);
+#endif /* _WITH_CPU_SET_T */
 #endif /* __BSD_VISIBLE */
 __END_DECLS
 
diff --git a/lib/libc/gen/sched_getaffinity.c b/lib/libc/gen/sched_getaffinity.c
index 191374a3c5e3..5557d3d93b47 100644
--- a/lib/libc/gen/sched_getaffinity.c
+++ b/lib/libc/gen/sched_getaffinity.c
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#define	_WITH_CPU_SET_T
 #include <sched.h>
 
 int
diff --git a/lib/libc/gen/sched_getcpu_gen.c b/lib/libc/gen/sched_getcpu_gen.c
index ef1bebc2915a..704075c0ae53 100644
--- a/lib/libc/gen/sched_getcpu_gen.c
+++ b/lib/libc/gen/sched_getcpu_gen.c
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#define	_WITH_CPU_SET_T
 #include <sched.h>
 #include "libc_private.h"
 
diff --git a/lib/libc/gen/sched_setaffinity.c b/lib/libc/gen/sched_setaffinity.c
index 9368b1752b74..ad775b5dbce5 100644
--- a/lib/libc/gen/sched_setaffinity.c
+++ b/lib/libc/gen/sched_setaffinity.c
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#define	_WITH_CPU_SET_T
 #include <sched.h>
 
 int
diff --git a/lib/libc/x86/sys/sched_getcpu_x86.c b/lib/libc/x86/sys/sched_getcpu_x86.c
index 13ba18ef5e36..5e3bd5311734 100644
--- a/lib/libc/x86/sys/sched_getcpu_x86.c
+++ b/lib/libc/x86/sys/sched_getcpu_x86.c
@@ -32,6 +32,7 @@
 #include <machine/sysarch.h>
 #include <x86/ifunc.h>
 #include <errno.h>
+#define	_WITH_CPU_SET_T
 #include <sched.h>
 #include "libc_private.h"