mirror of
https://github.com/reactos/reactos.git
synced 2025-06-24 19:00:20 +00:00
[UCRT] Use GCC inline assembler
Clang requires the asm to be split, otherwise it complains that it doesn't have enough registers.
This commit is contained in:
parent
0cdde63c57
commit
faedd8ff75
3 changed files with 54 additions and 2 deletions
|
@ -130,7 +130,11 @@ _ACRTIMP int __cdecl fesetround(_In_ int _Round);
|
||||||
// next floating point instruction. If we're using /arch:IA32,
|
// next floating point instruction. If we're using /arch:IA32,
|
||||||
// force the exception to be raised immediately:
|
// force the exception to be raised immediately:
|
||||||
#if defined _M_IX86 && _M_IX86_FP == 0 && !defined _M_HYBRID_X86_ARM64
|
#if defined _M_IX86 && _M_IX86_FP == 0 && !defined _M_HYBRID_X86_ARM64
|
||||||
|
#ifdef _MSC_VER
|
||||||
__asm fwait;
|
__asm fwait;
|
||||||
|
#else
|
||||||
|
__asm__ __volatile__("fwait");
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -686,6 +686,7 @@ __forceinline uint32_t __cdecl count_sequential_high_zeroes(uint32_t const u) th
|
||||||
uint32_t const multiplier
|
uint32_t const multiplier
|
||||||
) throw()
|
) throw()
|
||||||
{
|
{
|
||||||
|
#ifdef _MSC_VER
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov eax, dword ptr [multiplicand + 4]
|
mov eax, dword ptr [multiplicand + 4]
|
||||||
|
@ -698,6 +699,21 @@ __forceinline uint32_t __cdecl count_sequential_high_zeroes(uint32_t const u) th
|
||||||
|
|
||||||
add edx, ecx
|
add edx, ecx
|
||||||
}
|
}
|
||||||
|
#else // ^^^ _MSC_VER ^^^ // vvv !_MSC_VER vvv //
|
||||||
|
uint64_t retval;
|
||||||
|
__asm__(
|
||||||
|
"mull %[multiplier]\n"
|
||||||
|
"movl %%eax, %%ecx\n"
|
||||||
|
"movl %[multiplicand_lo], %%eax\n"
|
||||||
|
"mull %[multiplier]\n"
|
||||||
|
"addl %%ecx, %%edx\n"
|
||||||
|
: "=A" (retval)
|
||||||
|
: [multiplicand_hi] "a" ((uint32_t)((multiplicand >> 32) & 0xFFFFFFFF)),
|
||||||
|
[multiplicand_lo] "rm" ((uint32_t)((multiplicand >> 0) & 0xFFFFFFFF)),
|
||||||
|
[multiplier] "rm" (multiplier)
|
||||||
|
: "ecx" );
|
||||||
|
return retval;
|
||||||
|
#endif // !_MSC_VER
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
__forceinline uint64_t __cdecl multiply_64_32(
|
__forceinline uint64_t __cdecl multiply_64_32(
|
||||||
|
@ -869,7 +885,7 @@ inline uint64_t __cdecl divide(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply and subtract. Note that uu_quo may be one too large. If
|
// Multiply and subtract. Note that uu_quo may be one too large. If
|
||||||
// we have a borrow at the end, we'll add the denominator back on and
|
// we have a borrow at the end, we'll add the denominator back on and
|
||||||
// decrement uu_quo.
|
// decrement uu_quo.
|
||||||
if (uu_quo > 0)
|
if (uu_quo > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -166,7 +166,38 @@ extern "C" __declspec(noreturn) void __cdecl _invalid_parameter_noinfo_noreturn(
|
||||||
EXCEPTION_POINTERS ExceptionPointers = {&ExceptionRecord, &ContextRecord};
|
EXCEPTION_POINTERS ExceptionPointers = {&ExceptionRecord, &ContextRecord};
|
||||||
|
|
||||||
#ifdef _M_IX86
|
#ifdef _M_IX86
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"movl %%eax, %[CxEax]\n\t"
|
||||||
|
"movl %%ecx, %[CxEcx]\n\t"
|
||||||
|
"movl %%edx, %[CxEdx]\n\t"
|
||||||
|
"movl %%ebx, %[CxEbx]\n\t"
|
||||||
|
"movl %%esi, %[CxEsi]\n\t"
|
||||||
|
"movl %%edi, %[CxEdi]\n\t"
|
||||||
|
: [CxEax] "=m" (ContextRecord.Eax),
|
||||||
|
[CxEcx] "=m" (ContextRecord.Ecx),
|
||||||
|
[CxEdx] "=m" (ContextRecord.Edx),
|
||||||
|
[CxEbx] "=m" (ContextRecord.Ebx),
|
||||||
|
[CxEsi] "=m" (ContextRecord.Esi),
|
||||||
|
[CxEdi] "=m" (ContextRecord.Edi));
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"movw %%ss, %[CxSegSs]\n\t"
|
||||||
|
"movw %%cs, %[CxSegCs]\n\t"
|
||||||
|
"movw %%ds, %[CxSegDs]\n\t"
|
||||||
|
"movw %%es, %[CxSegEs]\n\t"
|
||||||
|
"movw %%fs, %[CxSegFs]\n\t"
|
||||||
|
"movw %%gs, %[CxSegGs]\n\t"
|
||||||
|
: [CxSegSs] "=m" (ContextRecord.SegSs),
|
||||||
|
[CxSegCs] "=m" (ContextRecord.SegCs),
|
||||||
|
[CxSegDs] "=m" (ContextRecord.SegDs),
|
||||||
|
[CxSegEs] "=m" (ContextRecord.SegEs),
|
||||||
|
[CxSegFs] "=m" (ContextRecord.SegFs),
|
||||||
|
[CxSegGs] "=m" (ContextRecord.SegGs));
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"pushfl\n\t"
|
||||||
|
"popl %[CxEFlags]\n\t"
|
||||||
|
: [CxEFlags] "=m" (ContextRecord.EFlags));
|
||||||
|
#else // ^^^ __GNUC__ ^^^ // vvv !__GNUC__ vvv //
|
||||||
__asm
|
__asm
|
||||||
{
|
{
|
||||||
mov dword ptr [ContextRecord.Eax ], eax
|
mov dword ptr [ContextRecord.Eax ], eax
|
||||||
|
@ -184,6 +215,7 @@ extern "C" __declspec(noreturn) void __cdecl _invalid_parameter_noinfo_noreturn(
|
||||||
pushfd
|
pushfd
|
||||||
pop [ContextRecord.EFlags]
|
pop [ContextRecord.EFlags]
|
||||||
}
|
}
|
||||||
|
#endif // !__GNUC__
|
||||||
|
|
||||||
ContextRecord.ContextFlags = CONTEXT_CONTROL;
|
ContextRecord.ContextFlags = CONTEXT_CONTROL;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue