Page MenuHomeFreeBSD

printf.9: Support more than 32 bits in %b
Needs ReviewPublic

Authored by tuexen on Thu, Dec 18, 2:39 PM.
Tags
None
Referenced Files
F140016504: D54286.id168316.diff
Fri, Dec 19, 2:09 AM
F140012671: D54286.id168380.diff
Fri, Dec 19, 12:46 AM
F140008586: D54286.id.diff
Thu, Dec 18, 11:25 PM
F140007884: D54286.id168316.diff
Thu, Dec 18, 11:11 PM
F140007350: D54286.diff
Thu, Dec 18, 11:01 PM
F140006657: D54286.diff
Thu, Dec 18, 10:46 PM
F139978981: D54286.id168316.diff
Thu, Dec 18, 2:59 PM
Subscribers

Details

Summary

This will be usable after clang has been extended to accept length modifiers for %b when compiling kernel code. But we need FreeBSD to support it first...

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

share/man/man9/printf.9
182

Extra newline. (It would be better to remove it from the previous example.)

sys/kern/subr_prf.c
971

Can we not support a modifier, so %lb takes a long, %jb takes an intmax_t, etc., instead of having this ad-hoc encoding?

The example should follow style.9 as suggested by Mark.

tuexen added inline comments.
share/man/man9/printf.9
182

Fixed. The previous example has been fixed in a separate commit.

sys/kern/subr_prf.c
971

That is already supported by the code above. But you need to be able to specify bit positions from 1 to 128 now. The positions from 1 to 32 are encoded as characters from \01 to \40. So you need a way to encode the other positions. OpenBSD also uses the characters from \200 to \377 for it. If you have a different idea, I am happy to explore it.

Once this is in, I need to change clang such that it knows that you can use a length modifier (like l or j) in combination with %b. Right now it is warning that you can only use a 32-bit entity. But when you just ignore the warning, it works. Fixing clang is the next step when this change is in.