From: Piotr Caban piotr@codeweavers.com
--- configure.ac | 1 + dlls/msvcp140_2/tests/Makefile.in | 4 ++ dlls/msvcp140_2/tests/math.c | 80 +++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 dlls/msvcp140_2/tests/Makefile.in create mode 100644 dlls/msvcp140_2/tests/math.c
diff --git a/configure.ac b/configure.ac index 9488b3263cc..da661323375 100644 --- a/configure.ac +++ b/configure.ac @@ -2876,6 +2876,7 @@ WINE_CONFIG_MAKEFILE(dlls/msvcp140/tests) WINE_CONFIG_MAKEFILE(dlls/msvcp140_1) WINE_CONFIG_MAKEFILE(dlls/msvcp140_1/tests) WINE_CONFIG_MAKEFILE(dlls/msvcp140_2) +WINE_CONFIG_MAKEFILE(dlls/msvcp140_2/tests) WINE_CONFIG_MAKEFILE(dlls/msvcp140_atomic_wait) WINE_CONFIG_MAKEFILE(dlls/msvcp140_atomic_wait/tests) WINE_CONFIG_MAKEFILE(dlls/msvcp140_codecvt_ids) diff --git a/dlls/msvcp140_2/tests/Makefile.in b/dlls/msvcp140_2/tests/Makefile.in new file mode 100644 index 00000000000..3024ebdd358 --- /dev/null +++ b/dlls/msvcp140_2/tests/Makefile.in @@ -0,0 +1,4 @@ +TESTDLL = msvcp140_2.dll + +SOURCES = \ + math.c diff --git a/dlls/msvcp140_2/tests/math.c b/dlls/msvcp140_2/tests/math.c new file mode 100644 index 00000000000..0e2a28a981f --- /dev/null +++ b/dlls/msvcp140_2/tests/math.c @@ -0,0 +1,80 @@ +/* + * Special math functions + * + * Copyright 2024 Piotr Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "wine/test.h" +#include <math.h> + +static double (__stdcall *p___std_smf_hypot3)(double x, double y, double z); + +#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp, y) +#define SET(x,y) do { SETNOFAIL(x, y); ok(x != NULL, "Export '%s' not found\n", y); } while(0) +static BOOL init(void) +{ + HMODULE msvcp = LoadLibraryA("msvcp140_2.dll"); + + if (!msvcp) + { + win_skip("msvcp140_2.dll not installed\n"); + return FALSE; + } + +#ifdef __i386__ + SET(p___std_smf_hypot3, "___std_smf_hypot3@24"); +#else + SET(p___std_smf_hypot3, "__std_smf_hypot3"); +#endif + + return TRUE; +} + +static inline BOOL compare_double(double f, double g, unsigned int ulps) +{ + ULONGLONG x = *(ULONGLONG *)&f; + ULONGLONG y = *(ULONGLONG *)&g; + + if (f < 0) + x = ~x + 1; + else + x |= ((ULONGLONG)1) << 63; + if (g < 0) + y = ~y + 1; + else + y |= ((ULONGLONG)1) << 63; + + return (x > y ? x - y : y - x) <= ulps; +} + +static void test_hypot3(void) +{ + double r; + + r = p___std_smf_hypot3(0, 0, 0); + ok(compare_double(r, 0.0, 1), "r = %.23e\n", r); + + r = p___std_smf_hypot3(9, 12, 20); + ok(compare_double(r, 25.0, 1), "r = %.23e\n", r); +} + +START_TEST(math) +{ + init(); + + test_hypot3(); +}