|
|
@ -2341,30 +2341,36 @@ API void* nctablet_userptr(struct nctablet* t);
|
|
|
|
// Access the ncplane associated with this nctablet, if one exists.
|
|
|
|
// Access the ncplane associated with this nctablet, if one exists.
|
|
|
|
API struct ncplane* nctablet_ncplane(struct nctablet* t);
|
|
|
|
API struct ncplane* nctablet_ncplane(struct nctablet* t);
|
|
|
|
|
|
|
|
|
|
|
|
#define PREFIXSTRLEN 7 // Does not include a '\0' (xxx.xxU)
|
|
|
|
// The number of columns is one fewer, as the expressions here must
|
|
|
|
#define IPREFIXSTRLEN 8 // Does not include a '\0' (xxxx.xxU)
|
|
|
|
// leave an extra byte open in case “µ” (U+00B5, 0xC2 0xB5) shows up.
|
|
|
|
#define BPREFIXSTRLEN 9 // Does not include a '\0' (xxxx.xxUi), i == prefix
|
|
|
|
#define PREFIXCOLUMNS 7
|
|
|
|
|
|
|
|
#define IPREFIXCOLUMNS 8
|
|
|
|
|
|
|
|
#define BPREFIXCOLUMNS 9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PREFIXSTRLEN (PREFIXCOLUMNS + 1) // Does not include a '\0' (xxx.xxU)
|
|
|
|
|
|
|
|
#define IPREFIXSTRLEN (IPREFIXCOLUMNS + 1) // Does not include a '\0' (xxxx.xxU)
|
|
|
|
|
|
|
|
#define BPREFIXSTRLEN (BPREFIXCOLUMNS + 1) // Does not include a '\0' (xxxx.xxUi), i == prefix
|
|
|
|
|
|
|
|
|
|
|
|
// A bit of the nasties here to stringize our preprocessor tokens just now
|
|
|
|
// A bit of the nasties here to stringize our preprocessor tokens just now
|
|
|
|
// #defined, making them usable as printf(3) specifiers.
|
|
|
|
// #defined, making them usable as printf(3) specifiers.
|
|
|
|
#define STRHACK1(x) #x
|
|
|
|
#define STRHACK1(x) #x
|
|
|
|
#define STRHACK2(x) STRHACK1(x)
|
|
|
|
#define STRHACK2(x) STRHACK1(x)
|
|
|
|
#define PREFIXFMT "%" STRHACK2(PREFIXSTRLEN) "s"
|
|
|
|
#define PREFIXFMT "%" STRHACK2(PREFIXCOLUMNS) "s"
|
|
|
|
#define IPREFIXFMT "%" STRHACK2(IPREFIXSTRLEN) "s"
|
|
|
|
#define IPREFIXFMT "%" STRHACK2(IPREFIXCOLUMNS) "s"
|
|
|
|
#define BPREFIXFMT "%" STRHACK2(BPREFIXSTRLEN) "s"
|
|
|
|
#define BPREFIXFMT "%" STRHACK2(BPREFIXCOLUMNS) "s"
|
|
|
|
|
|
|
|
|
|
|
|
// Takes an arbitrarily large number, and prints it into a fixed-size buffer by
|
|
|
|
// Takes an arbitrarily large number, and prints it into a fixed-size buffer by
|
|
|
|
// adding the necessary SI suffix. Usually, pass a |[B]PREFIXSTRLEN+1|-sized
|
|
|
|
// adding the necessary SI suffix. Usually, pass a |[IB]PREFIXSTRLEN+1|-sized
|
|
|
|
// buffer to generate up to [B]PREFIXSTRLEN characters. The characteristic can
|
|
|
|
// buffer to generate up to |[IB]PREFIXCOLUMNS| columns' worth of EGCs. The
|
|
|
|
// occupy up through |mult-1| characters (3 for 1000, 4 for 1024). The mantissa
|
|
|
|
// characteristic can occupy up through |mult-1| characters (3 for 1000, 4 for
|
|
|
|
// can occupy either zero or two characters.
|
|
|
|
// 1024). The mantissa can occupy either zero or two characters.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Floating-point is never used, because an IEEE758 double can only losslessly
|
|
|
|
// Floating-point is never used, because an IEEE758 double can only losslessly
|
|
|
|
// represent integers through 2^53-1.
|
|
|
|
// represent integers through 2^53-1.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// 2^64-1 is 18446744073709551615, 18.45E(xa). KMGTPEZY thus suffice to handle
|
|
|
|
// 2^64-1 is 18446744073709551615, 18.45E(xa). KMGTPEZY thus suffice to handle
|
|
|
|
// an 89-bit uintmax_t. Beyond Z(etta) and Y(otta) lie lands unspecified by SI.
|
|
|
|
// an 89-bit uintmax_t. Beyond Z(etta) and Y(otta) lie lands unspecified by SI.
|
|
|
|
//
|
|
|
|
// 2^-63 is 0.000000000000000000108, 1.08a(tto).
|
|
|
|
// val: value to print
|
|
|
|
// val: value to print
|
|
|
|
// decimal: scaling. '1' if none has taken place.
|
|
|
|
// decimal: scaling. '1' if none has taken place.
|
|
|
|
// buf: buffer in which string will be generated
|
|
|
|
// buf: buffer in which string will be generated
|
|
|
@ -2372,7 +2378,7 @@ API struct ncplane* nctablet_ncplane(struct nctablet* t);
|
|
|
|
// mult: base of suffix system (almost always 1000 or 1024)
|
|
|
|
// mult: base of suffix system (almost always 1000 or 1024)
|
|
|
|
// uprefix: character to print following suffix ('i' for kibibytes basically).
|
|
|
|
// uprefix: character to print following suffix ('i' for kibibytes basically).
|
|
|
|
// only printed if suffix is actually printed (input >= mult).
|
|
|
|
// only printed if suffix is actually printed (input >= mult).
|
|
|
|
API const char* ncmetric(uintmax_t val, unsigned decimal, char* buf,
|
|
|
|
API const char* ncmetric(uintmax_t val, uintmax_t decimal, char* buf,
|
|
|
|
int omitdec, unsigned mult, int uprefix);
|
|
|
|
int omitdec, unsigned mult, int uprefix);
|
|
|
|
|
|
|
|
|
|
|
|
// Mega, kilo, gigafoo. Use PREFIXSTRLEN + 1.
|
|
|
|
// Mega, kilo, gigafoo. Use PREFIXSTRLEN + 1.
|
|
|
|