]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - tools/perf/util/units.c
6 #include <linux/kernel.h>
7 #include <linux/time64.h>
9 unsigned long parse_tag_value(const char *str
, struct parse_tag
*tags
)
11 struct parse_tag
*i
= tags
;
14 char *s
= strchr(str
, i
->tag
);
17 unsigned long int value
;
20 value
= strtoul(str
, &endptr
, 10);
24 if (value
> ULONG_MAX
/ i
->mult
)
32 return (unsigned long) -1;
35 unsigned long convert_unit(unsigned long value
, char *unit
)
57 int unit_number__scnprintf(char *buf
, size_t size
, u64 n
)
59 char unit
[4] = "BKMG";
62 while (((n
/ 1024) > 1) && (i
< 3)) {
67 return scnprintf(buf
, size
, "%" PRIu64
"%c", n
, unit
[i
]);