Page MenuHomeFreeBSD

sysctl: make sys/sysctl.h self contained

Authored by imp on Sep 3 2021, 6:57 PM.



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

Diff Detail

R10 FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

imp requested review of this revision.Sep 3 2021, 6:57 PM
imp created this revision.

I think this line should be moved under #ifdef _KERNEL, if you are cleaning the header for userspace.


I am not sure why this structure is defined for userspace.

More, I tried to find a use for it in src/ and failed (but I only grepped, I did not tried to compile world with the definition removed).

This revision is now accepted and ready to land.Sep 8 2021, 6:18 PM

Excellent suggestion.


World and kernel both build w/o it. I'm going to remove it as a separate commit.

Finalize kib's comments

This revision now requires review to proceed.Oct 11 2021, 3:44 PM
This revision is now accepted and ready to land.Oct 11 2021, 4:11 PM
This revision was automatically updated to reflect the committed changes.