more minor test fixups to pass on all platforms
diff --git a/test/pico_float_test/pico_double_test.c b/test/pico_float_test/pico_double_test.c index a0959fe..459a4bd 100644 --- a/test/pico_float_test/pico_double_test.c +++ b/test/pico_float_test/pico_double_test.c
@@ -329,7 +329,7 @@ #define FRAC ((double)(1ull << 50)) #define allowed_range(a) (fabs(a) / FRAC) -#define assert_close(a, b) test_assert((fabs(a - b) <= allowed_range(a) || ({ printf(" error: %f != %f\n", a, b); 0; })) || (isinf(a) && isinf(b) && (a < 0) == (b < 0))) +#define assert_close(a, b) test_assert((fabs((a) - (b)) <= allowed_range(a) || ({ printf(" error: %f != %f\n", a, b); 0; })) || (isinf(a) && isinf(b) && ((a) < 0) == ((b) < 0))) #define check1(func,p0) ({ typeof(p0) r = func(p0), r2 = __CONCAT(__real_, func)(p0); test_assert(r == r2); r; }) #define check2(func,p0,p1) ({ typeof(p0) r = func(p0,p1), r2 = __CONCAT(__real_, func)(p0,p1); test_assert(r == r2); r; }) #define check_close1(func,p0) ({ typeof(p0) r = func(p0), r2 = __CONCAT(__real_, func)(p0); if (isnan(p0)) assert_nan(r); else assert_close(r, r2); r; }) @@ -367,7 +367,7 @@ for (double x = 0; x < 3; x++) { printf("\n ----- %g\n", x); printf("SQRT %10.18g\n", check_close1(sqrt, x)); -#if PICO_RP2350 && !LIB_PICO_DOUBLE_COMPILER +#if PICO_DOUBLE_HAS_SQRT_FAST printf("SQRT_FAST %10.18g\n", check_close1(sqrt_fast, x)); #endif printf("COS %10.18g\n", check_close1(cos, x)); @@ -442,10 +442,9 @@ for (double a = -100.0; a < 100.0; a += 53.103) { for (double b = -2000000.0; b < 1000000.0; b += 397243.5) { for (double c = -700.0; c < 1000.0; c += 287.4) { - printf("fma %f %f %f\n", a, b, c); - check_close3(fma, a, b, c); -#if PICO_RP2350 && !LIB_PICO_DOUBLE_COMPILER - check_close3(fma_fast, a, b, c); + printf("FMA %f\n", check_close3(fma, a, b, c)); +#if PICO_DOUBLE_HAS_FMA_FAST + printf("FMAFAST %f\n", check_close3(fma, a, b, c)); #endif } } @@ -531,7 +530,7 @@ x - 0.377777777777777777777777777777, g, 123456789.0 / x); check2(__aeabi_dmul, x, x); check2(__aeabi_ddiv, 1.0, x); -#if PICO_RP2350 && !LIB_PICO_DOUBLE_COMPILER +#if PICO_DOUBLE_HAS_DDIV_FAST check2(ddiv_fast, 1.0, x); #endif }
diff --git a/test/pico_float_test/pico_float_test.c b/test/pico_float_test/pico_float_test.c index 5296a79..c38cec9 100644 --- a/test/pico_float_test/pico_float_test.c +++ b/test/pico_float_test/pico_float_test.c
@@ -311,7 +311,7 @@ int64_t __attribute__((pcs("aapcs"))) __aeabi_f2lz(float); float __attribute__((pcs("aapcs"))) __aeabi_fmul(float, float); float __attribute__((pcs("aapcs"))) __aeabi_fdiv(float, float); -#if LIB_PICO_FLOAT_PICO +#if !LIB_PICO_FLOAT_COMPILER #if !LIB_PICO_FLOAT_PICO_VFP float __attribute__((pcs("aapcs"))) __real___aeabi_i2f(int); float __attribute__((pcs("aapcs"))) __real___aeabi_ui2f(int); @@ -321,9 +321,9 @@ float __attribute__((pcs("aapcs"))) __real___aeabi_fdiv(float, float); int32_t __attribute__((pcs("aapcs"))) __real___aeabi_f2iz(float); int64_t __attribute__((pcs("aapcs"))) __real___aeabi_f2lz(float); +#endif float __real_sqrtf(float); float __real_fmaf(float, float, float); -#endif float __real_cosf(float); float __real_sinf(float); float __real_tanf(float); @@ -421,6 +421,7 @@ #if 1 for (float x = 0; x < 3; x++) { printf("\n ----- %f\n", x); + // not replaced in this version #if !LIB_PICO_FLOAT_PICO_VFP printf("FSQRT %10.18f\n", check_close1(sqrtf, x)); #endif @@ -435,9 +436,8 @@ printf("FEXP %10.18f\n", check_close1(expf, x)); printf("FLN %10.18f\n", check_close1(logf, x)); printf("POWF %10.18f\n", check_close2(powf, x, x)); - // todo clang why does this not compile? -#ifndef __clang__ - printf("TRUNCF %10.18f\n", check_close1(truncf, x)); +#if !(__clang__ && __PICOLIBC__) // seems to be a buf with wrapping the extern inline trunc + printf("TRUNCF %10.18f\n", check1(truncf, x)); #endif printf("LDEXPF %10.18f\n", check_close2(ldexpf, x, x)); printf("FMODF %10.18f\n", check_close2(fmodf, x, 3.0f)); @@ -561,17 +561,17 @@ } for(float x = 4294967296.f * 4294967296.f * 2.f; x>=0.5f; x/=2.f) { printf("f2i64 %f->%lld\n", x, (int64_t)x); -#if PICO_RP2040 if ((double)x >= (double)INT64_MAX) { #if TEST_SATURATION test_assert(__aeabi_f2lz(x) == INT64_MAX); #endif } else { +#if PICO_RP2040 check1(__aeabi_f2lz, x); - } #else - check1_vfp_unwrapped(__aeabi_f2lz, x); + check1_vfp_unwrapped(__aeabi_f2lz, x); #endif + } } for(float x = -4294967296.f * 4294967296.f; x<=-0.5f; x/=2.f) { printf("f2i32 %f->%d\n", x, (int32_t)x); @@ -579,17 +579,17 @@ } for(float x = 4294967296.f * 4294967296.f; x>=0.5f; x/=2.f) { printf("f2i32 %f->%d\n", x, (int32_t)x); -#if PICO_RP2040 if ((double)x >= (double)INT32_MAX) { #if TEST_SATURATION test_assert(__aeabi_f2iz(x) == INT32_MAX); #endif } else { +#if PICO_RP2040 check1(__aeabi_f2iz, x); - } #else - check1_vfp_unwrapped(__aeabi_f2iz, x); + check1_vfp_unwrapped(__aeabi_f2iz, x); #endif + } } for (float x = 1; x < 11; x += 2) {