I have found some problems with the InterlockedBitTestAndXXX functions. For example:

- Despite sezero's recent update, they still don't all have the "memory" clobber.
- The constraints for the 64bit versions are incorrect (I vs J).
- There is no library definition for interlockedbittestandcomplement64.

For these reasons (among others), I have created the attached patch. Specifically it includes:

Fixes for:
InterlockedBitTestAndSet, InterlockedBitTestAndReset, InterlockedBitTestAndComplement, InterlockedBitTestAndSet64, InterlockedBitTestAndReset64, InterlockedBitTestAndComplement64 _interlockedbittestandset, _interlockedbittestandreset, _interlockedbittestandcomplement _interlockedbittestandset64, _interlockedbittestandreset64, _interlockedbittestandcomplement64

- While sezero recently added the (required) "memory" clobber to a number of the InterlockedBitTestXXX methods, he didn't get all of them. Using the macro for defining these methods makes them all consistent. - The Bit parameter uses the "I" constraint on both 32bit and 64bit. 64bit should use "J".
- Use symbolic names for asm statement for clarity.
- Support both att and intel dialects of assembler in public headers.
- InterlockedBitTestAndSet and _interlockedbittestandset were mapped to each other via #define. However they should have different prototypes. This patch declares InterlockedBitTestAndSet (and related) with p1 as volatile, which is consistent with the MSVC definition. In the crt, these are implemented with 'alias.' The inlines both use the same macro.
- Adds declarations for all methods in intrin.h.
- There was no library definition for interlockedbittestandcomplement64. This required a new file. - As with my other recent patches, this one uses macros so all implementations (winnt.h and crt) use the same code.

