[CRT]
authorThomas Faber <thomas.faber@reactos.org>
Thu, 20 Feb 2014 19:28:27 +0000 (19:28 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 20 Feb 2014 19:28:27 +0000 (19:28 +0000)
- Force the use of memory operands in bit test intrinsics. Bit offsets above 31 (or 63) can't behave correctly with registers (the constant case is fine because it ensures low offsets). Thanks to Timo Kreuzer and Alex Radocea.

svn path=/trunk/; revision=62266

reactos/include/crt/mingw32/intrin_x86.h

index 00ef94d..d129b1a 100644 (file)
@@ -1032,7 +1032,7 @@ __INTRIN_INLINE unsigned char _bittest(const long * const a, const long b)
        if(__builtin_constant_p(b))
                __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*(a + (b / 32))), [b] "Ir" (b % 32));
        else
-               __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*a), [b] "r" (b));
+               __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "m" (*a), [b] "r" (b));
 
        return retval;
 }
@@ -1045,7 +1045,7 @@ __INTRIN_INLINE unsigned char _bittest64(const __int64 * const a, const __int64
        if(__builtin_constant_p(b))
                __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*(a + (b / 64))), [b] "Ir" (b % 64));
        else
-               __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "mr" (*a), [b] "r" (b));
+               __asm__("bt %[b], %[a]; setb %b[retval]" : [retval] "=q" (retval) : [a] "m" (*a), [b] "r" (b));
 
        return retval;
 }
@@ -1058,7 +1058,7 @@ __INTRIN_INLINE unsigned char _bittestandcomplement(long * const a, const long b
        if(__builtin_constant_p(b))
                __asm__("btc %[b], %[a]; setb %b[retval]" : [a] "+mr" (*(a + (b / 32))), [retval] "=q" (retval) : [b] "Ir" (b % 32));
        else
-               __asm__("btc %[b], %[a]; setb %b[retval]" : [a] "+mr" (*a), [retval] "=q" (retval) : [b] "r" (b));
+               __asm__("btc %[b], %[a]; setb %b[retval]" : [a] "+m" (*a), [retval] "=q" (retval) : [b] "r" (b));
 
        return retval;
 }
@@ -1070,7 +1070,7 @@ __INTRIN_INLINE unsigned char _bittestandreset(long * const a, const long b)
        if(__builtin_constant_p(b))
                __asm__("btr %[b], %[a]; setb %b[retval]" : [a] "+mr" (*(a + (b / 32))), [retval] "=q" (retval) : [b] "Ir" (b % 32));
        else
-               __asm__("btr %[b], %[a]; setb %b[retval]" : [a] "+mr" (*a), [retval] "=q" (retval) : [b] "r" (b));
+               __asm__("btr %[b], %[a]; setb %b[retval]" : [a] "+m" (*a), [retval] "=q" (retval) : [b] "r" (b));
 
        return retval;
 }
@@ -1082,7 +1082,7 @@ __INTRIN_INLINE unsigned char _bittestandset(long * const a, const long b)
        if(__builtin_constant_p(b))
                __asm__("bts %[b], %[a]; setb %b[retval]" : [a] "+mr" (*(a + (b / 32))), [retval] "=q" (retval) : [b] "Ir" (b % 32));
        else
-               __asm__("bts %[b], %[a]; setb %b[retval]" : [a] "+mr" (*a), [retval] "=q" (retval) : [b] "r" (b));
+               __asm__("bts %[b], %[a]; setb %b[retval]" : [a] "+m" (*a), [retval] "=q" (retval) : [b] "r" (b));
 
        return retval;
 }