aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2021-10-11 17:14:51 +0000
committerWarner Losh <imp@FreeBSD.org>2021-10-11 17:20:07 +0000
commit56ee5c551f89e767e931c55e063a20abd0c55346 (patch)
tree0f281592b78dee8ad4c361f704f134a078a1bc3b
parente8f26e5dc859a8fbc663e108421f657325ca3054 (diff)
downloadsrc-56ee5c551f89e767e931c55e063a20abd0c55346.tar.gz
src-56ee5c551f89e767e931c55e063a20abd0c55346.zip
sysctl: make sys/sysctl.h self contained
sys/sysctl.h only needs u_int and size_t from sys/types.h. When the sysctl interface was designed, having one more more prerequisites (especially sys/types.h) was the norm. Times have changed, and to make things more portable, make sys/types.h optional. We do this by including sys/_types.h, defining size_t if needed, and changing u_int to 'unsigned int' in a prototype for userland builds. For kernel builds, sys/types.h is still required. Sponsored by: Netflix Reviewed by: kib, jhb Differential Revision: https://reviews.freebsd.org/D31827
-rw-r--r--sys/sys/sysctl.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index 9e9bd723f4bd..8178c7208f9b 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1180,9 +1180,14 @@ struct sbuf *sbuf_new_for_sysctl(struct sbuf *, char *, int,
struct sysctl_req *);
#else /* !_KERNEL */
#include <sys/cdefs.h>
+#include <sys/_types.h>
+#ifndef _SIZE_T_DECLARED
+typedef __size_t size_t;
+#define _SIZE_T_DECLARED
+#endif
__BEGIN_DECLS
-int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
+int sysctl(const int *, unsigned int, void *, size_t *, const void *, size_t);
int sysctlbyname(const char *, void *, size_t *, const void *, size_t);
int sysctlnametomib(const char *, int *, size_t *);
__END_DECLS