Cleanup:
- My previous patches have been using the cpp comment style (//). I have replaced that with c style (/* */) to be consistent with the rest of the file. - I have renamed the file macro for intrin-mac.h from _INTRIN-MAC_ to _INTRIN_MAC_. I'm not sure why this ever worked. - I have added comments to intrin-mac.h describing the parameters for the macros from previous patches.

dw
Index: mingw-w64-crt/intrincs/bittestci.c
===================================================================
--- mingw-w64-crt/intrincs/bittestci.c  (revision 5873)
+++ mingw-w64-crt/intrincs/bittestci.c  (working copy)
@@ -1,14 +1,6 @@
 #include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
 
-unsigned char _InterlockedBitTestAndComplement(__LONG32 *Base, __LONG32 Bit);  
                /* not in intrin.h */
-unsigned char _InterlockedBitTestAndComplement(__LONG32 *Base, __LONG32 Bit)
-{
-  int old = 0;
-  __asm__ __volatile__("lock ; btcl %2,%1\n\tsbbl %0,%0 "
-    :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-    :"Ir" (Bit) : "memory");
-  return (old != 0);
-}
+__buildbittesti(_interlockedbittestandcomplement, __LONG32, "lock btc", "I", 
/* unused param */)
 
-unsigned char InterlockedBitTestAndComplement(__LONG32 *Base, __LONG32 Bit) 
__attribute__((alias("_InterlockedBitTestAndComplement")));
-
+unsigned char InterlockedBitTestAndComplement(__LONG32 volatile *, __LONG32) 
__attribute__((alias("_interlockedbittestandcomplement")));
Index: mingw-w64-crt/intrincs/bittestci64.c
===================================================================
--- mingw-w64-crt/intrincs/bittestci64.c        (revision 0)
+++ mingw-w64-crt/intrincs/bittestci64.c        (working copy)
@@ -0,0 +1,6 @@
+#include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
+
+__buildbittesti(_interlockedbittestandcomplement64, __int64, "lock btc", "J", 
/* unused param */)
+
+unsigned char InterlockedBitTestAndComplement64(__int64 volatile *, __int64) 
__attribute__((alias("_interlockedbittestandcomplement64")));
Index: mingw-w64-crt/intrincs/bittestri.c
===================================================================
--- mingw-w64-crt/intrincs/bittestri.c  (revision 5873)
+++ mingw-w64-crt/intrincs/bittestri.c  (working copy)
@@ -1,11 +1,6 @@
 #include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
 
-unsigned char _interlockedbittestandreset(__LONG32 *Base, __LONG32 Offset)
-{
-  int old = 0;
-  __asm__ __volatile__("lock ; btrl %2,%1\n\tsbbl %0,%0 "
-    :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-    :"Ir" (Offset) : "memory");
-  return (old != 0);
-}
+__buildbittesti(_interlockedbittestandreset, __LONG32, "lock btr", "I", /* 
unused param */)
 
+unsigned char InterlockedBitTestAndReset(__LONG32 volatile *, __LONG32) 
__attribute__((alias("_interlockedbittestandreset")));
Index: mingw-w64-crt/intrincs/bittestri64.c
===================================================================
--- mingw-w64-crt/intrincs/bittestri64.c        (revision 5873)
+++ mingw-w64-crt/intrincs/bittestri64.c        (working copy)
@@ -1,11 +1,6 @@
 #include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
 
-unsigned char _interlockedbittestandreset64(__int64 *Base, __int64 Offset)
-{
-  int old = 0;
-  __asm__ __volatile__("lock ; btrq %2,%1\n\tsbbl %0,%0 "
-    :"=r" (old),"=m" ((*(volatile long long *) Base))
-    :"Ir" (Offset) : "memory");
-  return (old != 0);
-}
+__buildbittesti(_interlockedbittestandreset64, __int64, "lock btr", "J", /* 
unused param */)
 
+unsigned char InterlockedBitTestAndReset64(__int64 volatile *, __int64) 
__attribute__((alias("_interlockedbittestandreset64")));
Index: mingw-w64-crt/intrincs/bittestsi.c
===================================================================
--- mingw-w64-crt/intrincs/bittestsi.c  (revision 5873)
+++ mingw-w64-crt/intrincs/bittestsi.c  (working copy)
@@ -1,11 +1,6 @@
 #include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
 
-unsigned char _interlockedbittestandset(__LONG32 *Base, __LONG32 Offset)
-{
-  int old = 0;
-  __asm__ __volatile__("lock ; btsl %2,%1\n\tsbbl %0,%0 "
-    :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-    :"Ir" (Offset) : "memory");
-  return (old != 0);
-}
+__buildbittesti(_interlockedbittestandset, __LONG32, "lock bts", "I", /* 
unused param */)
 
+unsigned char InterlockedBitTestAndSet(__LONG32 volatile *, __LONG32) 
__attribute__((alias("_interlockedbittestandset")));
Index: mingw-w64-crt/intrincs/bittestsi64.c
===================================================================
--- mingw-w64-crt/intrincs/bittestsi64.c        (revision 5873)
+++ mingw-w64-crt/intrincs/bittestsi64.c        (working copy)
@@ -1,11 +1,6 @@
 #include <intrin.h>
+#include <psdk_inc/intrin-mac.h>
 
-unsigned char _interlockedbittestandset64(__int64 *Base, __int64 Offset)
-{
-  int old = 0;
-  __asm__ __volatile__("lock ; btsq %2,%1\n\tsbbl %0,%0 "
-    :"=r" (old),"=m" ((*(volatile long long *) Base))
-    :"Ir" (Offset) : "memory");
-  return (old != 0);
-}
+__buildbittesti(_interlockedbittestandset64, __int64, "lock bts", "J", /* 
unused param */)
 
+unsigned char InterlockedBitTestAndSet64(__int64 volatile *, __int64) 
__attribute__((alias("_interlockedbittestandset64")));
Index: mingw-w64-crt/Makefile.am
===================================================================
--- mingw-w64-crt/Makefile.am   (revision 5873)
+++ mingw-w64-crt/Makefile.am   (working copy)
@@ -258,7 +258,7 @@
   intrincs/readgsqword.c  intrincs/writegsbyte.c  intrincs/writegsword.c  
intrincs/writegsdword.c    \
   intrincs/writegsqword.c intrincs/mul128ex.c     intrincs/umul128ex.c    
intrincs/_mul128.c         \
   intrincs/_umul128.c     intrincs/__movsq.c      intrincs/__stosq.c      
intrincs/__shiftright128.c \
-  intrincs/__shiftleft128.c
+  intrincs/bittestci64.c  intrincs/__shiftleft128.c
 
 # these only go into the 32 bit version:
 src_intrincs32=\
Index: mingw-w64-headers/crt/intrin.h
===================================================================
--- mingw-w64-headers/crt/intrin.h      (revision 5873)
+++ mingw-w64-headers/crt/intrin.h      (working copy)
@@ -1037,14 +1037,22 @@
     __MACHINEIW64(unsigned char _bittestandset(__LONG32 *a,__LONG32 b))
     __MACHINEIW64(unsigned char _bittestandreset(__LONG32 *a,__LONG32 b))
     __MACHINEIW64(unsigned char _bittestandcomplement(__LONG32 *a,__LONG32 b))
+    __MACHINEI(unsigned char InterlockedBitTestAndSet(volatile __LONG32 
*a,__LONG32 b))
+    __MACHINEI(unsigned char InterlockedBitTestAndReset(volatile __LONG32 
*a,__LONG32 b))
+    __MACHINEI(unsigned char InterlockedBitTestAndComplement(volatile __LONG32 
*a,__LONG32 b))
     __MACHINEI(unsigned char _interlockedbittestandset(__LONG32 *a,__LONG32 b))
     __MACHINEI(unsigned char _interlockedbittestandreset(__LONG32 *a,__LONG32 
b))
+    __MACHINEI(unsigned char _interlockedbittestandcomplement(__LONG32 
*a,__LONG32 b))
     __MACHINEW64(__MINGW_EXTENSION unsigned char _bittest64(__int64 const 
*a,__int64 b))
     __MACHINEW64(__MINGW_EXTENSION unsigned char _bittestandset64(__int64 
*a,__int64 b))
     __MACHINEW64(__MINGW_EXTENSION unsigned char _bittestandreset64(__int64 
*a,__int64 b))
     __MACHINEW64(__MINGW_EXTENSION unsigned char 
_bittestandcomplement64(__int64 *a,__int64 b))
+    __MACHINEX64(__MINGW_EXTENSION unsigned char 
InterlockedBitTestAndSet64(volatile __int64 *a,__int64 b))
+    __MACHINEX64(__MINGW_EXTENSION unsigned char 
InterlockedBitTestAndReset64(volatile __int64 *a,__int64 b))
+    __MACHINEX64(__MINGW_EXTENSION unsigned char 
InterlockedBitTestAndComplement64(volatile __int64 *a,__int64 b))
     __MACHINEX64(__MINGW_EXTENSION unsigned char 
_interlockedbittestandset64(__int64 *a,__int64 b))
     __MACHINEX64(__MINGW_EXTENSION unsigned char 
_interlockedbittestandreset64(__int64 *a,__int64 b))
+    __MACHINEX64(__MINGW_EXTENSION unsigned char 
_interlockedbittestandcomplement64(__int64 *a,__int64 b))
     __MACHINEI(void __cpuid(int a[4],int b))
     __MACHINEI(__MINGW_EXTENSION unsigned __int64 __readpmc(unsigned __LONG32 
a))
     __MACHINEI(unsigned __LONG32 __segmentlimit(unsigned __LONG32 a))
Index: mingw-w64-headers/include/psdk_inc/intrin-mac.h
===================================================================
--- mingw-w64-headers/include/psdk_inc/intrin-mac.h     (revision 5876)
+++ mingw-w64-headers/include/psdk_inc/intrin-mac.h     (working copy)
@@ -6,10 +6,15 @@
 
 /* The macros in this file are included in multiple places */
 
-#ifndef _INTRIN-MAC_
-#define _INTRIN-MAC_
+#ifndef _INTRIN_MAC_
+#define _INTRIN_MAC_
 
 /* This macro is used by __stosb, __stosw, __stosd, __stosq */
+
+/* Parameters: (FunctionName, DataType, Operator)
+   FunctionName: Any valid function name
+   DataType: BYTE, WORD, DWORD or DWORD64 */
+
 #define __buildstos(x, y) void x(y *Dest, y Data, size_t Count) \
 { \
    __asm__ __volatile__ ("rep stos%z[Data]" \
@@ -18,10 +23,35 @@
       : "memory"); \
 }
 
-// This macro is used by InterlockedAnd, InterlockedOr, InterlockedXor, 
InterlockedAnd64, InterlockedOr64, InterlockedXor64
+/* This macro is used by InterlockedAnd, InterlockedOr, InterlockedXor, 
InterlockedAnd64, InterlockedOr64, InterlockedXor64 */
+
+/* Parameters: (FunctionName, DataType, Operator)
+   FunctionName: Any valid function name
+   DataType: __LONG32 or LONG64
+   Operator: One of xor, or, and */
 #define __buildlogicali(x, y, o) y x(volatile y *Destination, y Value) \
 { \
     return __sync_fetch_and_ ## o(Destination, Value); \
 }
 
-#endif /* _INTRIN-MAC_ */
+/* This macro is used by InterlockedBitTestAndSet, InterlockedBitTestAndReset, 
InterlockedBitTestAndComplement,
+   InterlockedBitTestAndSet64, InterlockedBitTestAndReset64, 
InterlockedBitTestAndComplement64
+   _interlockedbittestandset, _interlockedbittestandreset, 
_interlockedbittestandcomplement
+   _interlockedbittestandset64, _interlockedbittestandreset64, 
_interlockedbittestandcomplement64 */
+
+/* Parameters: (FunctionName, DataType, AsmCode, OffsetConstraint, Volatile)
+   FunctionName: Any valid function name
+   DataType: __LONG32 or LONG64
+   OffsetConstraint: either "I" for 32bit data types or "J" for 64.
+   Volatile: either volatile or blank. */
+#define __buildbittesti(x, y, z, a, b) unsigned char x(b y *Base, y Offset) \
+{ \
+   unsigned char old; \
+   __asm__ __volatile__ (z "%z[Base] {%[Offset],%[Base] | %[Base],%[Offset]} ; 
setc %[old]" \
+      : [old] "=qm" (old), [Base] "+m" (*Base) \
+      : [Offset] a "r" (Offset) \
+      : "memory", "cc"); \
+   return old; \
+}
+
+#endif /* _INTRIN_MAC_ */
Index: mingw-w64-headers/include/winnt.h
===================================================================
--- mingw-w64-headers/include/winnt.h   (revision 5876)
+++ mingw-w64-headers/include/winnt.h   (working copy)
@@ -1178,14 +1178,10 @@
 #define BitTestAndComplement _bittestandcomplement
 #define BitTestAndSet _bittestandset
 #define BitTestAndReset _bittestandreset
-#define InterlockedBitTestAndSet _interlockedbittestandset
-#define InterlockedBitTestAndReset _interlockedbittestandreset
 #define BitTest64 _bittest64
 #define BitTestAndComplement64 _bittestandcomplement64
 #define BitTestAndSet64 _bittestandset64
 #define BitTestAndReset64 _bittestandreset64
-#define InterlockedBitTestAndSet64 _interlockedbittestandset64
-#define InterlockedBitTestAndReset64 _interlockedbittestandreset64
 
     BOOLEAN _bittest(LONG const *Base,LONG Offset);
     BOOLEAN _bittestandcomplement(LONG *Base,LONG Offset);
@@ -1207,25 +1203,25 @@
     }
 #endif /* __CRT__NO_INLINE */
 
-    BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit);
     BOOLEAN _bittestandset(LONG *Base,LONG Offset);
     BOOLEAN _bittestandreset(LONG *Base,LONG Offset);
-    BOOLEAN _interlockedbittestandset(LONG *Base,LONG Offset);
-    BOOLEAN _interlockedbittestandreset(LONG *Base,LONG Offset);
+    BOOLEAN _interlockedbittestandset(__LONG32 *Base,LONG Offset);
+    BOOLEAN _interlockedbittestandreset(__LONG32 *Base,LONG Offset);
+    BOOLEAN _interlockedbittestandcomplement(__LONG32 *Base,LONG Bit);
+    BOOLEAN InterlockedBitTestAndSet(volatile __LONG32 *Base,LONG Offset);
+    BOOLEAN InterlockedBitTestAndReset(volatile __LONG32 *Base,LONG Offset);
+    BOOLEAN InterlockedBitTestAndComplement(volatile __LONG32 *Base,LONG Bit);
     BOOLEAN _bittest64(LONG64 const *Base,LONG64 Offset);
     BOOLEAN _bittestandcomplement64(LONG64 *Base,LONG64 Offset);
     BOOLEAN _bittestandset64(LONG64 *Base,LONG64 Offset);
     BOOLEAN _bittestandreset64(LONG64 *Base,LONG64 Offset);
+    BOOLEAN InterlockedBitTestAndSet64(volatile LONG64 *Base,LONG64 Offset);
+    BOOLEAN InterlockedBitTestAndReset64(volatile LONG64 *Base,LONG64 Offset);
+    BOOLEAN InterlockedBitTestAndComplement64(volatile LONG64 *Base,LONG64 
Bit);
     BOOLEAN _interlockedbittestandset64(LONG64 *Base,LONG64 Offset);
     BOOLEAN _interlockedbittestandreset64(LONG64 *Base,LONG64 Offset);
+    BOOLEAN _interlockedbittestandcomplement64(LONG64 *Base,LONG64 Bit);
 #ifndef __CRT__NO_INLINE
-    __CRT_INLINE BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btcl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Bit) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
     __CRT_INLINE BOOLEAN _bittestandset(LONG *Base,LONG Offset) {
       int old = 0;
       __asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0 "
@@ -1240,20 +1236,14 @@
        :"Ir" (Offset) : "memory");
       return (BOOLEAN) (old!=0);
     }
