- fix what got broken with recent merge in intrin_x86.h

- add intrinsic bittest functions to wdm.h

svn path=/branches/ros-amd64-bringup/; revision=37872
This commit is contained in:
Timo Kreuzer 2008-12-05 20:18:58 +00:00
parent c8eaf02a99
commit 150d33cede
2 changed files with 39 additions and 14 deletions

View file

@ -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)

View file

@ -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)
//