Skip to content

Commit

Permalink
64bit long double tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackhex committed Oct 29, 2023
1 parent 217e85e commit e747ded
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build-aarch64-w64-mingw32/
.vscode/
build-*/
code/
downloads/
*.exe
Expand Down
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -228,7 +228,7 @@ build_mingw_libs()
{
echo "==== build mingw libs"
cd $BUILD_DIR/mingw
make
make $PARALLEL_MAKE
make install
cd ../..
}
Expand Down
21 changes: 10 additions & 11 deletions tests/build-tests.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


65 changes: 38 additions & 27 deletions tests/test-math.c
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

_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;
}
printf ("ok\n");

return 0;
}

0 comments on commit e747ded

Please sign in to comment.