printf.9: Support more than 32 bits in %b
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... Reviewed by: markj, Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54286
This commit is contained in:
+18
-7
@@ -24,7 +24,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd December 18, 2025
|
||||
.Dd December 19, 2025
|
||||
.Dt PRINTF 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -95,14 +95,15 @@ arguments.
|
||||
The base value is the output base (radix) expressed as an octal value;
|
||||
for example, \e10 gives octal and \e20 gives hexadecimal.
|
||||
The arguments are made up of a sequence of bit identifiers.
|
||||
Each bit identifier begins with an
|
||||
.Em octal
|
||||
value which is the number of the bit (starting from 1) this identifier
|
||||
describes.
|
||||
Each bit identifier begins with a character specifying the number of the bit
|
||||
(starting from 1) this identifier describes.
|
||||
The characters from \e01 to \e40 can be used to specify bit numbers in the
|
||||
range from 1 to 32 and characters from \e200 to \e377 to specify bit numbers
|
||||
in the range from 1 to 128.
|
||||
The rest of the identifier is a string of characters containing the name of
|
||||
the bit.
|
||||
The string is terminated by either the bit number at the start of the next
|
||||
bit identifier or
|
||||
The identifier is terminated by either the bit number at the start of the next
|
||||
bit identifier or by
|
||||
.Dv NUL
|
||||
for the last bit identifier.
|
||||
.Pp
|
||||
@@ -173,6 +174,16 @@ reg=3<BITTWO,BITONE>
|
||||
out: 41:41:5a:5a
|
||||
.Ed
|
||||
.Pp
|
||||
The same output will be generated by the following function:
|
||||
.Bd -literal -offset indent
|
||||
void
|
||||
printf_test(void)
|
||||
{
|
||||
printf("reg=%b\en", 3, "\e10\e201BITTWO\e200BITONE");
|
||||
printf("out: %4D\en", "AAZZ", ":");
|
||||
}
|
||||
.Ed
|
||||
.Pp
|
||||
The call
|
||||
.Bd -literal -offset indent
|
||||
log(LOG_DEBUG, "%s%d: been there.\en", sc->sc_name, sc->sc_unit);
|
||||
|
||||
Reference in New Issue
Block a user