Page MenuHomeFreeBSD

sysctl: make sys/sysctl.h self contained
ClosedPublic

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

Details

Summary

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

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
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.
sys/sys/sysctl.h
45

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

64

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
sys/sys/sysctl.h
45

Excellent suggestion.

64

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.