-    __CRT_INLINE BOOLEAN _interlockedbittestandset(LONG *Base,LONG Offset) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btsl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Offset) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
-    __CRT_INLINE BOOLEAN _interlockedbittestandreset(LONG *Base,LONG Offset) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btrl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Offset) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
+    __CRT_INLINE __buildbittesti(_interlockedbittestandset, __LONG32, "lock 
bts", "I", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandreset, __LONG32, "lock 
btr", "I", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandcomplement, __LONG32, 
"lock btc", "I", /* unused param */)
+
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndSet, __LONG32, "lock 
bts", "I", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndReset, __LONG32, "lock 
btr", "I", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndComplement, __LONG32, 
"lock btc", "I", volatile)
+
     __CRT_INLINE BOOLEAN _bittest64(LONG64 const *Base,LONG64 Offset) {
       int old = 0;
       __asm__ __volatile__("btq %2,%1\n\tsbbl %0,%0 "
@@ -1282,20 +1272,14 @@
        :"Ir" (Offset) : "memory");
       return (BOOLEAN) (old!=0);
     }
-    __CRT_INLINE BOOLEAN _interlockedbittestandset64(LONG64 *Base,LONG64 
Offset) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btsq %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile LONG64 *) Base))
-       :"Ir" (Offset) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
-    __CRT_INLINE BOOLEAN _interlockedbittestandreset64(LONG64 *Base,LONG64 
Offset) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btrq %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile LONG64 *) Base))
-       :"Ir" (Offset) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
+    __CRT_INLINE __buildbittesti(_interlockedbittestandset64, LONG64, "lock 
bts", "J", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandreset64, LONG64, "lock 
btr", "J", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandcomplement64, LONG64, 
"lock btc", "J", /* unused param */)
+
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndSet64, LONG64, "lock 
bts", "J", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndReset64, LONG64, "lock 
btr", "J", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndComplement64, LONG64, 
"lock btc", "J", volatile)
+
 #endif /* !__CRT__NO_INLINE */
 
 #define BitScanForward _BitScanForward
