diff --git a/pkg/tinycbor/patches/0001-fix-pretty-fix-compilation-with-newlib-and-GCC-13.2..patch b/pkg/tinycbor/patches/0001-fix-pretty-fix-compilation-with-newlib-and-GCC-13.2..patch new file mode 100644 index 0000000000..03f82a6691 Binary files /dev/null and b/pkg/tinycbor/patches/0001-fix-pretty-fix-compilation-with-newlib-and-GCC-13.2..patch differ diff --git a/sys/matstat/matstat.c b/sys/matstat/matstat.c index a39aee19cc..55f344b778 100644 --- a/sys/matstat/matstat.c +++ b/sys/matstat/matstat.c @@ -53,8 +53,15 @@ uint64_t matstat_variance(const matstat_state_t *state) return 0; } uint64_t variance = state->sum_sq / (state->count - 1); +#ifdef PRIu64 DEBUG("Var: (%" PRIu64 " / (%" PRId32 " - 1)) = %" PRIu64 "\n", state->sum_sq, state->count, variance); +#else + DEBUG("Var: (%" PRIu32 "%s / (%" PRId32 " - 1)) = %" PRIu32 "%s\n", + (uint32_t)state->sum_sq, (state->sum_sq > UINT32_MAX) ? "!trunc " : "", + state->count, + (uint32_t)variance, (variance > UINT32_MAX) ? "!trunc " : ""); +#endif return variance; } diff --git a/tests/unittests/tests-div/tests-div.c b/tests/unittests/tests-div/tests-div.c index 699de4874a..30e4e908ed 100644 --- a/tests/unittests/tests-div/tests-div.c +++ b/tests/unittests/tests-div/tests-div.c @@ -7,6 +7,7 @@ */ #include +#include #include "embUnit.h" #include "tests-div.h" @@ -78,7 +79,13 @@ static void test_div_u64_by_15625(void) } for (unsigned i = 0; i < N_U64_VALS; i++) { +#ifdef PRIu64 DEBUG("Dividing %12"PRIu64" by 15625...\n", u64_test_values[i]); +#else + DEBUG("Dividing %12"PRIu32"%s by 15625...\n", (uint32_t)u64_test_values[i], + ((uint32_t)u64_test_values[i] != u64_test_values[i]) ? "!trunc" : ""); +#endif + TEST_ASSERT_EQUAL_INT( (uint64_t)u64_test_values[i] / 15625, div_u64_by_15625(u64_test_values[i])); @@ -105,7 +112,12 @@ static void test_div_u64_by_1000000(void) } for (unsigned i = 0; i < N_U64_VALS; i++) { +#ifdef PRIu64 DEBUG("Dividing %"PRIu64" by 1000000...\n", u64_test_values[i]); +#else + DEBUG("Dividing %"PRIu32"%s by 1000000...\n", (uint32_t)u64_test_values[i], + ((uint32_t)u64_test_values[i] != u64_test_values[i]) ? "!trunc" : ""); +#endif TEST_ASSERT_EQUAL_INT( u64_test_values[i] / 1000000lu, div_u64_by_1000000(u64_test_values[i])); @@ -122,7 +134,12 @@ static void test_div_u64_by_15625div512(void) } for (unsigned i = 0; i < N_U64_VALS; i++) { +#ifdef PRIu64 DEBUG("Dividing %"PRIu64" by (15625/512)...\n", u64_test_values[i]); +#else + DEBUG("Dividing %"PRIu32"%s by (15625/512)...\n", (uint32_t)u64_test_values[i], + ((uint32_t)u64_test_values[i] != u64_test_values[i]) ? "!trunc" : ""); +#endif TEST_ASSERT_EQUAL_INT( u64_15625_512_expected_values[i], div_u64_by_15625div512(u64_test_values[i])); diff --git a/tests/unittests/tests-frac/tests-frac.c b/tests/unittests/tests-frac/tests-frac.c index 7236ac61e4..df362b1726 100644 --- a/tests/unittests/tests-frac/tests-frac.c +++ b/tests/unittests/tests-frac/tests-frac.c @@ -6,13 +6,12 @@ * directory for more details. */ +#include #include #include "embUnit.h" #include "tests-frac.h" -#include "kernel_defines.h" #include "frac.h" -#include "div.h" #define ENABLE_DEBUG 0 #include "debug.h" @@ -120,11 +119,21 @@ static void test_frac_scale32(void) uint32_t actual = frac_scale(&frac, u32_test_values[i]); if ((uint32_t)expected != actual) { int32_t diff = actual - expected; +#ifdef PRIu64 DEBUG("%" PRIu32 " * (%" PRIu32 " / %" PRIu32 ")" " tmp %" PRIu64 " expect %" PRIu32 ", actual %" PRIu32 ", diff = %" PRId32 " shift=%u\n", u32_test_values[i], num, den, tmp, (uint32_t)expected, actual, diff, frac.shift); +#else + DEBUG("%" PRIu32 " * (%" PRIu32 " / %" PRIu32 ")" + " tmp %" PRIu32"%s expect %" PRIu32 ", actual %" PRIu32 + ", diff = %" PRId32 " shift=%u\n", + u32_test_values[i], num, den, + (uint32_t)tmp, ((uint32_t)tmp != tmp) ? "!trunc" : "", + (uint32_t)expected, + actual, diff, frac.shift); +#endif /* The frac algorithm sacrifices accuracy for speed, * some large numbers will be incorrectly rounded,