From ee071ab752662d4e1e70f8929a1912c09c393167 Mon Sep 17 00:00:00 2001 From: Thomas Faber Date: Tue, 1 Sep 2015 14:57:30 +0000 Subject: [PATCH] [CRT] - Rewrite _fpreset based on Wine. Fixes the last kernel32:thread test failure svn path=/trunk/; revision=68898 --- reactos/lib/sdk/crt/float/i386/fpreset.c | 26 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/reactos/lib/sdk/crt/float/i386/fpreset.c b/reactos/lib/sdk/crt/float/i386/fpreset.c index 6cee5e885b3..32f1c83e86f 100644 --- a/reactos/lib/sdk/crt/float/i386/fpreset.c +++ b/reactos/lib/sdk/crt/float/i386/fpreset.c @@ -1,11 +1,8 @@ /* - * COPYRIGHT: See COPYING in the top level directory + * COPYRIGHT: See COPYING.LIB in the top level directory * PROJECT: ReactOS system libraries - * FILE: lib/crt/?????? - * PURPOSE: Unknown - * PROGRAMER: Unknown - * UPDATE HISTORY: - * 25/11/05: Added license header + * PURPOSE: Resets FPU state to the default + * PROGRAMER: Thomas Faber */ #include @@ -15,9 +12,20 @@ */ void CDECL _fpreset(void) { -#if defined(__GNUC__) - __asm__ __volatile__( "fninit" ); + const unsigned int x86_cw = 0x27f; +#ifdef _MSC_VER + __asm { fninit } + __asm { fldcw [x86_cw] } #else - __asm fninit; + __asm__ __volatile__( "fninit; fldcw %0" : : "m" (x86_cw) ); #endif + if (IsProcessorFeaturePresent(PF_XMMI64_INSTRUCTIONS_AVAILABLE)) + { + const unsigned long sse2_cw = 0x1f80; +#ifdef _MSC_VER + __asm { ldmxcsr [sse2_cw] } +#else + __asm__ __volatile__( "ldmxcsr %0" : : "m" (sse2_cw) ); +#endif + } } -- 2.17.1