2007-03-14 20:24:57 +00:00
|
|
|
/*
|
2015-09-01 14:57:30 +00:00
|
|
|
* COPYRIGHT: See COPYING.LIB in the top level directory
|
2007-03-14 20:24:57 +00:00
|
|
|
* PROJECT: ReactOS system libraries
|
2015-09-01 14:57:30 +00:00
|
|
|
* PURPOSE: Resets FPU state to the default
|
|
|
|
* PROGRAMER: Thomas Faber <thomas.faber@reactos.org>
|
2007-03-14 20:24:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
|
2008-06-06 17:49:24 +00:00
|
|
|
/*********************************************************************
|
|
|
|
* _fpreset (MSVCRT.@)
|
2007-03-14 20:24:57 +00:00
|
|
|
*/
|
2008-06-06 17:49:24 +00:00
|
|
|
void CDECL _fpreset(void)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2016-08-06 10:18:08 +00:00
|
|
|
const unsigned short x86_cw = 0x27f;
|
2015-09-01 14:57:30 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
__asm { fninit }
|
|
|
|
__asm { fldcw [x86_cw] }
|
2008-06-06 17:49:24 +00:00
|
|
|
#else
|
2015-09-01 14:57:30 +00:00
|
|
|
__asm__ __volatile__( "fninit; fldcw %0" : : "m" (x86_cw) );
|
2008-06-06 17:49:24 +00:00
|
|
|
#endif
|
2015-09-01 14:57:30 +00:00
|
|
|
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
|
|
|
|
}
|
2007-03-14 20:24:57 +00:00
|
|
|
}
|