HomeFreeBSD

sysctl(9): Ease exporting struct sizes; Discourage doing that

Description

sysctl(9): Ease exporting struct sizes; Discourage doing that

Introduce two helpers, the more general SYSCTL_SIZEOF() and
a struct-specific one SYSCTL_SIZEOF_STRUCT() which prepends 'struct' in
the description and in the use of sizeof() but uses the raw structure
name as the knob's name. The size of the object/structure is exported
under 'debug.sizeof'.

Existing knobs under 'debug.sizeof' were all converted to use the
helpers.

Add a note before the helpers discouraging the introduction of new
leaves for ad-hoc reasons. List alternative means for developers to
obtain the size of arbitrary kernel structures easily (thanks to markj@
for providing these).

No functional change (intended).

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50121

Details

Provenance
olceAuthored on May 1 2025, 4:02 PM
Reviewer
kib
Differential Revision
D50121: sysctl(9): Ease exporting struct sizes; Discourage doing that
Parents
rGda509c29089a: libc: add link_ntoa_r()
Branches
Unknown
Tags
Unknown