[NTOSKRNL]

Use inline asm in KiIsNpxErrataPresent(). C code can be optimized in a wrong way.

svn path=/trunk/; revision=53907
This commit is contained in:
Dmitry Gorbachev 2011-09-30 21:03:29 +00:00
parent 107362cefc
commit ce77677b0b

View file

@ -1254,9 +1254,9 @@ NTAPI
INIT_FUNCTION INIT_FUNCTION
KiIsNpxErrataPresent(VOID) KiIsNpxErrataPresent(VOID)
{ {
BOOLEAN ErrataPresent; static double Value1 = 4195835.0, Value2 = 3145727.0;
INT ErrataPresent;
ULONG Cr0; ULONG Cr0;
volatile double Value1, Value2;
/* Disable interrupts */ /* Disable interrupts */
_disable(); _disable();
@ -1269,9 +1269,30 @@ KiIsNpxErrataPresent(VOID)
Ke386FnInit(); Ke386FnInit();
/* Multiply the magic values and divide, we should get the result back */ /* Multiply the magic values and divide, we should get the result back */
Value1 = 4195835.0; #ifdef __GNUC__
Value2 = 3145727.0; __asm__ __volatile__
ErrataPresent = (Value1 * Value2 / 3145727.0) != 4195835.0; (
"fldl %1\n\t"
"fdivl %2\n\t"
"fmull %2\n\t"
"fldl %1\n\t"
"fsubp\n\t"
"fistpl %0\n\t"
: "=m" (ErrataPresent)
: "m" (Value1),
"m" (Value2)
);
#else
__asm
{
fld Value1
fdiv Value2
fmul Value2
fld Value1
fsubp
fistp ErrataPresent
};
#endif
/* Restore CR0 */ /* Restore CR0 */
__writecr0(Cr0); __writecr0(Cr0);
@ -1280,7 +1301,7 @@ KiIsNpxErrataPresent(VOID)
_enable(); _enable();
/* Return if there's an errata */ /* Return if there's an errata */
return ErrataPresent; return ErrataPresent != 0;
} }
VOID VOID