From e747ded84cafe391e47cbb1038654f937dae22ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radek=20Barto=C5=88?= Date: Wed, 25 Oct 2023 14:36:46 +0200 Subject: [PATCH] 64bit long double tests --- .gitignore | 3 +- build.sh | 8 +++--- tests/build-tests.sh | 21 +++++++------- tests/test-math.c | 65 ++++++++++++++++++++++++++------------------ 4 files changed, 54 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 12ab17eb4..7e0824233 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -build-aarch64-w64-mingw32/ +.vscode/ +build-*/ code/ downloads/ *.exe diff --git a/build.sh b/build.sh index 82b8f4f0e..8050dc8d8 100755 --- a/build.sh +++ b/build.sh @@ -15,7 +15,7 @@ BINUTILS_BRANCH=${BINUTILS_BRANCH:-woarm64} BINUTILS_VERSION=binutils-master GCC_REPO=https://github.com/ZacWalk/gcc-woarm64.git -GCC_BRANCH=${GCC_BRANCH:-woarm64} +GCC_BRANCH=${GCC_BRANCH:-long-double-64} # GCC_VERSION=gcc-12.2.0 GCC_VERSION=gcc-master @@ -32,7 +32,7 @@ MSYS2_CONFIG=1 TARGET=$TARGET_ARCH-w64-mingw32 # TARGET=$TARGET_ARCH-pc-cygwin BUILD_DIR=build-$TARGET -PARALLEL_MAKE=-j6 +PARALLEL_MAKE=-j$(nproc) MPFR_VERSION=mpfr-4.1.0 GMP_VERSION=gmp-6.2.1 MPC_VERSION=mpc-1.2.1 @@ -173,7 +173,7 @@ build_mingw_headers() { echo "==== build mingw headers" cd $BUILD_DIR/mingw-headers - make + make $PARALLEL_MAKE make install cd ../.. # Symlink for gcc @@ -228,7 +228,7 @@ build_mingw_libs() { echo "==== build mingw libs" cd $BUILD_DIR/mingw - make + make $PARALLEL_MAKE make install cd ../.. } diff --git a/tests/build-tests.sh b/tests/build-tests.sh index e329cc720..c0ce6cb9d 100755 --- a/tests/build-tests.sh +++ b/tests/build-tests.sh @@ -1,22 +1,21 @@ -rm *.s *.dump *.gkd *.exe *.dll *.log +rm -f *.s *.dump *.gkd *.exe *.dll *.log ~/cross/bin/aarch64-w64-mingw32-g++ -S test-bigdata.cpp -o test-bigdata.s -fdump-final-insns ~/cross/bin/aarch64-w64-mingw32-g++ -S test-throw.cpp -o test-throw.s -fdump-final-insns -~/cross/bin/aarch64-w64-mingw32-g++ -S test-iostream.cpp -o test-iostream.cpp.s -fdump-final-insns +~/cross/bin/aarch64-w64-mingw32-g++ -S test-iostream.cpp -o test-iostream.s -fdump-final-insns ~/cross/bin/aarch64-w64-mingw32-gcc -S test-math.c -o test-math.c.s -fdump-final-insns -~/cross/bin/aarch64-w64-mingw32-gcc -S test-pdata.c -o test-pdata.s -fdump-final-insns -~/cross/bin/aarch64-w64-mingw32-gcc -S test-struct.c -o test-struct.s -fdump-final-insns +~/cross/bin/aarch64-w64-mingw32-gcc -S test-pdata.c -o test-pdata.c.s -fdump-final-insns +~/cross/bin/aarch64-w64-mingw32-gcc -S test-struct.c -o test-struct.c.s -fdump-final-insns ~/cross/bin/aarch64-w64-mingw32-g++ -g test-bigdata.cpp -o test-bigdata.exe >> test-bigdata.log ~/cross/bin/aarch64-w64-mingw32-g++ -g test-throw.cpp -o test-throw.exe >> test-throw.log ~/cross/bin/aarch64-w64-mingw32-g++ -g test-iostream.cpp -o test-iostream.exe >> test-iostream.log ~/cross/bin/aarch64-w64-mingw32-gcc -g test-math.c -o test-math.c.exe >> test-math.c.log -~/cross/bin/aarch64-w64-mingw32-gcc -g test-pdata.c -ldbghelp -o test-pdata.exe >> test-pdata.log -~/cross/bin/aarch64-w64-mingw32-gcc -g test-struct.c -o test-struct.exe >> test-struct.log -~/cross/bin/aarch64-w64-mingw32-gcc -g test-math.c -o test-math.exe >> test-math.log -~/cross/bin/aarch64-w64-mingw32-gcc -g test-varargs.c -o test-varargs.exe >> test-varargs.log -~/cross/bin/aarch64-w64-mingw32-gcc -g test-sjlj.c -o test-sjlj.exe >> test-sjlj.log -~/cross/bin/aarch64-w64-mingw32-gcc -g -fopenmp test-omp.c -o test-omp.exe >> test-omp.log +~/cross/bin/aarch64-w64-mingw32-gcc -g test-pdata.c -ldbghelp -o test-pdata.c.exe >> test-pdata.c.log +~/cross/bin/aarch64-w64-mingw32-gcc -g test-struct.c -o test-struct.c.exe >> test-struct.c.log +~/cross/bin/aarch64-w64-mingw32-gcc -g test-varargs.c -o test-varargs.c.exe >> test-varargs.c.log +~/cross/bin/aarch64-w64-mingw32-gcc -g test-sjlj.c -o test-sjlj.c.exe >> test-sjlj.c.log +~/cross/bin/aarch64-w64-mingw32-gcc -g -fopenmp test-omp.c -o test-omp.c.exe >> test-omp.c.log # # DLL examples @@ -38,6 +37,6 @@ rm *.s *.dump *.gkd *.exe *.dll *.log ~/cross/bin/aarch64-w64-mingw32-objdump -dr test-throw.exe >> test-throw.dump ~/cross/bin/aarch64-w64-mingw32-objdump -dr test-dll-auto.exe >> test-dll-auto.dump ~/cross/bin/aarch64-w64-mingw32-objdump -dr test-dll-export.exe >> test-dll-export.dump -~/cross/bin/aarch64-w64-mingw32-objdump -dr test-struct.exe >> test-struct.dump +~/cross/bin/aarch64-w64-mingw32-objdump -dr test-struct.c.exe >> test-struct.c.dump diff --git a/tests/test-math.c b/tests/test-math.c index 63c63767e..ab13193ae 100644 --- a/tests/test-math.c +++ b/tests/test-math.c @@ -1,38 +1,49 @@ +#include +#include #include +#include -_Float128 foo (_Float128 x) +// Source: https://cpufun.substack.com/p/portable-support-for-128b-floats +#define M_E_LD 2.718281828459045235360287471352662498L + +#define assert_sizeof(type, size) \ + printf ("expected: sizeof(%s) == %d\n", #type, size); \ + printf ("actual: sizeof(%s) == %d\n", #type, sizeof (type)); \ + assert (sizeof (type) == size); + +void assert_snprintf(const char* expected, const char* format, ...) { - _Complex _Float128 z1, z2; + va_list list; + va_start (list, format); - z1 = x; - z2 = x / 7.F128; - z2 /= z1; + const int SIZE = 1024; + char actual[SIZE]; + snprintf (actual, SIZE, format, list); + printf ("expected: %s\n", expected); + printf ("actual: %s\n", actual); + assert (strncmp (expected, actual, SIZE) == 0); - return (_Float128) z2; + va_end(list); } -_Float128 bar (_Float128 x) +int main() { - return x * __builtin_huge_valf128 (); -} + assert_sizeof (float, 4); + assert_sizeof (double, 8); + assert_sizeof (long double, 8); -_Float128 baz (_Float128 x) -{ - return x * __builtin_huge_valf128 (); -} + float f = 1.23456f; + double d = 1.23456; + long double ld = M_E_LD; + assert_snprintf ("float %g => 1.23456", "float %%g => %g", f); + assert_snprintf ("double %g => 1.23456", "double %%g => %g", d); + assert_snprintf ("long double %g => 2.71828", "long double %%g => %g", ld); + assert_snprintf ("long double %Lg => 2.71828", "long double %%Lg => %Lg", ld); + assert_snprintf ("long double %qg => 2.71828", "long double %%qg => %qg", ld); + assert_snprintf ("long double %Qg => 2.71828", "long double %%Qg => %Qg", ld); -int main() -{ - foo (1.2Q); - bar (1.2Q); - foo (1.2F128); - bar (1.2F128); - baz (1.2F128); - foo (1.2Q); - bar (1.2Q); - baz (1.2Q); - - printf("ok\n"); - return 0; -} \ No newline at end of file + printf ("ok\n"); + + return 0; +}