]> granicus.if.org Git - clang/commitdiff
MS intrinsics: __interlockedbittestandset(64) (PR19054)
authorHans Wennborg <hans@hanshq.net>
Thu, 13 Mar 2014 17:05:09 +0000 (17:05 +0000)
committerHans Wennborg <hans@hanshq.net>
Thu, 13 Mar 2014 17:05:09 +0000 (17:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203816 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Headers/Intrin.h

index b159fbb8c85a461aff80947a18ccccc1e7f94674..2ed88301cf9b657a2d6b6a1747e1af137be3ced5 100644 (file)
@@ -195,6 +195,7 @@ short _InterlockedAnd16(short volatile *_Value, short _Mask);
 static __inline__
 char _InterlockedAnd8(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset(long volatile *, long);
+static __inline__
 unsigned char _interlockedbittestandset(long volatile *, long);
 static __inline__
 long __cdecl _InterlockedCompareExchange(long volatile *_Destination,
@@ -390,6 +391,7 @@ short _InterlockedAnd16_np(short volatile *_Value, short _Mask);
 __int64 _InterlockedAnd64_np(__int64 volatile *_Value, __int64 _Mask);
 char _InterlockedAnd8_np(char volatile *_Value, char _Mask);
 unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64);
+static __inline__
 unsigned char _interlockedbittestandset64(__int64 volatile *, __int64);
 long _InterlockedCompareExchange_np(long volatile *_Destination, long _Exchange,
                                     long _Comparand);
@@ -572,6 +574,16 @@ _bittestandset(long *a, long b) {
   *a = *a | (1 << b);
   return x;
 }
+static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
+_interlockedbittestandset(long volatile *__BitBase, long __BitPos) {
+  unsigned char __Res;
+  __asm__ ("xor %0, %0\n"
+           "lock bts %2, %1\n"
+           "setc %0\n"
+           : "=r" (__Res), "+m"(*__BitBase)
+           : "Ir"(__BitPos));
+  return __Res;
+}
 #ifdef __x86_64__
 static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
 _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask) {
@@ -621,6 +633,16 @@ _bittestandset64(__int64 *a, __int64 b) {
   *a = *a | (1ll << b);
   return x;
 }
+static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
+_interlockedbittestandset64(__int64 volatile *__BitBase, __int64 __BitPos) {
+  unsigned char __Res;
+  __asm__ ("xor %0, %0\n"
+           "lock bts %2, %1\n"
+           "setc %0\n"
+           : "=r" (__Res), "+m"(*__BitBase)
+           : "Ir"(__BitPos));
+  return __Res;
+}
 #endif
 /*----------------------------------------------------------------------------*\
 |* Interlocked Exchange Add