Reactos

[UCRT] Use GCC inline assembler

Clang requires the asm to be split, otherwise it complains that it doesn't have enough registers.

+54 -2
+4
sdk/include/ucrt/fenv.h
··· 130 130 // next floating point instruction. If we're using /arch:IA32, 131 131 // force the exception to be raised immediately: 132 132 #if defined _M_IX86 && _M_IX86_FP == 0 && !defined _M_HYBRID_X86_ARM64 133 + #ifdef _MSC_VER 133 134 __asm fwait; 135 + #else 136 + __asm__ __volatile__("fwait"); 137 + #endif 134 138 #endif 135 139 } 136 140 }
+17 -1
sdk/lib/ucrt/inc/corecrt_internal_big_integer.h
··· 686 686 uint32_t const multiplier 687 687 ) throw() 688 688 { 689 + #ifdef _MSC_VER 689 690 __asm 690 691 { 691 692 mov eax, dword ptr [multiplicand + 4] ··· 698 699 699 700 add edx, ecx 700 701 } 702 + #else // ^^^ _MSC_VER ^^^ // vvv !_MSC_VER vvv // 703 + uint64_t retval; 704 + __asm__( 705 + "mull %[multiplier]\n" 706 + "movl %%eax, %%ecx\n" 707 + "movl %[multiplicand_lo], %%eax\n" 708 + "mull %[multiplier]\n" 709 + "addl %%ecx, %%edx\n" 710 + : "=A" (retval) 711 + : [multiplicand_hi] "a" ((uint32_t)((multiplicand >> 32) & 0xFFFFFFFF)), 712 + [multiplicand_lo] "rm" ((uint32_t)((multiplicand >> 0) & 0xFFFFFFFF)), 713 + [multiplier] "rm" (multiplier) 714 + : "ecx" ); 715 + return retval; 716 + #endif // !_MSC_VER 701 717 } 702 718 #else 703 719 __forceinline uint64_t __cdecl multiply_64_32( ··· 869 885 } 870 886 871 887 // Multiply and subtract. Note that uu_quo may be one too large. If 872 - // we have a borrow at the end, we'll add the denominator back on and 888 + // we have a borrow at the end, we'll add the denominator back on and 873 889 // decrement uu_quo. 874 890 if (uu_quo > 0) 875 891 {
+33 -1
sdk/lib/ucrt/misc/invalid_parameter.cpp
··· 166 166 EXCEPTION_POINTERS ExceptionPointers = {&ExceptionRecord, &ContextRecord}; 167 167 168 168 #ifdef _M_IX86 169 - 169 + #if defined(__GNUC__) || defined(__clang__) 170 + __asm__ __volatile__( 171 + "movl %%eax, %[CxEax]\n\t" 172 + "movl %%ecx, %[CxEcx]\n\t" 173 + "movl %%edx, %[CxEdx]\n\t" 174 + "movl %%ebx, %[CxEbx]\n\t" 175 + "movl %%esi, %[CxEsi]\n\t" 176 + "movl %%edi, %[CxEdi]\n\t" 177 + : [CxEax] "=m" (ContextRecord.Eax), 178 + [CxEcx] "=m" (ContextRecord.Ecx), 179 + [CxEdx] "=m" (ContextRecord.Edx), 180 + [CxEbx] "=m" (ContextRecord.Ebx), 181 + [CxEsi] "=m" (ContextRecord.Esi), 182 + [CxEdi] "=m" (ContextRecord.Edi)); 183 + __asm__ __volatile__( 184 + "movw %%ss, %[CxSegSs]\n\t" 185 + "movw %%cs, %[CxSegCs]\n\t" 186 + "movw %%ds, %[CxSegDs]\n\t" 187 + "movw %%es, %[CxSegEs]\n\t" 188 + "movw %%fs, %[CxSegFs]\n\t" 189 + "movw %%gs, %[CxSegGs]\n\t" 190 + : [CxSegSs] "=m" (ContextRecord.SegSs), 191 + [CxSegCs] "=m" (ContextRecord.SegCs), 192 + [CxSegDs] "=m" (ContextRecord.SegDs), 193 + [CxSegEs] "=m" (ContextRecord.SegEs), 194 + [CxSegFs] "=m" (ContextRecord.SegFs), 195 + [CxSegGs] "=m" (ContextRecord.SegGs)); 196 + __asm__ __volatile__( 197 + "pushfl\n\t" 198 + "popl %[CxEFlags]\n\t" 199 + : [CxEFlags] "=m" (ContextRecord.EFlags)); 200 + #else // ^^^ __GNUC__ ^^^ // vvv !__GNUC__ vvv // 170 201 __asm 171 202 { 172 203 mov dword ptr [ContextRecord.Eax ], eax ··· 184 215 pushfd 185 216 pop [ContextRecord.EFlags] 186 217 } 218 + #endif // !__GNUC__ 187 219 188 220 ContextRecord.ContextFlags = CONTEXT_CONTROL; 189 221