diff --git a/reactos/include/crt/mingw32/intrin_x86.h b/reactos/include/crt/mingw32/intrin_x86.h index a2c7e0e44ae..213f8d626ef 100644 --- a/reactos/include/crt/mingw32/intrin_x86.h +++ b/reactos/include/crt/mingw32/intrin_x86.h @@ -657,29 +657,24 @@ static __inline__ __attribute__((always_inline)) void __incgsdword(const unsigne __asm__ __volatile__("incl %%gs:%a[Offset]" : : [Offset] "ir" (Offset) : "memory"); } -/* NOTE: the bizarre implementation of __addgsxxx mimics the broken Visual C++ behavior */ static __inline__ __attribute__((always_inline)) void __addgsbyte(const unsigned long Offset, const unsigned char Data) { - if(!__builtin_constant_p(Offset)) - __asm__ __volatile__("addb %k[Offset], %%gs:%a[Offset]" : : [Offset] "r" (Offset) : "memory"); - else - __asm__ __volatile__("addb %b[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); + __asm__ __volatile__("addb %b[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); } static __inline__ __attribute__((always_inline)) void __addgsword(const unsigned long Offset, const unsigned short Data) { - if(!__builtin_constant_p(Offset)) - __asm__ __volatile__("addw %k[Offset], %%gs:%a[Offset]" : : [Offset] "r" (Offset) : "memory"); - else - __asm__ __volatile__("addw %w[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); + __asm__ __volatile__("addw %w[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); } static __inline__ __attribute__((always_inline)) void __addgsdword(const unsigned long Offset, const unsigned int Data) { - if(!__builtin_constant_p(Offset)) - __asm__ __volatile__("addl %k[Offset], %%gs:%a[Offset]" : : [Offset] "r" (Offset) : "memory"); - else - __asm__ __volatile__("addl %k[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); + __asm__ __volatile__("addl %k[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); +} + +static __inline__ __attribute__((always_inline)) void __addgsqword(const unsigned long Offset, const unsigned __int64 Data) +{ + __asm__ __volatile__("addq %k[Data], %%gs:%a[Offset]" : : [Offset] "ir" (Offset), [Data] "iq" (Data) : "memory"); } #else @@ -1066,11 +1061,28 @@ static __inline__ __attribute__((always_inline)) void __cpuid(int CPUInfo[], con static __inline__ __attribute__((always_inline)) unsigned long long __rdtsc(void) { +#ifdef _M_AMD64 + unsigned long long low, high; + __asm__ __volatile__("rdtsc" : "=a"(low), "=d"(high)); + return low | (high << 32); +#else unsigned long long retval; __asm__ __volatile__("rdtsc" : "=A"(retval)); return retval; +#endif } +static __inline__ __attribute__((always_inline)) void __writeeflags(uintptr_t Value) +{ + __asm__ __volatile__("push %0\n popf" : : "rim"(Value)); +} + +static __inline__ __attribute__((always_inline)) uintptr_t __readeflags(void) +{ + uintptr_t retval; + __asm__ __volatile__("pushf\n pop %0" : "=rm"(retval)); + return retval; +} /*** Interrupts ***/ static __inline__ __attribute__((always_inline)) void __debugbreak(void) diff --git a/reactos/include/ddk/wdm.h b/reactos/include/ddk/wdm.h index c0c126ed661..91328bc9996 100644 --- a/reactos/include/ddk/wdm.h +++ b/reactos/include/ddk/wdm.h @@ -628,7 +628,20 @@ typedef struct _CONTEXT { } CONTEXT; #elif defined(_M_AMD64) -//#error FIXME-TODO: 64-bit + +#define BitTest _bittest +#define BitTest64 _bittest64 +#define BitTestAndComplement _bittestandcomplement +#define BitTestAndComplement64 _bittestandcomplement64 +#define BitTestAndSet _bittestandset +#define BitTestAndSet64 _bittestandset64 +#define BitTestAndReset _bittestandreset +#define BitTestAndReset64 _bittestandreset64 +#define InterlockedBitTestAndSet _interlockedbittestandset +#define InterlockedBitTestAndSet64 _interlockedbittestandset64 +#define InterlockedBitTestAndReset _interlockedbittestandreset +#define InterlockedBitTestAndReset64 _interlockedbittestandreset64 + #elif defined(_M_ARM) //