git: f23668516160 - main - kern/sched: Hide scheduler selection from C++

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Thu, 20 Aug 2026 13:58:19 UTC
The branch main has been updated by des:

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

commit f2366851616083f923e8101363802678a03dc0b9
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-08-20 13:57:56 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-08-20 13:57:56 +0000

    kern/sched: Hide scheduler selection from C++
    
    The scheduler selection interface uses names that are reserved words in
    C++, causing problems for downstream projects that use C++ in the
    kernel.  Work around this by hiding the interface from C++ compilers
    until we can come up with a better solution.
    
    Fixes:          ce38acee8d0b ("Add kern/sched_shim.c")
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Sponsored by:   NetApp, Inc.
    Reviewed by:    siderop1_netapp.com, imp, kib
    Differential Revision:  https://reviews.freebsd.org/D58991
---
 sys/sys/sched.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index a7519f988762..9d8268d43d63 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -270,6 +270,13 @@ void schedinit_ap(void);
  */
 int sched_find_l2_neighbor(int cpu);
 
+/*
+ * The scheduler selection interface uses names that are reserved words in
+ * C++, causing problems for downstream projects that use C++ in the
+ * kernel.
+ */
+#ifndef __cplusplus
+
 struct sched_instance {
 	int	(*load)(void);
 	int	(*rr_interval)(void);
@@ -334,6 +341,8 @@ struct sched_selection {
 
 void sched_instance_select(void);
 
+#endif /* !__cplusplus */
+
 #endif /* _KERNEL */
 
 /* POSIX 1003.1b Process Scheduling */
@@ -360,7 +369,7 @@ struct sched_param {
 #ifndef _PID_T_DECLARED
 typedef __pid_t         pid_t;
 #define _PID_T_DECLARED
-#endif
+#endif /* !_PID_T_DECLARED */
 
 __BEGIN_DECLS
 int     sched_get_priority_max(int);
@@ -373,5 +382,6 @@ int     sched_setscheduler(pid_t, int, const struct sched_param *);
 int     sched_yield(void);
 __END_DECLS
 
-#endif
+#endif /* !_KERNEL */
+
 #endif /* !_SCHED_H_ */