Route Borland/Embarcadero into MS inline ASM code for CPUID

The inline ASM code now uses local variables to save the EAX-EDX registers, and then copies the locals into the function parameters. It side steps problems with calling conventions
This commit is contained in:
Jeffrey Walton 2017-09-16 18:03:24 -04:00
parent 7464cbba51
commit da0dc66952
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

19
cpu.cpp
View File

@ -123,24 +123,31 @@ extern "C"
}
#endif
// Embarcadero and Issue 498
// Borland/Embarcadero and Issue 498
// cpu.cpp (131): E2211 Inline assembly not allowed in inline and template functions
bool CpuId(word32 func, word32 subfunc, word32 output[4])
{
#if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY)
#if defined(CRYPTOPP_MS_STYLE_INLINE_ASSEMBLY) || defined(__BORLANDC__)
__try
{
// Borland/Embarcadero and Issue 500
// Local variables for cpuid output
word32 a, b, c, d;
__asm
{
mov eax, func
mov ecx, subfunc
cpuid
mov edi, output
mov [edi], eax
mov [edi+4], ebx
mov [edi+8], ecx
mov [edi+12], edx
mov [a], eax
mov [b], ebx
mov [c], ecx
mov [d], edx
}
output[0] = a;
output[1] = b;
output[2] = c;
output[3] = d;
}
// GetExceptionCode() == EXCEPTION_ILLEGAL_INSTRUCTION
__except (EXCEPTION_EXECUTE_HANDLER)