git: e36cb22221e1 - stable/14 - kern_rctl.c: Minimal includes when RCTL not defined

From: Olivier Certner <olce_at_FreeBSD.org>
Date: Tue, 27 Feb 2024 10:38:32 UTC
The branch stable/14 has been updated by olce:

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

commit e36cb22221e11b711830509479fd56df69221b0e
Author:     Olivier Certner <olce@FreeBSD.org>
AuthorDate: 2023-10-19 14:28:06 +0000
Commit:     Olivier Certner <olce@FreeBSD.org>
CommitDate: 2024-02-27 10:37:23 +0000

    kern_rctl.c: Minimal includes when RCTL not defined
    
    If RCTL is not defined, only the system call stubs returning ENOSYS are
    compiled in.  In this case, don't waste time including most headers
    since their code is not used.
    
    Reviewed by:    markj
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e0205aa325c0936ccdd0e635576875786c41f6c3)
    
    Approved by:        emaste (mentor)
---
 sys/kern/kern_rctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c
index 799fcd76b77e..8e65fabeddc9 100644
--- a/sys/kern/kern_rctl.c
+++ b/sys/kern/kern_rctl.c
@@ -28,6 +28,8 @@
  * SUCH DAMAGE.
  */
 
+#ifdef RCTL
+
 #include <sys/cdefs.h>
 #include <sys/param.h>
 #include <sys/devctl.h>
@@ -56,7 +58,6 @@
 #include <sys/tree.h>
 #include <vm/uma.h>
 
-#ifdef RCTL
 #ifndef RACCT
 #error "The RCTL option requires the RACCT option"
 #endif
@@ -2204,6 +2205,9 @@ rctl_init(void)
 
 #else /* !RCTL */
 
+#include <sys/types.h>
+#include <sys/sysproto.h>
+
 int
 sys_rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap)
 {
@@ -2239,4 +2243,4 @@ sys_rctl_remove_rule(struct thread *td, struct rctl_remove_rule_args *uap)
 	return (ENOSYS);
 }
 
-#endif /* !RCTL */
+#endif /* RCTL */