From c84c34c0058e8f64dc5fe346549711d84e77938e Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Mon, 8 Feb 2021 17:07:42 +0100 Subject: [PATCH 1/3] sys/fmt: Add print_s64_dec to header --- sys/include/fmt.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/include/fmt.h b/sys/include/fmt.h index 8e89906ef889..816791cf9227 100644 --- a/sys/include/fmt.h +++ b/sys/include/fmt.h @@ -475,6 +475,15 @@ void print_u64_hex(uint64_t val); */ void print_u64_dec(uint64_t val); +/** + * @brief Print int64 value as decimal to stdout + * + * @note This uses fmt_s64_dec(), which uses ~400b of code. + * + * @param[in] val Value to print + */ +void print_s64_dec(uint64_t val); + /** * @brief Print float value * From 73cd498dba9d4ef1f12c9c6b43e64de8a700f08d Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Wed, 10 Feb 2021 13:40:40 +0100 Subject: [PATCH 2/3] tests/fmt_print: improve test coverage --- tests/fmt_print/main.c | 18 ++++++++++++++++++ tests/fmt_print/tests/01-run.py | 9 +++++++++ 2 files changed, 27 insertions(+) diff --git a/tests/fmt_print/main.c b/tests/fmt_print/main.c index 1b5ecfba274d..15159293a5d5 100644 --- a/tests/fmt_print/main.c +++ b/tests/fmt_print/main.c @@ -25,6 +25,24 @@ int main(void) { print_str("If you can read this:\n"); + print_u32_dec(0xFFFFFFFF); + print_str("\n"); + print_s32_dec(0x80000000); + print_str("\n"); + print_byte_hex(0xFA); + print_str("\n"); + print_s32_dec(0x80000000); + print_str("\n"); + print_u32_hex(0x12345678); + print_str("\n"); + print_u64_hex(0x123456789ABCDEF0); + print_str("\n"); + print_u64_dec(0xFFFFFFFFFFFFFFFF); + print_str("\n"); + print_s64_dec(0x8000000000000000); + print_str("\n"); + print_float(1.2345, 5); + print_str("\n"); print_str("Test successful.\n"); return 0; diff --git a/tests/fmt_print/tests/01-run.py b/tests/fmt_print/tests/01-run.py index 9f6f3d734810..3f69b950a16c 100755 --- a/tests/fmt_print/tests/01-run.py +++ b/tests/fmt_print/tests/01-run.py @@ -6,6 +6,15 @@ def testfunc(child): child.expect_exact('If you can read this:') + child.expect_exact('4294967295') + child.expect_exact('-2147483648') + child.expect_exact('FA') + child.expect_exact('-2147483648') + child.expect_exact('12345678') + child.expect_exact('123456789ABCDEF0') + child.expect_exact('18446744073709551615') + child.expect_exact('-9223372036854775808') + child.expect_exact('1.23450') child.expect_exact('Test successful.') From f22dede3ce172846bcd8917ab1feebcef744ab0b Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Thu, 11 Feb 2021 09:30:46 +0100 Subject: [PATCH 3/3] test/periph_ptp_clock: Remove redundant function --- tests/periph_ptp_clock/main.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tests/periph_ptp_clock/main.c b/tests/periph_ptp_clock/main.c index f3afc03b73b8..22f82464d227 100644 --- a/tests/periph_ptp_clock/main.c +++ b/tests/periph_ptp_clock/main.c @@ -46,16 +46,6 @@ static mutex_t sync_mutex = MUTEX_INIT_LOCKED; static atomic_uint_least64_t timestamp; -static inline void print_s64_dec(int64_t _num) -{ - uint64_t num = _num; - if (_num < 0) { - print_str("-"); - num = -_num; - } - print_u64_dec(num); -} - static void speed_adj_cb(void *arg, int chan) { (void)arg;