[PATCH v3] ucrtbase: added function implementation for get_FMA3_enable and set_FMA3_enable
Rosa Hase
daxcore at online.de
Sun Feb 2 09:51:44 CST 2020
From: daxcore <daxcore at online.de>
replaced the stub with a real implementation for FMA3_enable
Proton-Bug: https://github.com/ValveSoftware/Proton/issues/3227
Signed-off-by: Rosa Hase <daxcore at online.de>
---
v2: also implemented the set_FMA3_enable function.
v3: added the preprocessor checks
---
.../api-ms-win-crt-math-l1-1-0.spec | 2 +-
dlls/msvcr120/msvcr120.spec | 1 +
dlls/msvcrt/math.c | 26 +++++++++++++++++--
dlls/ucrtbase/ucrtbase.spec | 2 +-
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
index cb8fdc9227..579b97fee3 100644
--- a/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
+++ b/dlls/api-ms-win-crt-math-l1-1-0/api-ms-win-crt-math-l1-1-0.spec
@@ -81,7 +81,7 @@
@ cdecl _fpclass(double) ucrtbase._fpclass
@ stub _fpclassf
@ cdecl -arch=i386 -ret64 _ftol() ucrtbase._ftol
-@ stub _get_FMA3_enable
+@ cdecl -arch=win64 _get_FMA3_enable() ucrtbase._get_FMA3_enable
@ cdecl _hypot(double double) ucrtbase._hypot
@ cdecl _hypotf(float float) ucrtbase._hypotf
@ cdecl _isnan(double) ucrtbase._isnan
diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec
index 903f4b7ce3..1016f6a649 100644
--- a/dlls/msvcr120/msvcr120.spec
+++ b/dlls/msvcr120/msvcr120.spec
@@ -1639,6 +1639,7 @@
@ stdcall -arch=i386 _seh_longjmp_unwind4(ptr)
@ stdcall -arch=i386 _seh_longjmp_unwind(ptr)
@ cdecl -arch=i386 _set_SSE2_enable(long) MSVCRT__set_SSE2_enable
+@ cdecl -arch=win64 _get_FMA3_enable() MSVCRT__get_FMA3_enable
@ cdecl -arch=win64 _set_FMA3_enable(long) MSVCRT__set_FMA3_enable
@ cdecl _set_abort_behavior(long long) MSVCRT__set_abort_behavior
@ cdecl _set_controlfp(long long)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index f6824128cd..ea5781a0d4 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -56,10 +56,24 @@ static MSVCRT_matherr_func MSVCRT_default_matherr_func = NULL;
static BOOL sse2_supported;
static BOOL sse2_enabled;
+#if defined(_WIN64) && _MSVCR_VER>=120
+static BOOL fma3_supported;
+static BOOL fma3_enabled;
+#endif
void msvcrt_init_math(void)
{
sse2_supported = sse2_enabled = IsProcessorFeaturePresent( PF_XMMI64_INSTRUCTIONS_AVAILABLE );
+ #if defined(_WIN64) && _MSVCR_VER>=120
+ #if !defined(__FMA__) && defined(__AVX2__)
+ #define __FMA__ 1
+ #endif
+ #if defined(__FMA__)
+ fma3_supported = fma3_enabled = 1;
+ #else
+ fma3_supported = fma3_enabled = 0;
+ #endif
+ #endif
}
/*********************************************************************
@@ -118,13 +132,21 @@ int CDECL MSVCRT__set_SSE2_enable(int flag)
}
#if defined(_WIN64) && _MSVCR_VER>=120
+/*********************************************************************
+ * _get_FMA3_enable (MSVCR120.@)
+ */
+int CDECL MSVCRT__get_FMA3_enable(void)
+{
+ return fma3_enabled;
+}
+
/*********************************************************************
* _set_FMA3_enable (MSVCR120.@)
*/
int CDECL MSVCRT__set_FMA3_enable(int flag)
{
- FIXME("(%x) stub\n", flag);
- return 0;
+ fma3_enabled = flag && fma3_supported;
+ return fma3_enabled;
}
#endif
diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec
index 568019da51..6cac7a5ef5 100644
--- a/dlls/ucrtbase/ucrtbase.spec
+++ b/dlls/ucrtbase/ucrtbase.spec
@@ -357,7 +357,7 @@
@ cdecl _fwrite_nolock(ptr long long ptr) MSVCRT__fwrite_nolock
@ cdecl _gcvt(double long str) MSVCRT__gcvt
@ cdecl _gcvt_s(ptr long double long) MSVCRT__gcvt_s
-@ stub _get_FMA3_enable
+@ cdecl -arch=win64 _get_FMA3_enable() MSVCRT__get_FMA3_enable
@ cdecl _get_current_locale() MSVCRT__get_current_locale
@ cdecl _get_daylight(ptr)
@ cdecl _get_doserrno(ptr)
--
2.25.0
More information about the wine-devel
mailing list