Page MenuHomeFreeBSD

sys: Extract __bitcount* from sys/types.h to new sys/bitcount.h
ClosedPublic

Authored by jrtc27 on Aug 11 2022, 12:03 AM.
Tags
None
Referenced Files
F102419976: D36132.id109500.diff
Tue, Nov 12, 12:57 AM
Unknown Object (File)
Wed, Nov 6, 12:51 AM
Unknown Object (File)
Oct 8 2024, 8:02 AM
Unknown Object (File)
Oct 8 2024, 8:01 AM
Unknown Object (File)
Oct 8 2024, 8:01 AM
Unknown Object (File)
Oct 8 2024, 7:38 AM
Unknown Object (File)
Sep 25 2024, 4:28 PM
Unknown Object (File)
Sep 25 2024, 2:20 PM

Details

Summary

This will allow the code to be reused by the cross-build sys/types.h
wrapper in order to provide the APIs for greater compatibility. This
also provides a path towards eventually removing the definitions from
sys/types.h altogether if so desired by gradually migrating users to
including sys/bitcount.h explicitly, but that is not the primary goal
here.

Diff Detail

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

Event Timeline

jrtc27 created this revision.
emaste added inline comments.
sys/sys/bitcount.h
4–6

I'm not sure these should have a Regents copyright -- I looked at one example, bitcount16, and it comes from @kib's R10:b03c6795275eb89d06599250d7ebb905417ea172

sys/sys/bitcount.h
4–6

Happy to trim it to something more appropriate, I just copied it wholesale from sys/sys/types.h given that's where the contents are moved from

sys/sys/bitcount.h
4–6

Yeah - I suspect that when they were added the author(s) did not feel they warranted an addition to the copyright header, but now that they're extracted to a separate file we should clean it up. I'll try to find where they all come from

arichardson added inline comments.
sys/sys/bitcount.h
47

I was going to suggest using those builtins unconditionally, but it turns out GCC emits a libcall instead of inlining the code: https://godbolt.org/z/cYn6zr6cv ...

The original version of bitcount32() goes back to commit f1b665c8fe3c87d9baf30ea71abacecb5345238c by @peter. The only material change to that code was a cleanup by @cperciva in 9c518c234b073769063b086103701fdc7e834150. kib added bitcount16(), and I expanded it to cover 64-bit, longs, and ints. None of those have origins in UCB, with the exception that I think @peter might have gotten the original out of a fortune(6) file which indeed might date back to UCB.

If it's going to take a while to figure out what a more precise copyright statement would be, can I please get this committed so we can fix building makefs as a bootstrap tool on non-FreeBSD, with the copyright adjusted as deemed fit post-commit? This is currently preventing cheribuild freebsd-<arch> from working on non-FreeBSD.

I think it's fine to commit as-is.

BTW, the code in fortune that Peter copied was added in this commit (I was 11 years old at the time): https://svnweb.freebsd.org/csrg/games/fortune/datfiles/fortunes?revision=39099&view=markup

I don't think fortune really had a separate license. It probably though was under the UCB umbrella in 4.4Lite.

can I please get this committed so we can fix building makefs as a bootstrap tool on non-FreeBSD

Sure, go ahead. Perhaps just mention in the commit message that you copied the header copyright block from the source file (so that if someone wants to change it in the future it seems reasonable).

This revision is now accepted and ready to land.Aug 16 2022, 7:45 PM