@@ -1418,13 +1402,13 @@
       return prev;
     }
 
-__CRT_INLINE __buildlogicali(InterlockedAnd, LONG, and)
-__CRT_INLINE __buildlogicali(InterlockedOr, LONG, or)
-__CRT_INLINE __buildlogicali(InterlockedXor, LONG, xor)
+    __CRT_INLINE __buildlogicali(InterlockedAnd, LONG, and)
+    __CRT_INLINE __buildlogicali(InterlockedOr, LONG, or)
+    __CRT_INLINE __buildlogicali(InterlockedXor, LONG, xor)
 
-__CRT_INLINE __buildlogicali(InterlockedAnd64, LONG64, and)
-__CRT_INLINE __buildlogicali(InterlockedOr64, LONG64, or)
-__CRT_INLINE __buildlogicali(InterlockedXor64, LONG64, xor)
+    __CRT_INLINE __buildlogicali(InterlockedAnd64, LONG64, and)
+    __CRT_INLINE __buildlogicali(InterlockedOr64, LONG64, or)
+    __CRT_INLINE __buildlogicali(InterlockedXor64, LONG64, xor)
 #endif /* !__CRT__NO_INLINE */
 
     LONG InterlockedExchangeAdd(LONG volatile *Addend,LONG Value);
@@ -1809,8 +1793,6 @@
 #define BitTestAndComplement _bittestandcomplement
 #define BitTestAndSet _bittestandset
 #define BitTestAndReset _bittestandreset
