[PATCH v2 0/4] MR4871: msvcp140_2: Implement __std_smf_hypot3.
-- v2: msvcp140_t/tests: Add __std_smf_hypot3 tests. https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
From: Piotr Caban <piotr(a)codeweavers.com> --- dlls/msvcp140_2/msvcp140_2.spec | 132 +++++++++++++++++++++----------- 1 file changed, 88 insertions(+), 44 deletions(-) diff --git a/dlls/msvcp140_2/msvcp140_2.spec b/dlls/msvcp140_2/msvcp140_2.spec index c59da9aba9c..0c10d213c4b 100644 --- a/dlls/msvcp140_2/msvcp140_2.spec +++ b/dlls/msvcp140_2/msvcp140_2.spec @@ -1,44 +1,88 @@ -@ stub __std_smf_assoc_laguerre -@ stub __std_smf_assoc_laguerref -@ stub __std_smf_assoc_legendre -@ stub __std_smf_assoc_legendref -@ stub __std_smf_beta -@ stub __std_smf_betaf -@ stub __std_smf_comp_ellint_1 -@ stub __std_smf_comp_ellint_1f -@ stub __std_smf_comp_ellint_2 -@ stub __std_smf_comp_ellint_2f -@ stub __std_smf_comp_ellint_3 -@ stub __std_smf_comp_ellint_3f -@ stub __std_smf_cyl_bessel_i -@ stub __std_smf_cyl_bessel_if -@ stub __std_smf_cyl_bessel_j -@ stub __std_smf_cyl_bessel_jf -@ stub __std_smf_cyl_bessel_k -@ stub __std_smf_cyl_bessel_kf -@ stub __std_smf_cyl_neumann -@ stub __std_smf_cyl_neumannf -@ stub __std_smf_ellint_1 -@ stub __std_smf_ellint_1f -@ stub __std_smf_ellint_2 -@ stub __std_smf_ellint_2f -@ stub __std_smf_ellint_3 -@ stub __std_smf_ellint_3f -@ stub __std_smf_expint -@ stub __std_smf_expintf -@ stub __std_smf_hermite -@ stub __std_smf_hermitef -@ stub __std_smf_hypot3 -@ stub __std_smf_hypot3f -@ stub __std_smf_laguerre -@ stub __std_smf_laguerref -@ stub __std_smf_legendre -@ stub __std_smf_legendref -@ stub __std_smf_riemann_zeta -@ stub __std_smf_riemann_zetaf -@ stub __std_smf_sph_bessel -@ stub __std_smf_sph_besself -@ stub __std_smf_sph_legendre -@ stub __std_smf_sph_legendref -@ stub __std_smf_sph_neumann -@ stub __std_smf_sph_neumannf +@ stub -arch=i386 ___std_smf_assoc_laguerre(a)16 +@ stub -arch=!i386 __std_smf_assoc_laguerre +@ stub -arch=i386 ___std_smf_assoc_laguerref(a)12 +@ stub -arch=!i386 __std_smf_assoc_laguerref +@ stub -arch=i386 ___std_smf_assoc_legendre(a)16 +@ stub -arch=!i386 __std_smf_assoc_legendre +@ stub -arch=i386 ___std_smf_assoc_legendref(a)12 +@ stub -arch=!i386 __std_smf_assoc_legendref +@ stub -arch=i386 ___std_smf_beta(a)16 +@ stub -arch=!i386 __std_smf_beta +@ stub -arch=i386 ___std_smf_betaf(a)8 +@ stub -arch=!i386 __std_smf_betaf +@ stub -arch=i386 ___std_smf_comp_ellint_1(a)8 +@ stub -arch=!i386 __std_smf_comp_ellint_1 +@ stub -arch=i386 ___std_smf_comp_ellint_1f(a)4 +@ stub -arch=!i386 __std_smf_comp_ellint_1f +@ stub -arch=i386 ___std_smf_comp_ellint_2(a)8 +@ stub -arch=!i386 __std_smf_comp_ellint_2 +@ stub -arch=i386 ___std_smf_comp_ellint_2f(a)4 +@ stub -arch=!i386 __std_smf_comp_ellint_2f +@ stub -arch=i386 ___std_smf_comp_ellint_3(a)16 +@ stub -arch=!i386 __std_smf_comp_ellint_3 +@ stub -arch=i386 ___std_smf_comp_ellint_3f(a)8 +@ stub -arch=!i386 __std_smf_comp_ellint_3f +@ stub -arch=i386 ___std_smf_cyl_bessel_i(a)16 +@ stub -arch=!i386 __std_smf_cyl_bessel_i +@ stub -arch=i386 ___std_smf_cyl_bessel_if(a)8 +@ stub -arch=!i386 __std_smf_cyl_bessel_if +@ stub -arch=i386 ___std_smf_cyl_bessel_j(a)16 +@ stub -arch=!i386 __std_smf_cyl_bessel_j +@ stub -arch=i386 ___std_smf_cyl_bessel_jf(a)8 +@ stub -arch=!i386 __std_smf_cyl_bessel_jf +@ stub -arch=i386 ___std_smf_cyl_bessel_k(a)16 +@ stub -arch=!i386 __std_smf_cyl_bessel_k +@ stub -arch=i386 ___std_smf_cyl_bessel_kf(a)8 +@ stub -arch=!i386 __std_smf_cyl_bessel_kf +@ stub -arch=i386 ___std_smf_cyl_neumann(a)16 +@ stub -arch=!i386 __std_smf_cyl_neumann +@ stub -arch=i386 ___std_smf_cyl_neumannf(a)8 +@ stub -arch=!i386 __std_smf_cyl_neumannf +@ stub -arch=i386 ___std_smf_ellint_1(a)16 +@ stub -arch=!i386 __std_smf_ellint_1 +@ stub -arch=i386 ___std_smf_ellint_1f(a)8 +@ stub -arch=!i386 __std_smf_ellint_1f +@ stub -arch=i386 ___std_smf_ellint_2(a)16 +@ stub -arch=!i386 __std_smf_ellint_2 +@ stub -arch=i386 ___std_smf_ellint_2f(a)8 +@ stub -arch=!i386 __std_smf_ellint_2f +@ stub -arch=i386 ___std_smf_ellint_3(a)24 +@ stub -arch=!i386 __std_smf_ellint_3 +@ stub -arch=i386 ___std_smf_ellint_3f(a)12 +@ stub -arch=!i386 __std_smf_ellint_3f +@ stub -arch=i386 ___std_smf_expint(a)8 +@ stub -arch=!i386 __std_smf_expint +@ stub -arch=i386 ___std_smf_expintf(a)4 +@ stub -arch=!i386 __std_smf_expintf +@ stub -arch=i386 ___std_smf_hermite(a)12 +@ stub -arch=!i386 __std_smf_hermite +@ stub -arch=i386 ___std_smf_hermitef(a)8 +@ stub -arch=!i386 __std_smf_hermitef +@ stub -arch=i386 ___std_smf_hypot3(a)24 +@ stub -arch=!i386 __std_smf_hypot3 +@ stub -arch=i386 ___std_smf_hypot3f(a)12 +@ stub -arch=!i386 __std_smf_hypot3f +@ stub -arch=i386 ___std_smf_laguerre(a)12 +@ stub -arch=!i386 __std_smf_laguerre +@ stub -arch=i386 ___std_smf_laguerref(a)8 +@ stub -arch=!i386 __std_smf_laguerref +@ stub -arch=i386 ___std_smf_legendre(a)12 +@ stub -arch=!i386 __std_smf_legendre +@ stub -arch=i386 ___std_smf_legendref(a)8 +@ stub -arch=!i386 __std_smf_legendref +@ stub -arch=i386 ___std_smf_riemann_zeta(a)8 +@ stub -arch=!i386 __std_smf_riemann_zeta +@ stub -arch=i386 ___std_smf_riemann_zetaf(a)4 +@ stub -arch=!i386 __std_smf_riemann_zetaf +@ stub -arch=i386 ___std_smf_sph_bessel(a)12 +@ stub -arch=!i386 __std_smf_sph_bessel +@ stub -arch=i386 ___std_smf_sph_besself(a)8 +@ stub -arch=!i386 __std_smf_sph_besself +@ stub -arch=i386 ___std_smf_sph_legendre(a)16 +@ stub -arch=!i386 __std_smf_sph_legendre +@ stub -arch=i386 ___std_smf_sph_legendref(a)12 +@ stub -arch=!i386 __std_smf_sph_legendref +@ stub -arch=i386 ___std_smf_sph_neumann(a)12 +@ stub -arch=!i386 __std_smf_sph_neumann +@ stub -arch=i386 ___std_smf_sph_neumannf(a)8 +@ stub -arch=!i386 __std_smf_sph_neumannf -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
From: Alex Henrie <alexhenrie24(a)gmail.com> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56078 --- dlls/msvcp140_2/Makefile.in | 3 +++ dlls/msvcp140_2/math.c | 26 ++++++++++++++++++++++++++ dlls/msvcp140_2/msvcp140_2.spec | 4 ++-- 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 dlls/msvcp140_2/math.c diff --git a/dlls/msvcp140_2/Makefile.in b/dlls/msvcp140_2/Makefile.in index 5b4865db844..0f75819198f 100644 --- a/dlls/msvcp140_2/Makefile.in +++ b/dlls/msvcp140_2/Makefile.in @@ -1 +1,4 @@ MODULE = msvcp140_2.dll + +SOURCES = \ + math.c diff --git a/dlls/msvcp140_2/math.c b/dlls/msvcp140_2/math.c new file mode 100644 index 00000000000..d2909745a9d --- /dev/null +++ b/dlls/msvcp140_2/math.c @@ -0,0 +1,26 @@ +/* + * Special math functions + * + * Copyright 2024 Alex Henrie + * + * 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 <math.h> + +double __stdcall __std_smf_hypot3(double x, double y, double z) +{ + return hypot(hypot(x, y), z); +} diff --git a/dlls/msvcp140_2/msvcp140_2.spec b/dlls/msvcp140_2/msvcp140_2.spec index 0c10d213c4b..fbc63fa5e28 100644 --- a/dlls/msvcp140_2/msvcp140_2.spec +++ b/dlls/msvcp140_2/msvcp140_2.spec @@ -58,8 +58,8 @@ @ stub -arch=!i386 __std_smf_hermite @ stub -arch=i386 ___std_smf_hermitef(a)8 @ stub -arch=!i386 __std_smf_hermitef -@ stub -arch=i386 ___std_smf_hypot3(a)24 -@ stub -arch=!i386 __std_smf_hypot3 +@ stdcall -arch=i386 ___std_smf_hypot3(a)24(double double double) __std_smf_hypot3 +@ stdcall -arch=!i386 __std_smf_hypot3(double double double) @ stub -arch=i386 ___std_smf_hypot3f(a)12 @ stub -arch=!i386 __std_smf_hypot3f @ stub -arch=i386 ___std_smf_laguerre(a)12 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
From: Piotr Caban <piotr(a)codeweavers.com> --- dlls/msvcp140_2/math.c | 5 +++++ dlls/msvcp140_2/msvcp140_2.spec | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dlls/msvcp140_2/math.c b/dlls/msvcp140_2/math.c index d2909745a9d..aa8726d6b3e 100644 --- a/dlls/msvcp140_2/math.c +++ b/dlls/msvcp140_2/math.c @@ -24,3 +24,8 @@ double __stdcall __std_smf_hypot3(double x, double y, double z) { return hypot(hypot(x, y), z); } + +float __stdcall __std_smf_hypot3f(float x, float y, float z) +{ + return hypotf(hypotf(x, y), z); +} diff --git a/dlls/msvcp140_2/msvcp140_2.spec b/dlls/msvcp140_2/msvcp140_2.spec index fbc63fa5e28..bcc3ecfa7fd 100644 --- a/dlls/msvcp140_2/msvcp140_2.spec +++ b/dlls/msvcp140_2/msvcp140_2.spec @@ -60,8 +60,8 @@ @ stub -arch=!i386 __std_smf_hermitef @ stdcall -arch=i386 ___std_smf_hypot3(a)24(double double double) __std_smf_hypot3 @ stdcall -arch=!i386 __std_smf_hypot3(double double double) -@ stub -arch=i386 ___std_smf_hypot3f(a)12 -@ stub -arch=!i386 __std_smf_hypot3f +@ stdcall -arch=i386 ___std_smf_hypot3f(a)12(float float float) __std_smf_hypot3f +@ stdcall -arch=!i386 __std_smf_hypot3f(float float float) @ stub -arch=i386 ___std_smf_laguerre(a)12 @ stub -arch=!i386 __std_smf_laguerre @ stub -arch=i386 ___std_smf_laguerref(a)8 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
From: Piotr Caban <piotr(a)codeweavers.com> --- configure.ac | 1 + dlls/msvcp140_2/tests/Makefile.in | 4 ++ dlls/msvcp140_2/tests/math.c | 81 +++++++++++++++++++++++++++++++ 3 files changed, 86 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..dc61d9b6db2 --- /dev/null +++ b/dlls/msvcp140_2/tests/math.c @@ -0,0 +1,81 @@ +/* + * 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(a)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) +{ + if (!init()) + return; + + test_hypot3(); +} -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
Alex Henrie (@alexhenrie) commented about dlls/msvcp140_2/math.c:
+/* + * Special math functions + * + * Copyright 2024 Alex Henrie You can put your own name here, my original code has been completely replaced by your improved version. Thank you for working on this!
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4871#note_57984
This merge request was approved by Piotr Caban. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4871
participants (4)
-
Alex Henrie -
Alex Henrie (@alexhenrie) -
Piotr Caban -
Piotr Caban (@piotr)