diff options
author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-04-11 21:12:12 +0200 |
---|---|---|
committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2024-04-11 21:12:12 +0200 |
commit | 01731e6e89d44ac7e7ab675e4e597474d1b5180a (patch) | |
tree | a8cda10345b3254cdadeac41a453e504386b33de /stage3 | |
parent | 8b90c1f407b4f4aa3802858e23aa90d7dfbe17ad (diff) | |
download | cuddles-01731e6e89d44ac7e7ab675e4e597474d1b5180a.tar.xz |
move print_bytes to font.c
Diffstat (limited to 'stage3')
-rw-r--r-- | stage3/font.c | 18 | ||||
-rw-r--r-- | stage3/font.h | 1 | ||||
-rw-r--r-- | stage3/shell.c | 18 |
3 files changed, 19 insertions, 18 deletions
diff --git a/stage3/font.c b/stage3/font.c index 4c99137..9022fbd 100644 --- a/stage3/font.c +++ b/stage3/font.c @@ -235,3 +235,21 @@ void print_dbl(double d, u8 points) print_char('.'); print_num_pad((d - (double) i) * (double) ipow(10, points), 10, points, '0'); } + +void print_bytes(usize bytes) +{ + static char fmt[] = { ' ', 'K', 'M', 'G', 'T' }; + usize unit = ipow(1000, LEN(fmt)-1); + for (usize i = 0; i < LEN(fmt); i++) { + if (bytes >= unit || unit == 1) { + print_num_pad(bytes/unit, 10, 3, ' '); + print_char('.'); + print_dec((bytes%unit)*10/unit); + print_char(' '); + print_char(fmt[LEN(fmt)-1-i]); + print_char('B'); + break; + } + unit /= 1000; + } +} diff --git a/stage3/font.h b/stage3/font.h index 44019bb..34c4780 100644 --- a/stage3/font.h +++ b/stage3/font.h @@ -24,5 +24,6 @@ void print_hex(u64 x); void print_num(u64 x, u8 base); void print_num_pad(u64 x, u8 base, u8 pad_len, char pad_char); void print_dbl(double d, u8 points); +void print_bytes(usize bytes); #endif diff --git a/stage3/shell.c b/stage3/shell.c index 9fd0f93..f61cbfd 100644 --- a/stage3/shell.c +++ b/stage3/shell.c @@ -184,24 +184,6 @@ static void cmd_uname(str arg) print(S("\n")); } -static void print_bytes(usize bytes) -{ - static char fmt[] = { ' ', 'K', 'M', 'G', 'T' }; - usize unit = ipow(1000, LEN(fmt)-1); - for (usize i = 0; i < LEN(fmt); i++) { - if (bytes >= unit || unit == 1) { - print_num_pad(bytes/unit, 10, 3, ' '); - print_char('.'); - print_dec((bytes%unit)*10/unit); - print_char(' '); - print_char(fmt[LEN(fmt)-1-i]); - print_char('B'); - break; - } - unit /= 1000; - } -} - static void cmd_ls(str arg) { dir d = fs_readdir(arg); |