summary refs log tree commit diff stats
path: root/fsdev/qemu-fsdev.c
diff options
context:
space:
mode:
authorLeonid Bloch <lbloch@janustech.com>2018-09-26 19:04:40 +0300
committerKevin Wolf <kwolf@redhat.com>2018-10-01 12:51:12 +0200
commit540b8492618ebbe98e7462bd7d31361b8cb10a05 (patch)
tree4ccf74af338a00bea794cedfeeac886ee69f96ac /fsdev/qemu-fsdev.c
parent40fb215d483ce510e211b843352288894eb13285 (diff)
downloadfocaccia-qemu-540b8492618ebbe98e7462bd7d31361b8cb10a05.tar.gz
focaccia-qemu-540b8492618ebbe98e7462bd7d31361b8cb10a05.zip
include: Add a lookup table of sizes
Adding a lookup table for the powers of two, with the appropriate size
prefixes. This is needed when a size has to be stringified, in which
case something like '(1 * KiB)' would become a literal '(1 * (1L << 10))'
string. Powers of two are used very often for sizes, so such a table
will also make it easier and more intuitive to write them.

This table is generatred using the following AWK script:

BEGIN {
	suffix="KMGTPE";
	for(i=10; i<64; i++) {
		val=2**i;
		s=substr(suffix, int(i/10), 1);
		n=2**(i%10);
		pad=21-int(log(n)/log(10));
		printf("#define S_%d%siB %*d\n", n, s, pad, val);
	}
}

Signed-off-by: Leonid Bloch <lbloch@janustech.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'fsdev/qemu-fsdev.c')
0 files changed, 0 insertions, 0 deletions