30L4_INLINE int l4util_human_readable_size(
char *outstr,
size_t outsize,
31 unsigned long long bytes)
33 static char const *
const unitstr =
"BKMGT";
35 int idx =
sizeof(unitstr) - 2;
38 for (order = idx * 10; order > 10; order -= 10, --idx)
39 if (bytes > (1ULL << order))
42 unsigned long long value = bytes >> order;
43 unsigned long long fract = (bytes - (value << order))
44 / ((1ULL << order) / 10 + 1);
46 return snprintf(outstr, outsize,
"%llu.%1llu %ciB",
47 value, fract, unitstr[idx]);
L4 compiler related defines.
#define L4_INLINE
L4 Inline function attribute.