Page MenuHomeFreeBSD

sys/param.h: Split some macros into new <sys/_param.h>
ClosedPublic

Authored by olce on Jun 16 2025, 4:35 PM.
Tags
None
Referenced Files
F132137776: D50880.id157111.diff
Tue, Oct 14, 2:29 AM
Unknown Object (File)
Mon, Oct 13, 11:38 AM
Unknown Object (File)
Mon, Oct 13, 11:38 AM
Unknown Object (File)
Mon, Oct 13, 11:38 AM
Unknown Object (File)
Sun, Oct 12, 10:57 PM
Unknown Object (File)
Tue, Sep 30, 2:53 PM
Unknown Object (File)
Tue, Sep 30, 2:53 PM
Unknown Object (File)
Tue, Sep 30, 2:52 PM
Subscribers

Details

Summary

Goal is to avoid having to include the full <sys/param.h> just to get
some common useful macros. More macros should be moved into it as
needed.

This is in preparation for using NBBY and howmany() from <sys/runq.h>.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

olce requested review of this revision.Jun 16 2025, 4:35 PM
kib added inline comments.
sys/sys/param.h
322
This revision is now accepted and ready to land.Jun 16 2025, 5:03 PM
olce marked an inline comment as done.Jun 17 2025, 2:11 PM
imp added inline comments.
sys/sys/_param.h
10

Maybe we should start using #pragma once?

olce marked an inline comment as done.Jun 17 2025, 4:02 PM
olce added inline comments.
sys/sys/_param.h
10

I generally am for it. There are some caveats in using it (reminded in this unrelated C++ proposal) but they don't seem to apply here.

Changed in my local copy.

sys/sys/_param.h
10

This feature is not even in C23. IMO this would be a gratuitous dependency on the compiler extension which could be avoided.

The argument that our system needs gcc-like compiler anyway does not apply there, the header is used by third-party code. There are enough small C compilers like tcc and other, which we should aim to support.

olce marked 2 inline comments as done.Jun 17 2025, 8:02 PM
olce added inline comments.
sys/sys/_param.h
10

Yes, I'm aware that this feature is completely non-standard. But it has been supported for so long by GCC that I thought it had percolated to basically every C compiler still in existence. I'll just back out introducing #pragma once to be safe, and we can see to intrducing #pragma once later.

For reference, according to GCC documentation, #pragma once existed in GCC 2.95 at least, was marked obsolete until GCC 9 since when the manual has been mentioning it again in the front "Pragmas" page.

sys/sys/_param.h
10

We already gratuitously depend on boatloads of non-standard features... #pragma once is used elsewhere in the tree... But only in openssl and 3 debug .h files...

Tinyc supports this since Linux uses it all over the place....

But I don't feel strongly enough about it to do more than ask the question... I'm good either way

This revision was automatically updated to reflect the committed changes.
olce marked an inline comment as done.