-#define InterlockedBitTestAndSet _interlockedbittestandset
-#define InterlockedBitTestAndReset _interlockedbittestandreset
 
 #define BitScanForward _BitScanForward
 #define BitScanReverse _BitScanReverse
@@ -1822,35 +1804,21 @@
 #define InterlockedIncrementAcquire InterlockedIncrement
 #define InterlockedIncrementRelease InterlockedIncrement
 
-    BOOLEAN InterlockedBitTestAndSet(LONG *Base,LONG Bit);
-    BOOLEAN InterlockedBitTestAndReset(LONG *Base,LONG Bit);
+    BOOLEAN _interlockedbittestandset(LONG *Base,LONG Bit);
+    BOOLEAN _interlockedbittestandreset(LONG *Base,LONG Bit);
+    BOOLEAN _interlockedbittestandcomplement(LONG *Base,LONG Bit);
+
+    BOOLEAN InterlockedBitTestAndSet(volatile LONG *Base,LONG Bit);
+    BOOLEAN InterlockedBitTestAndReset(volatile LONG *Base,LONG Bit);
+    BOOLEAN InterlockedBitTestAndComplement(volatile LONG *Base,LONG Bit);
 #ifndef __CRT__NO_INLINE
-    __CRT_INLINE BOOLEAN InterlockedBitTestAndSet(LONG *Base,LONG Bit) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btsl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Bit) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
+    __CRT_INLINE __buildbittesti(_interlockedbittestandset, LONG, "lock bts", 
"I", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandreset, LONG, "lock 
btr", "I", /* unused param */)
+    __CRT_INLINE __buildbittesti(_interlockedbittestandcomplement, LONG, "lock 
btc", "I", /* unused param */)
 
-    __CRT_INLINE BOOLEAN InterlockedBitTestAndReset(LONG *Base,LONG Bit) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btrl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Bit) : "memory");
-      return (BOOLEAN) (old!=0);
-    }
-#endif /* __CRT__NO_INLINE */
-
-    BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit);
-#ifndef __CRT__NO_INLINE
-    __CRT_INLINE BOOLEAN InterlockedBitTestAndComplement(LONG *Base,LONG Bit) {
-      int old = 0;
-      __asm__ __volatile__("lock ; btcl %2,%1\n\tsbbl %0,%0 "
-       :"=r" (old),"=m" ((*(volatile __LONG32 *) Base))
-       :"Ir" (Bit));
-      return (BOOLEAN) (old!=0);
-    }
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndSet, LONG, "lock bts", 
"I", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndReset, LONG, "lock btr", 
"I", volatile)
+    __CRT_INLINE __buildbittesti(InterlockedBitTestAndComplement, LONG, "lock 
btc", "I", volatile)
 #endif /* !__CRT__NO_INLINE */
 
 #ifdef _PREFIX_
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to