[KERNEL32_APITEST] Fix compilation & global wut?? with SSE exception test

This commit is contained in:
Jérôme Gardou 2021-04-09 16:50:43 +02:00 committed by Jérôme Gardou
parent 4959ccc8df
commit 0995b35bac

View file

@ -102,33 +102,28 @@ static LONG WINAPI ExceptionFilterSSEException(LPEXCEPTION_POINTERS exp)
return EXCEPTION_CONTINUE_EXECUTION;
}
#ifdef __clang__
#if defined(__clang__) || defined(__GNUC__)
__attribute__((__target__("sse")))
#endif
static
VOID TestSSEExceptions(VOID)
{
LPTOP_LEVEL_EXCEPTION_FILTER p;
BOOL supportsSSE = FALSE;
unsigned int csr;
/* Test SSE support for the CPU */
p = SetUnhandledExceptionFilter(ExceptionFilterSSESupport);
ok(p == NULL, "Previous filter should be NULL\n");
#ifdef _MSC_VER
#if defined(_M_AMD64)
#if !defined(_M_AMD64)
{
__m128 xmm = { { 0 } };
xmm = _mm_xor_ps(xmm, xmm);
if (!ExceptionCaught) supportsSSE = TRUE;
}
#else
BOOL supportsSSE = FALSE;
#ifdef _MSC_VER
__asm
{
xorps xmm0, xmm0
mov supportsSSE, 0x1
}
#endif
#else
__asm__(
"xorps %%xmm0, %%xmm0\n"
@ -136,12 +131,16 @@ VOID TestSSEExceptions(VOID)
: "=r"(supportsSSE)
);
#endif /* _MSC_VER */
if(!supportsSSE)
{
skip("CPU doesn't support SSE instructions.\n");
SetUnhandledExceptionFilter(NULL);
return;
}
}
#endif /* !defined(_M_AMD64) */
/* Deliberately throw a divide by 0 exception */
p = SetUnhandledExceptionFilter(ExceptionFilterSSEException);
ok(p == ExceptionFilterSSESupport, "Unexpected old filter : 0x%p", p);
@ -157,7 +156,6 @@ VOID TestSSEExceptions(VOID)
__m128 xmm1 = { { 1., 1. } }, xmm2 = { { 0 } };
/* Wait, aren't exceptions masked? Yes, but actually no. */
xmm1 = _mm_div_ps(xmm1, xmm2);
if (!ExceptionCaught) supportsSSE = TRUE;
}
#else
__asm
@ -178,20 +176,15 @@ VOID TestSSEExceptions(VOID)
}
#endif
#else
ULONG zeros[4] = {0, 0, 0, 0};
ULONG ones[4] = {0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000};
__asm__ (
"xorps %%xmm0, %%xmm0\n"
"pushl $0x3f800000\n"
"pushl $0x3f800000\n"
"pushl $0x3f800000\n"
"pushl $0x3f800000\n"
"movups (%%esp), %%xmm1\n"
"movups (%0), %%xmm0\n"
"movups (%1), %%xmm1\n"
/* Divide by 0 */
"divps %%xmm0, %%xmm1\n"
/* Clean up */
"addl $16, %%esp\n"
:
: : "r"(&zeros), "r"(&ones) : "xmm0", "xmm1"
);
#endif /* _MSC_VER */