| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: snprintb.3,v 1.21 2019/04/29 07:55:38 kre Exp $ | | 1 | .\" $NetBSD: snprintb.3,v 1.22 2019/12/06 19:31:52 christos Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1998 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 1998 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Jeremy Cooper. | | 7 | .\" by Jeremy Cooper. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd April 27, 2019 | | 30 | .Dd December 6, 2019 |
31 | .Dt SNPRINTB 3 | | 31 | .Dt SNPRINTB 3 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm snprintb , | | 34 | .Nm snprintb , |
35 | .Nm snprintb_m | | 35 | .Nm snprintb_m |
36 | .Nd bitmask output conversion | | 36 | .Nd bitmask output conversion |
37 | .Sh LIBRARY | | 37 | .Sh LIBRARY |
38 | .Lb libutil | | 38 | .Lb libutil |
39 | .Sh SYNOPSIS | | 39 | .Sh SYNOPSIS |
40 | .In util.h | | 40 | .In util.h |
41 | .Ft int | | 41 | .Ft int |
42 | .Fn "snprintb" "char *buf" "size_t buflen" "const char *fmt" "uint64_t val" | | 42 | .Fn "snprintb" "char *buf" "size_t buflen" "const char *fmt" "uint64_t val" |
43 | .Ft int | | 43 | .Ft int |
| @@ -180,28 +180,30 @@ operator, but omits the leading | | | @@ -180,28 +180,30 @@ operator, but omits the leading |
180 | .It Cm *FMT | | 180 | .It Cm *FMT |
181 | This provides a | | 181 | This provides a |
182 | .Dq default | | 182 | .Dq default |
183 | case that prints | | 183 | case that prints |
184 | .Ar FMT | | 184 | .Ar FMT |
185 | using | | 185 | using |
186 | .Xr printf 3 | | 186 | .Xr printf 3 |
187 | when other | | 187 | when other |
188 | .Sq \&: | | 188 | .Sq \&: |
189 | or | | 189 | or |
190 | .Sq \&= | | 190 | .Sq \&= |
191 | have not matched. | | 191 | have not matched. |
192 | .Ar FMT | | 192 | .Ar FMT |
193 | may contain an integer format specification that prints the value that | | 193 | may contain a |
194 | did not match. | | 194 | .Ft uintmax_t |
| | | 195 | format specification that prints the value that |
| | | 196 | did not match, since the field can be more than 32 bits wide. |
195 | .El | | 197 | .El |
196 | .Pp | | 198 | .Pp |
197 | Finally, each field is delimited by a NUL | | 199 | Finally, each field is delimited by a NUL |
198 | .Pq Sq \e0 | | 200 | .Pq Sq \e0 |
199 | character. | | 201 | character. |
200 | By convention, the format string has an additional NUL character at | | 202 | By convention, the format string has an additional NUL character at |
201 | the end, following that delimiting the last bit-position\(endescription | | 203 | the end, following that delimiting the last bit-position\(endescription |
202 | pair. | | 204 | pair. |
203 | .Pp | | 205 | .Pp |
204 | The | | 206 | The |
205 | .Fn snprintb_m | | 207 | .Fn snprintb_m |
206 | function accepts an additional | | 208 | function accepts an additional |
207 | .Fa max | | 209 | .Fa max |
| @@ -297,27 +299,27 @@ F\e30\e010\e0\e | | | @@ -297,27 +299,27 @@ F\e30\e010\e0\e |
297 | :\e022ALIGN=256KB\e0\e | | 299 | :\e022ALIGN=256KB\e0\e |
298 | :\e023ALIGN=512KB\e0\e | | 300 | :\e023ALIGN=512KB\e0\e |
299 | :\e024ALIGN=1MB\e0\e | | 301 | :\e024ALIGN=1MB\e0\e |
300 | :\e030ALIGN=16MB\e0\e | | 302 | :\e030ALIGN=16MB\e0\e |
301 | :\e034ALIGN=256MB\e0\e | | 303 | :\e034ALIGN=256MB\e0\e |
302 | :\e040ALIGN=4GB\e0\e | | 304 | :\e040ALIGN=4GB\e0\e |
303 | :\e044ALIGN=64GB\e0\e | | 305 | :\e044ALIGN=64GB\e0\e |
304 | :\e050ALIGN=1TB\e0\e | | 306 | :\e050ALIGN=1TB\e0\e |
305 | :\e054ALIGN=16TB\e0\e | | 307 | :\e054ALIGN=16TB\e0\e |
306 | :\e060ALIGN=256TB\e0\e | | 308 | :\e060ALIGN=256TB\e0\e |
307 | :\e064ALIGN=4PB\e0\e | | 309 | :\e064ALIGN=4PB\e0\e |
308 | :\e070ALIGN=64PB\e0\e | | 310 | :\e070ALIGN=64PB\e0\e |
309 | :\e074ALIGN=256PB\e0\e | | 311 | :\e074ALIGN=256PB\e0\e |
310 | *ALIGN=2^%d\e0\e | | 312 | *ALIGN=2^%jd\e0\e |
311 | " | | 313 | " |
312 | snprintb(buf, buflen, MAP_FMT, 0x0d001234) | | 314 | snprintb(buf, buflen, MAP_FMT, 0x0d001234) |
313 | \(rA "0xd001234<COPY,FIXED,RENAME,HASSEMAPHORE,ANONYMOUS,ALIGN=8KB>" | | 315 | \(rA "0xd001234<COPY,FIXED,RENAME,HASSEMAPHORE,ANONYMOUS,ALIGN=8KB>" |
314 | snprintb(buf, buflen, MAP_FMT, 0x2e000000) | | 316 | snprintb(buf, buflen, MAP_FMT, 0x2e000000) |
315 | \(rA "0xd001234<0x2e000000<FILE,ALIGN=2^46> | | 317 | \(rA "0xd001234<0x2e000000<FILE,ALIGN=2^46> |
316 | .Ed | | 318 | .Ed |
317 | .Pp | | 319 | .Pp |
318 | An example using snprintb_m: | | 320 | An example using snprintb_m: |
319 | .Bd -literal -offset indent | | 321 | .Bd -literal -offset indent |
320 | snprintb_m(buf, buflen, | | 322 | snprintb_m(buf, buflen, |
321 | "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0" | | 323 | "\e177\e020b\e0LSB\e0b\e1_BITONE\e0f\e4\e4NIBBLE2\e0" |
322 | "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0" | | 324 | "f\ex10\e4BURST\e0=\e4FOUR\e0=\exfSIXTEEN\e0" |
323 | "b\ex1fMSB\e0\e0", | | 325 | "b\ex1fMSB\e0\e0", |