some minor float test changes from testing llvm-libc (#3043)
diff --git a/test/pico_float_test/CMakeLists.txt b/test/pico_float_test/CMakeLists.txt
index ac7b5a5..aad51da 100644
--- a/test/pico_float_test/CMakeLists.txt
+++ b/test/pico_float_test/CMakeLists.txt
@@ -62,7 +62,10 @@
pico_set_float_implementation(custom_float_funcs_test_${FLOAT_TYPE} ${FLOAT_TYPE})
target_link_libraries(custom_float_funcs_test_${FLOAT_TYPE} PRIVATE pico_stdlib)
pico_add_extra_outputs(custom_float_funcs_test_${FLOAT_TYPE})
- pico_set_printf_implementation(custom_float_funcs_test_${FLOAT_TYPE} compiler)
+ if (NOT PICO_CLIB STREQUAL "llvm_libc")
+ # raw compiler printf on llvm_libc doesn't currently have floating point
+ pico_set_printf_implementation(custom_float_funcs_test_${FLOAT_TYPE} compiler)
+ endif()
if (PICO_C_COMPILER_IS_GNU)
target_compile_options(custom_float_funcs_test_${FLOAT_TYPE} PRIVATE -Wno-analyzer-use-of-uninitialized-value)
endif()
@@ -79,7 +82,10 @@
target_link_libraries(float_benchmark_${FLOAT_TYPE} PRIVATE pico_stdlib m)
pico_add_extra_outputs(float_benchmark_${FLOAT_TYPE})
target_compile_definitions(float_benchmark_${FLOAT_TYPE} PRIVATE PICO_FLOAT_IN_RAM=1)
- pico_set_printf_implementation(float_benchmark_${FLOAT_TYPE} compiler)
+ if (NOT PICO_CLIB STREQUAL "llvm_libc")
+ # raw compiler printf on llvm_libc doesn't currently have floating point
+ pico_set_printf_implementation(float_benchmark_${FLOAT_TYPE} compiler)
+ endif()
pico_set_binary_type(float_benchmark_${FLOAT_TYPE} copy_to_ram)
endforeach ()
@@ -117,7 +123,10 @@
pico_set_double_implementation(custom_double_funcs_test_${DOUBLE_TYPE} ${DOUBLE_TYPE})
target_link_libraries(custom_double_funcs_test_${DOUBLE_TYPE} PRIVATE pico_stdlib)
pico_add_extra_outputs(custom_double_funcs_test_${DOUBLE_TYPE})
- pico_set_printf_implementation(custom_double_funcs_test_${DOUBLE_TYPE} compiler)
+ if (NOT PICO_CLIB STREQUAL "llvm_libc")
+ # raw compiler printf on llvm_libc doesn't currently have floating point
+ pico_set_printf_implementation(custom_double_funcs_test_${DOUBLE_TYPE} compiler)
+ endif()
if (PICO_C_COMPILER_IS_CLANG)
# llvm by default will treat our out of range float->int conversions as undefined behavior
@@ -133,7 +142,10 @@
target_link_libraries(double_benchmark_${DOUBLE_TYPE} PRIVATE pico_stdlib m)
pico_add_extra_outputs(double_benchmark_${DOUBLE_TYPE})
target_compile_definitions(double_benchmark_${DOUBLE_TYPE} PRIVATE PICO_DOUBLE_IN_RAM=1)
- pico_set_printf_implementation(double_benchmark_${DOUBLE_TYPE} compiler)
+ if (NOT PICO_CLIB STREQUAL "llvm_libc")
+ # raw compiler printf on llvm_libc doesn't currently have floating point
+ pico_set_printf_implementation(double_benchmark_${DOUBLE_TYPE} compiler)
+ endif()
pico_set_binary_type(double_benchmark_${DOUBLE_TYPE} copy_to_ram)
endforeach ()
diff --git a/test/pico_float_test/pico_float_test.c b/test/pico_float_test/pico_float_test.c
index 94544c8..f81a566 100644
--- a/test/pico_float_test/pico_float_test.c
+++ b/test/pico_float_test/pico_float_test.c
@@ -349,8 +349,8 @@
#ifdef LLVM_LIBC_MATH_H
#define isinff isinf
#endif
-#define assert_close(a, b) test_assert((fabsf(a - b) <= allowed_range(a) || ({ printf(" error: %f != %f\n", a, b); 0; })) || (isinff(a) && isinff(b) && (a < 0) == (b < 0)))
-#define assert_close_fma(a, b) test_assert((fabsf(a - b) <= allowed_range_fma(a) || ({ printf(" error: %f != %f\n", a, b); 0; })) || (isinff(a) && isinff(b) && (a < 0) == (b < 0)))
+#define assert_close(a, b) test_assert((isinf(a) && isinf(b) && signbit(a) == signbit(b)) || fabsf((a) - (b)) <= allowed_range(a) || ({ printf(" error: %f != %f\n", a, b); 0; }) || (isinff(a) && isinff(b) && ((a) < 0) == ((b) < 0)))
+#define assert_close_fma(a, b) test_assert((fabsf((a) - (b)) <= allowed_range_fma(a) || ({ printf(" error: %f != %f\n", a, b); 0; })) || (isinff(a) && isinff(b) && ((a) < 0) == ((b) < 0)))
#define check1(func,p0) ({ typeof(p0) r = func(p0), r2 = __CONCAT(__real_, func)(p0); test_assert(r == r2); r; })
#if !LIB_PICO_FLOAT_PICO_VFP
#define check1_vfp_unwrapped(func,p0) ({ typeof(p0) r = func(p0), r2 = __CONCAT(__real_, func)(p0); test_assert(r == r2); r; })
@@ -458,7 +458,7 @@
sincosf(x, &s, &c);
printf("SINCOS %10.18f %10.18f\n", s, c);
if (s != sinf(x) || c != cosf(x)) {
- printf("SINCOS mismatch\n");
+ printf("SINCOS mismatch %10.18f %10.18f\n", sinf(x), cosf(x));
fail = true;
}
}