tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Extension to snprintb(3)

In article <>,
Paul Goyette  <> wrote:
>Having recently purchased a couple of new processors, and trying to make 
>the output from cpuctl(8) look reasonable when decoding the various CPU 
>features, it's become apparent that the current snprintb(3) is somewhat 
>awkward to use.  For large bit masks, one either has to manually "split" 
>the desired value across multiple calls (which leads to drastiscally 
>uneven line lengths and/or an unnecessarily large number of short lines) 
>or suffer from excessively long lines.
>I propose a modified version of snprintb(3) which fills its output 
>buffer only with complete bit/field values.  In addition to the current 
>return value, this modified version would take an additional u_quad_t 
>argument which would be set to the bit(s) that were NOT decoded in the 
>current output.  This would allow one to repeatedly call the new 
>function, with a fixed-sized buffer, until all bits were decoded, and 
>would result in output lines that were reasonably equal in length.
>Is this a reasonable idea?  Any suggestion on what this new function 
>should be called?
>int snprintbx(char *buf, size_t buflen, const char *fmt, u_quad_t *val);

Sounds ok to me.


Home | Main Index | Thread Index | Old Index