1) Move these functions to intrin-impl.h:
_InterlockedIncrement16, _InterlockedDecrement16, _InterlockedCompareExchange16, _InterlockedIncrement, _InterlockedDecrement, _InterlockedExchange, _InterlockedExchangeAdd, _InterlockedCompareExchange, _InterlockedIncrement64, _InterlockedDecrement64, _InterlockedExchangeAdd64, _InterlockedExchange64, _InterlockedCompareExchange64, _InterlockedExchangePointer, _InterlockedCompareExchangePointer
2) Change these functions to use builtins instead of inline asm.
3) Remove non-underscore and __stdcall versions of these functions from intrinsics\*.c
4) For x86 versions of InterlockedCompareExchange, InterlockedCompareExchange64, InterlockedDecrement, InterlockedExchange, InterlockedExchangeAdd, InterlockedIncrement, use macro to map to intrinsics instead of using kernel32.dll (as MS does).
git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5949 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-crt/intrincs/ilockcxch.c b/mingw-w64-crt/intrincs/ilockcxch.c
index 68c8fad..3998df5 100644
--- a/mingw-w64-crt/intrincs/ilockcxch.c
+++ b/mingw-w64-crt/intrincs/ilockcxch.c
@@ -1,13 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-__LONG32 _InterlockedCompareExchange(__LONG32 volatile *Destination, __LONG32 ExChange, __LONG32 Comperand)
-{
- __LONG32 prev;
- __asm__ __volatile__("lock ; cmpxchgl %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedCompareExchange(__LONG32 volatile *, __LONG32, __LONG32) __attribute__((alias("_InterlockedCompareExchange")));
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockcxch16.c b/mingw-w64-crt/intrincs/ilockcxch16.c
index 6fe760a..357e5ba 100644
--- a/mingw-w64-crt/intrincs/ilockcxch16.c
+++ b/mingw-w64-crt/intrincs/ilockcxch16.c
@@ -1,14 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange16 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-short _InterlockedCompareExchange16(short volatile *Destination, short ExChange, short Comperand)
-{
- short prev;
- __asm__ __volatile__("lock ; cmpxchgw %w1,%2"
- :"=a"(prev)
- :"q"(ExChange), "m"(*Destination), "0"(Comperand)
- : "memory");
- return prev;
-}
-
-short InterlockedCompareExchange16(short volatile *, short, short) __attribute__((alias("_InterlockedCompareExchange16")));
-
diff --git a/mingw-w64-crt/intrincs/ilockcxch2.c b/mingw-w64-crt/intrincs/ilockcxch2.c
index 75a1e84..8dc4260 100644
--- a/mingw-w64-crt/intrincs/ilockcxch2.c
+++ b/mingw-w64-crt/intrincs/ilockcxch2.c
@@ -1,3 +1,5 @@
+/* todo - delete this file. All __stdcalls of this method get macro'ed to the intrinsic.
+
#include <intrin.h>
#ifndef _WIN64
@@ -10,3 +12,4 @@
return prev;
}
#endif
+*/
diff --git a/mingw-w64-crt/intrincs/ilockcxch64.c b/mingw-w64-crt/intrincs/ilockcxch64.c
index d69dce5..f9e2134 100644
--- a/mingw-w64-crt/intrincs/ilockcxch64.c
+++ b/mingw-w64-crt/intrincs/ilockcxch64.c
@@ -1,41 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange64 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-__int64 _InterlockedCompareExchange64(__int64 volatile *Destination, __int64 ExChange, __int64 Comperand)
-{
- __int64 prev;
- __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
-}
-#else
-__int64 _InterlockedCompareExchange64(volatile __int64 *Destination, __int64 Exchange, __int64 Comperand);
-
-__int64 _InterlockedCompareExchange64(volatile __int64 *Destination, __int64 Exchange, __int64 Comperand)
-{
- __int64 retval = Comperand;
- __asm__ __volatile__
- (
- "lock; cmpxchg8b %[Destination]" :
- [retval] "+A" (retval) :
- [Destination] "m" (*Destination),
- "b" ((unsigned __LONG32)((Exchange >> 0) & 0xFFFFFFFF)),
- "c" ((unsigned __LONG32)((Exchange >> 32) & 0xFFFFFFFF)) :
- "memory"
- );
-
- return retval;
-}
-#endif
-
-#ifdef _WIN64
-__int64 InterlockedCompareExchange64(__int64 volatile *, __int64, __int64) __attribute__((alias("_InterlockedCompareExchange64")));
-#else
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 ExChange, __int64 Comperand);
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 ExChange, __int64 Comperand)
-{
- return _InterlockedCompareExchange64 (Destination, ExChange, Comperand);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockcxchptr.c b/mingw-w64-crt/intrincs/ilockcxchptr.c
index e727763..bc8f4f9 100644
--- a/mingw-w64-crt/intrincs/ilockcxchptr.c
+++ b/mingw-w64-crt/intrincs/ilockcxchptr.c
@@ -1,30 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchangePointer /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-void *_InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand)
-{
- void *prev;
- __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
-}
-#else
-void *_InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand);
-
-void *_InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand)
-{
- void *prev;
- __asm__ __volatile__("lock ; cmpxchgl %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
-}
-#endif
-
-#ifdef _WIN64
-void *InterlockedCompareExchangePointer(void * volatile *, void *, void *) __attribute__((alias("_InterlockedCompareExchangePointer")));
-#else
-void * __stdcall InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand);
-void * __stdcall InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand)
-{
- return _InterlockedCompareExchangePointer(Destination, ExChange, Comperand);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockdec.c b/mingw-w64-crt/intrincs/ilockdec.c
index 7d89495..97b2624 100644
--- a/mingw-w64-crt/intrincs/ilockdec.c
+++ b/mingw-w64-crt/intrincs/ilockdec.c
@@ -1,22 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedDecrement /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-__LONG32 _InterlockedDecrement(__LONG32 volatile *Addend)
-{
- __LONG32 ret = -1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1;
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedDecrement(__LONG32 volatile *) __attribute__((alias("_InterlockedDecrement")));
-#else
-__LONG32 __stdcall InterlockedDecrement(__LONG32 volatile *Addend);
-__LONG32 __stdcall InterlockedDecrement(__LONG32 volatile *Addend)
-{
- return _InterlockedDecrement(Addend);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockdec16.c b/mingw-w64-crt/intrincs/ilockdec16.c
index 6362271..bd29ac5 100644
--- a/mingw-w64-crt/intrincs/ilockdec16.c
+++ b/mingw-w64-crt/intrincs/ilockdec16.c
@@ -1,14 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedDecrement16 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-short _InterlockedDecrement16(short volatile *Addend)
-{
- short ret = -1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddw %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1;
-}
-
-short InterlockedDecrement16(short volatile *) __attribute__((alias("_InterlockedDecrement16")));
-
diff --git a/mingw-w64-crt/intrincs/ilockdec64.c b/mingw-w64-crt/intrincs/ilockdec64.c
index c7b28ea..7141699 100644
--- a/mingw-w64-crt/intrincs/ilockdec64.c
+++ b/mingw-w64-crt/intrincs/ilockdec64.c
@@ -1,36 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedDecrement64 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-__int64 _InterlockedDecrement64(__int64 volatile *Addend)
-{
- __int64 ret = -1LL;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1LL;
-}
-#else
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 Exchange, __int64 Comperand);
-__int64 _InterlockedDecrement64(__int64 volatile *Addend);
-__int64 _InterlockedDecrement64(__int64 volatile *Addend)
-{
- __int64 Old;
- do {
- Old = *Addend;
- } while(InterlockedCompareExchange64(Addend,Old - 1,Old)!=Old);
- return Old - 1;
-}
-#endif
-
-#ifdef _WIN64
-__int64 InterlockedDecrement64(__int64 volatile *) __attribute__((alias("_InterlockedDecrement64")));
-#else
-__int64 __stdcall InterlockedDecrement64(__int64 volatile *Addend);
-__int64 __stdcall InterlockedDecrement64(__int64 volatile *Addend)
-{
- return _InterlockedDecrement64(Addend);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockexch.c b/mingw-w64-crt/intrincs/ilockexch.c
index ab58625..7731baf 100644
--- a/mingw-w64-crt/intrincs/ilockexch.c
+++ b/mingw-w64-crt/intrincs/ilockexch.c
@@ -1,21 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedExchange /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-__LONG32 _InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value)
-{
- __asm__ __volatile("lock ; xchgl %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedExchange(__LONG32 volatile *, __LONG32) __attribute__((alias("_InterlockedExchange")));
-#else
-__LONG32 __stdcall InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value);
-__LONG32 __stdcall InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value)
-{
- return _InterlockedExchange(Target,Value);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockexch64.c b/mingw-w64-crt/intrincs/ilockexch64.c
index d543611..38a85ac 100644
--- a/mingw-w64-crt/intrincs/ilockexch64.c
+++ b/mingw-w64-crt/intrincs/ilockexch64.c
@@ -1,35 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedExchange64 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-__int64 _InterlockedExchange64(__int64 volatile *Target, __int64 Value)
-{
- __asm__ __volatile("lock ; xchgq %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
-}
-#else
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 Exchange, __int64 Comperand);
-__int64 _InterlockedExchange64(__int64 volatile *Target,__int64 Value);
-__int64 _InterlockedExchange64(__int64 volatile *Target,__int64 Value)
-{
- __int64 Old;
- do {
- Old = *Target;
- } while(InterlockedCompareExchange64(Target,Value,Old)!=Old);
- return Old;
-}
-#endif
-
-#ifdef _WIN64
-__int64 InterlockedExchange64(__int64 volatile *, __int64) __attribute__((alias("_InterlockedExchange64")));
-#else
-__int64 __stdcall InterlockedExchange64(__int64 volatile *Target, __int64 Value);
-__int64 __stdcall InterlockedExchange64(__int64 volatile *Target, __int64 Value)
-{
- return _InterlockedExchange64(Target, Value);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockexchadd.c b/mingw-w64-crt/intrincs/ilockexchadd.c
index 21fcc54..5b57e69 100644
--- a/mingw-w64-crt/intrincs/ilockexchadd.c
+++ b/mingw-w64-crt/intrincs/ilockexchadd.c
@@ -1,24 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value);
-
-__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value)
-{
- __LONG32 ret;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,(%1)"
- : "=r" (ret)
- : "r" (Addend), "0" (Value)
- : "memory");
- return ret;
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedExchangeAdd(__LONG32 volatile *, __LONG32) __attribute__((alias("_InterlockedExchangeAdd")));
-#else
-__LONG32 __stdcall InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value);
-__LONG32 __stdcall InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value)
-{
- return _InterlockedExchangeAdd(Addend, Value);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockexchadd64.c b/mingw-w64-crt/intrincs/ilockexchadd64.c
index 62aa741..f427c08 100644
--- a/mingw-w64-crt/intrincs/ilockexchadd64.c
+++ b/mingw-w64-crt/intrincs/ilockexchadd64.c
@@ -1,37 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd64 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-__int64 _InterlockedExchangeAdd64(__int64 volatile *Addend, __int64 Value)
-{
- __int64 ret;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,(%1)"
- : "=r" (ret)
- : "r" (Addend), "0" (Value)
- : "memory");
- return ret;
-}
-#else
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 Exchange, __int64 Comperand);
-__int64 __cdecl _InterlockedExchangeAdd64(__int64 volatile *Addend,__int64 Value);
-__int64 __cdecl _InterlockedExchangeAdd64(__int64 volatile *Addend,__int64 Value)
-{
- __int64 Old;
- do {
- Old = *Addend;
- } while(InterlockedCompareExchange64(Addend,Old + Value,Old)!=Old);
- return Old;
-}
-#endif
-
-#ifdef _WIN64
-__int64 InterlockedExchangeAdd64(__int64 volatile *, __int64) __attribute__((alias("_InterlockedExchangeAdd64")));
-#else
-__int64 __stdcall InterlockedExchangeAdd64(__int64 volatile *Addend, __int64 Value);
-__int64 __stdcall InterlockedExchangeAdd64(__int64 volatile *Addend, __int64 Value)
-{
- return _InterlockedExchangeAdd64(Addend, Value);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockexchptr.c b/mingw-w64-crt/intrincs/ilockexchptr.c
index 1acdffc..cbd2b18 100644
--- a/mingw-w64-crt/intrincs/ilockexchptr.c
+++ b/mingw-w64-crt/intrincs/ilockexchptr.c
@@ -1,33 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedExchangePointer /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-void *_InterlockedExchangePointer(void * volatile *Target, void *Value)
-{
- __asm__ __volatile("lock ; xchgq %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
-}
-#else
-void *_InterlockedExchangePointer(void * volatile *Target, void *Value);
-void *_InterlockedExchangePointer(void * volatile *Target, void *Value)
-{
- __asm__ __volatile("lock ; xchgl %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
-}
-#endif
-
-#ifdef _WIN64
-void *InterlockedExchangePointer(void * volatile *, void *) __attribute__((alias("_InterlockedExchangePointer")));
-#else
-void * __stdcall InterlockedExchangePointer(void * volatile *Target, void *Value);
-void * __stdcall InterlockedExchangePointer(void * volatile *Target, void *Value)
-{
- return _InterlockedExchangePointer(Target, Value);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockinc.c b/mingw-w64-crt/intrincs/ilockinc.c
index 28a9d34..1deff75 100644
--- a/mingw-w64-crt/intrincs/ilockinc.c
+++ b/mingw-w64-crt/intrincs/ilockinc.c
@@ -1,22 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedIncrement /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-__LONG32 _InterlockedIncrement(__LONG32 volatile *Addend)
-{
- __LONG32 ret = 1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1;
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedIncrement(__LONG32 volatile *) __attribute__((alias("_InterlockedIncrement")));
-#else
-__LONG32 __stdcall InterlockedIncrement(__LONG32 volatile *Addend);
-__LONG32 __stdcall InterlockedIncrement(__LONG32 volatile *Addend)
-{
- return _InterlockedIncrement (Addend);
-}
-#endif
-
diff --git a/mingw-w64-crt/intrincs/ilockinc16.c b/mingw-w64-crt/intrincs/ilockinc16.c
index 65a75a6..6318400 100644
--- a/mingw-w64-crt/intrincs/ilockinc16.c
+++ b/mingw-w64-crt/intrincs/ilockinc16.c
@@ -1,14 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedIncrement16 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-short _InterlockedIncrement16(short volatile *Addend)
-{
- short ret = 1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddw %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1;
-}
-
-short InterlockedIncrement16(short volatile *) __attribute__((alias("_InterlockedIncrement16")));
-
diff --git a/mingw-w64-crt/intrincs/ilockinc64.c b/mingw-w64-crt/intrincs/ilockinc64.c
index a956538..04e646a 100644
--- a/mingw-w64-crt/intrincs/ilockinc64.c
+++ b/mingw-w64-crt/intrincs/ilockinc64.c
@@ -1,36 +1,4 @@
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedIncrement64 /* Causes code generation in intrin-impl.h */
+
#include <intrin.h>
-
-#ifdef _WIN64
-__int64 _InterlockedIncrement64(__int64 volatile *Addend)
-{
- __int64 ret = 1LL;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1LL;
-}
-#else
-__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
- __int64 Exchange, __int64 Comperand);
-__int64 _InterlockedIncrement64(__int64 volatile *Addend);
-__int64 _InterlockedIncrement64(__int64 volatile *Addend)
-{
- __int64 Old;
- do {
- Old = *Addend;
- } while(InterlockedCompareExchange64(Addend,Old + 1,Old)!=Old);
- return Old + 1;
-}
-#endif
-
-#ifdef _WIN64
-__int64 InterlockedIncrement64(__int64 volatile *) __attribute__((alias("_InterlockedIncrement64")));
-#else
-__int64 __stdcall InterlockedIncrement64(__int64 volatile *Addend);
-__int64 __stdcall InterlockedIncrement64(__int64 volatile *Addend)
-{
- return _InterlockedIncrement64(Addend);
-}
-#endif
-
diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h
index 79deaac..cd0bc5a 100644
--- a/mingw-w64-headers/crt/intrin.h
+++ b/mingw-w64-headers/crt/intrin.h
@@ -281,33 +281,33 @@
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedAdd64(__int64 volatile *,__int64))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedAdd64_acq(__int64 volatile *,__int64))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedAdd64_rel(__int64 volatile *,__int64))
- __MACHINEI(__LONG32 __cdecl _InterlockedDecrement(__LONG32 volatile *))
+ /* __MACHINEI(__LONG32 __cdecl _InterlockedDecrement(__LONG32 volatile *)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(long _InterlockedDecrement(long volatile *))
__MACHINEIA64(long _InterlockedDecrement_acq(long volatile *))
__MACHINEIA64(long _InterlockedDecrement_rel(long volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedDecrement64(__int64 volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedDecrement64_acq(__int64 volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedDecrement64_rel(__int64 volatile *))
- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedDecrement64(__int64 volatile *))
- __MACHINEI(__LONG32 _InterlockedExchange(__LONG32 volatile *,__LONG32))
+ /* __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedDecrement64(__int64 volatile *)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEI(__LONG32 _InterlockedExchange(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(long _InterlockedExchange(long volatile *,long))
__MACHINEIA64(long _InterlockedExchange_acq(long volatile *,long))
__MACHINESA(long WINAPI _InterlockedExchange(long volatile *,long))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedExchange64(__int64 volatile *,__int64))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedExchange64_acq(__int64 volatile *,__int64))
- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchange64(__int64 volatile *,__int64))
+ /* __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchange64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(void *_InterlockedExchangePointer(void *volatile *,void *))
__MACHINEIA64(void *_InterlockedExchangePointer_acq(void *volatile *,void volatile *))
- __MACHINEX64(void *_InterlockedExchangePointer(void *volatile *,void *))
- __MACHINEI(__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *,__LONG32))
+ /* __MACHINEX64(void *_InterlockedExchangePointer(void *volatile *,void *)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEI(__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(long _InterlockedExchangeAdd(long volatile *,long))
__MACHINEIA64(long _InterlockedExchangeAdd_acq(long volatile *,long))
__MACHINEIA64(long _InterlockedExchangeAdd_rel(long volatile *,long))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64(__int64 volatile *,__int64))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64_acq(__int64 volatile *,__int64))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64_rel(__int64 volatile *,__int64))
- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64(__int64 volatile *,__int64))
- __MACHINEI(__LONG32 _InterlockedCompareExchange (__LONG32 volatile *,__LONG32,__LONG32))
+ /* __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEI(__LONG32 _InterlockedCompareExchange (__LONG32 volatile *,__LONG32,__LONG32)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(long _InterlockedCompareExchange (long volatile *,long,long))
__MACHINEIA64(long _InterlockedCompareExchange_acq (long volatile *,long,long))
__MACHINEIA64(long _InterlockedCompareExchange_rel (long volatile *,long,long))
@@ -323,16 +323,16 @@
__MACHINEIA64(void *_InterlockedCompareExchangePointer (void *volatile *,void *,void *))
__MACHINEIA64(void *_InterlockedCompareExchangePointer_acq (void *volatile *,void *,void *))
__MACHINEIA64(void *_InterlockedCompareExchangePointer_rel (void *volatile *,void *,void *))
- __MACHINEI(__MINGW_EXTENSION __int64 _InterlockedCompareExchange64(__int64 volatile *,__int64,__int64))
- __MACHINEX64(void *_InterlockedCompareExchangePointer (void *volatile *,void *,void *))
- __MACHINEI(__LONG32 __cdecl _InterlockedIncrement(__LONG32 volatile *))
+ /* __MACHINEI(__MINGW_EXTENSION __int64 _InterlockedCompareExchange64(__int64 volatile *,__int64,__int64)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEX64(void *_InterlockedCompareExchangePointer (void *volatile *,void *,void *)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEI(__LONG32 __cdecl _InterlockedIncrement(__LONG32 volatile *)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(long _InterlockedIncrement(long volatile *))
__MACHINEIA64(long _InterlockedIncrement_acq(long volatile *))
__MACHINEIA64(long _InterlockedIncrement_rel(long volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedIncrement64(__int64 volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedIncrement64_acq(__int64 volatile *))
__MACHINEIA64(__MINGW_EXTENSION __int64 _InterlockedIncrement64_rel(__int64 volatile *))
- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedIncrement64(__int64 volatile *))
+ /* __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedIncrement64(__int64 volatile *)) moved to psdk_inc/intrin-impl.h */
/* __MACHINEIW64(__LONG32 _InterlockedOr(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h */
__MACHINEIW64(char _InterlockedOr8(char volatile *,char))
__MACHINEIW64(short _InterlockedOr16(short volatile *,short))
@@ -1110,9 +1110,9 @@
__MACHINEIW64(unsigned short _rotr16(unsigned short value,unsigned char shift))
__MACHINEIW64(unsigned char _rotl8(unsigned char value,unsigned char shift))
__MACHINEIW64(unsigned short _rotl16(unsigned short value,unsigned char shift))
- __MACHINEIW64(short _InterlockedIncrement16(short volatile *Addend))
- __MACHINEIW64(short _InterlockedDecrement16(short volatile *Addend))
- __MACHINEIW64(short _InterlockedCompareExchange16(short volatile *Destination,short Exchange,short Comparand))
+ /* __MACHINEIW64(short _InterlockedIncrement16(short volatile *Addend)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEIW64(short _InterlockedDecrement16(short volatile *Addend)) moved to psdk_inc/intrin-impl.h */
+ /* __MACHINEIW64(short _InterlockedCompareExchange16(short volatile *Destination,short Exchange,short Comparand)) moved to psdk_inc/intrin-impl.h */
__MACHINEIA64(short _InterlockedIncrement16_acq(short volatile *Addend))
__MACHINEIA64(short _InterlockedIncrement16_rel(short volatile *Addend))
__MACHINEIA64(short _InterlockedDecrement16_acq(short volatile *Addend))
diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index 276304f..495f56f 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -132,6 +132,21 @@
#define __INTRINSIC_SPECIAL_InterlockedBitTestAndReset64
#define __INTRINSIC_SPECIAL_InterlockedBitTestAndSet
#define __INTRINSIC_SPECIAL_InterlockedBitTestAndSet64
+#define __INTRINSIC_SPECIAL__InterlockedIncrement16
+#define __INTRINSIC_SPECIAL__InterlockedDecrement16
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange16
+#define __INTRINSIC_SPECIAL__InterlockedIncrement
+#define __INTRINSIC_SPECIAL__InterlockedDecrement
+#define __INTRINSIC_SPECIAL__InterlockedExchange
+#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange
+#define __INTRINSIC_SPECIAL__InterlockedIncrement64
+#define __INTRINSIC_SPECIAL__InterlockedDecrement64
+#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd64
+#define __INTRINSIC_SPECIAL__InterlockedExchange64
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchange64
+#define __INTRINSIC_SPECIAL__InterlockedExchangePointer
+#define __INTRINSIC_SPECIAL__InterlockedCompareExchangePointer
#endif /* __INTRINSIC_GROUP_WINNT */
@@ -226,6 +241,42 @@
#define __INTRINSIC_DEFINED__InterlockedXor64
#endif /* __INTRINSIC_PROLOG */
+#if __INTRINSIC_PROLOG(_InterlockedIncrement64)
+__MINGW_EXTENSION __int64 _InterlockedIncrement64(__int64 volatile *Addend);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedIncrement64(__int64 volatile *Addend) {
+ return __sync_add_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedIncrement64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedDecrement64)
+__MINGW_EXTENSION __int64 _InterlockedDecrement64(__int64 volatile *Addend);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedDecrement64(__int64 volatile *Addend) {
+ return __sync_sub_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedDecrement64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedExchange64)
+__MINGW_EXTENSION __int64 _InterlockedExchange64(__int64 volatile *Target, __int64 Value);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedExchange64(__int64 volatile *Target, __int64 Value) {
+ return __sync_lock_test_and_set(Target, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedExchange64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedExchangeAdd64)
+__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64(__int64 volatile *Addend, __int64 Value);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedExchangeAdd64(__int64 volatile *Addend, __int64 Value) {
+ return __sync_fetch_and_add(Addend, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedExchangeAdd64
+#endif /* __INTRINSIC_PROLOG */
+
#endif // __x86_64__
/* ***************************************************** */
@@ -325,6 +376,105 @@
#define __INTRINSIC_DEFINED__InterlockedXor
#endif /* __INTRINSIC_PROLOG */
+#if __INTRINSIC_PROLOG(_InterlockedIncrement16)
+short _InterlockedIncrement16(short volatile *Addend);
+__INTRINSICS_USEINLINE
+short _InterlockedIncrement16(short volatile *Addend) {
+ return __sync_add_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedIncrement16
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedDecrement16)
+short _InterlockedDecrement16(short volatile *Addend);
+__INTRINSICS_USEINLINE
+short _InterlockedDecrement16(short volatile *Addend) {
+ return __sync_sub_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedDecrement16
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedCompareExchange16)
+short _InterlockedCompareExchange16(short volatile *Destination, short ExChange, short Comperand);
+__INTRINSICS_USEINLINE
+short _InterlockedCompareExchange16(short volatile *Destination, short ExChange, short Comperand) {
+ return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
+}
+#define __INTRINSIC_DEFINED__InterlockedCompareExchange16
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedExchangeAdd)
+__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value);
+__INTRINSICS_USEINLINE
+__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *Addend, __LONG32 Value) {
+ return __sync_fetch_and_add(Addend, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedExchangeAdd
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedCompareExchange)
+__LONG32 _InterlockedCompareExchange(__LONG32 volatile *Destination, __LONG32 ExChange, __LONG32 Comperand);
+__INTRINSICS_USEINLINE
+__LONG32 _InterlockedCompareExchange(__LONG32 volatile *Destination, __LONG32 ExChange, __LONG32 Comperand) {
+ return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
+}
+#define __INTRINSIC_DEFINED__InterlockedCompareExchange
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedIncrement)
+__LONG32 _InterlockedIncrement(__LONG32 volatile *Addend);
+__INTRINSICS_USEINLINE
+__LONG32 _InterlockedIncrement(__LONG32 volatile *Addend) {
+ return __sync_add_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedIncrement
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedDecrement)
+__LONG32 _InterlockedDecrement(__LONG32 volatile *Addend);
+__INTRINSICS_USEINLINE
+__LONG32 _InterlockedDecrement(__LONG32 volatile *Addend) {
+ return __sync_sub_and_fetch(Addend, 1);
+}
+#define __INTRINSIC_DEFINED__InterlockedDecrement
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedExchange)
+__LONG32 _InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value);
+__INTRINSICS_USEINLINE
+__LONG32 _InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value) {
+ return __sync_lock_test_and_set(Target, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedExchange
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedCompareExchange64)
+__MINGW_EXTENSION __int64 _InterlockedCompareExchange64(__int64 volatile *Destination, __int64 ExChange, __int64 Comperand);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedCompareExchange64(__int64 volatile *Destination, __int64 ExChange, __int64 Comperand) {
+ return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
+}
+#define __INTRINSIC_DEFINED__InterlockedCompareExchange64
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedCompareExchangePointer)
+void *_InterlockedCompareExchangePointer(void * volatile *Destination, void *ExChange, void *Comperand);
+__INTRINSICS_USEINLINE
+void *_InterlockedCompareExchangePointer(void *volatile *Destination, void *ExChange, void *Comperand) {
+ return __sync_val_compare_and_swap(Destination, Comperand, ExChange);
+}
+#define __INTRINSIC_DEFINED__InterlockedCompareExchangePointer
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedExchangePointer)
+void *_InterlockedExchangePointer(void *volatile *Target,void *Value);
+__INTRINSICS_USEINLINE
+void *_InterlockedExchangePointer(void *volatile *Target,void *Value) {
+ return __sync_lock_test_and_set(Target, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedExchangePointer
+#endif /* __INTRINSIC_PROLOG */
+
#endif // defined(__x86_64__) || (defined(_X86_)
#ifdef __cplusplus
diff --git a/mingw-w64-headers/include/winbase.h b/mingw-w64-headers/include/winbase.h
index 5f5d87e..aa41b20 100644
--- a/mingw-w64-headers/include/winbase.h
+++ b/mingw-w64-headers/include/winbase.h
@@ -995,15 +995,28 @@
#else /* not ia64, nor x64. */
- LONG WINAPI InterlockedIncrement(LONG volatile *lpAddend);
- LONG WINAPI InterlockedDecrement(LONG volatile *lpAddend);
- LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value);
+/* While MS resolves these 3 from kernel32.dll, we are mapping them
+to intrinsics. */
+#define InterlockedIncrement _InterlockedIncrement
+#define InterlockedDecrement _InterlockedDecrement
+#define InterlockedExchange _InterlockedExchange
+
+ /* LONG WINAPI InterlockedIncrement(LONG volatile *lpAddend); mapped to intrinsic */
+ /* LONG WINAPI InterlockedDecrement(LONG volatile *lpAddend); mapped to intrinsic */
+ /* LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value); mapped to intrinsic */
#define InterlockedExchangePointer(Target,Value) (PVOID)InterlockedExchange((PLONG)(Target),(LONG)(Value))
- LONG WINAPI InterlockedExchangeAdd(LONG volatile *Addend,LONG Value);
- LONG WINAPI InterlockedCompareExchange(LONG volatile *Destination,LONG Exchange,LONG Comperand);
- LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile *Destination,LONGLONG Exchange,LONGLONG Comperand);
+/* While MS resolves these 3 from kernel32.dll, we are mapping them
+to intrinsics. */
+#define InterlockedExchangeAdd _InterlockedExchangeAdd
+#define InterlockedCompareExchange _InterlockedCompareExchange
+#define InterlockedCompareExchange64 _InterlockedCompareExchange64
+
+ /* LONG WINAPI InterlockedExchangeAdd(LONG volatile *Addend,LONG Value); mapped to intrinsic */
+ /* LONG WINAPI InterlockedCompareExchange(LONG volatile *Destination,LONG Exchange,LONG Comperand); mapped to intrinsic */
+ /* LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile *Destination,LONGLONG Exchange,LONGLONG Comperand); mapped to intrinsic */
+
LONGLONG WINAPI InterlockedAnd64 (LONGLONG volatile *Destination,LONGLONG Value);
LONGLONG WINAPI InterlockedOr64 (LONGLONG volatile *Destination,LONGLONG Value);
LONGLONG WINAPI InterlockedXor64 (LONGLONG volatile *Destination,LONGLONG Value);
diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h
index 5ade211..cb83d5b 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -1337,105 +1337,29 @@
#define InterlockedIncrementSizeT(a) InterlockedIncrement64((LONG64 *)a)
#define InterlockedDecrementSizeT(a) InterlockedDecrement64((LONG64 *)a)
- SHORT InterlockedIncrement16(SHORT volatile *Addend);
- SHORT InterlockedDecrement16(SHORT volatile *Addend);
- SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand);
- LONG InterlockedIncrement(LONG volatile *Addend);
- LONG InterlockedDecrement(LONG volatile *Addend);
- LONG InterlockedExchange(LONG volatile *Target,LONG Value);
+ /* SHORT InterlockedIncrement16(SHORT volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* SHORT InterlockedDecrement16(SHORT volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand); moved to psdk_inc/intrin-impl.h */
+ /* LONG InterlockedIncrement(LONG volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* LONG InterlockedDecrement(LONG volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* LONG InterlockedExchange(LONG volatile *Target,LONG Value); moved to psdk_inc/intrin-impl.h */
-#ifndef __CRT__NO_INLINE
- __CRT_INLINE SHORT InterlockedIncrement16(SHORT volatile *Addend) {
- SHORT ret = 1;
- __asm__ __volatile__("lock\n\t"
- "xaddw %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1;
- }
- __CRT_INLINE SHORT InterlockedDecrement16(SHORT volatile *Addend) {
- SHORT ret = -1;
- __asm__ __volatile__("lock\n\t"
- "xaddw %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1;
- }
- __CRT_INLINE SHORT InterlockedCompareExchange16(SHORT volatile *Destination,SHORT ExChange,SHORT Comperand) {
- SHORT prev;
- __asm__ __volatile__("lock ; cmpxchgw %w1,%2"
- :"=a"(prev)
- :"q"(ExChange), "m"(*Destination), "0"(Comperand)
- : "memory");
- return prev;
- }
-#endif /* !__CRT__NO_INLINE */
-
- LONG InterlockedExchangeAdd(LONG volatile *Addend,LONG Value);
- LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand);
+ /* LONG InterlockedExchangeAdd(LONG volatile *Addend,LONG Value); moved to psdk_inc/intrin-impl.h */
+ /* LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand); moved to psdk_inc/intrin-impl.h */
LONG InterlockedAdd(LONG volatile *Addend,LONG Value);
- LONG64 InterlockedIncrement64(LONG64 volatile *Addend);
- LONG64 InterlockedDecrement64(LONG64 volatile *Addend);
- LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value);
+ /* LONG64 InterlockedIncrement64(LONG64 volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* LONG64 InterlockedDecrement64(LONG64 volatile *Addend); moved to psdk_inc/intrin-impl.h */
+ /* LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value); moved to psdk_inc/intrin-impl.h */
-#ifndef __CRT__NO_INLINE
- __CRT_INLINE LONG InterlockedAdd(LONG volatile *Addend,LONG Value) { return InterlockedExchangeAdd(Addend,Value) + Value; }
- __CRT_INLINE LONG InterlockedCompareExchange(LONG volatile *Destination,LONG ExChange,LONG Comperand) {
- LONG prev;
- __asm__ __volatile__("lock ; cmpxchgl %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
- }
- __CRT_INLINE LONG64 InterlockedIncrement64(LONG64 volatile *Addend) {
- LONG64 ret = 1LL;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1LL;
- }
- __CRT_INLINE LONG64 InterlockedDecrement64(LONG64 volatile *Addend) {
- LONG64 ret = -1LL;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1LL;
- }
- __CRT_INLINE LONG64 InterlockedExchange64(LONG64 volatile *Target,LONG64 Value) {
- __asm__ __volatile("lock ; xchgq %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
- }
-#endif /* !__CRT__NO_INLINE */
+ __forceinline LONG InterlockedAdd(LONG volatile *Addend,LONG Value) { return InterlockedExchangeAdd(Addend,Value) + Value; }
- LONG64 InterlockedExchangeAdd64(LONG64 volatile *Addend,LONG64 Value);
+ /* LONG64 InterlockedExchangeAdd64(LONG64 volatile *Addend,LONG64 Value); moved to psdk_inc/intrin-impl.h */
LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value);
- LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand);
- PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand);
- PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value);
+ /* LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand); moved to psdk_inc/intrin-impl.h */
+ /* PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand); moved to psdk_inc/intrin-impl.h */
+ /* PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value); moved to psdk_inc/intrin-impl.h */
-#ifndef __CRT__NO_INLINE
- __CRT_INLINE LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value) { return InterlockedExchangeAdd64(Addend,Value) + Value; }
- __CRT_INLINE LONG64 InterlockedCompareExchange64(LONG64 volatile *Destination,LONG64 ExChange,LONG64 Comperand) {
- LONG64 prev;
- __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
- }
- __CRT_INLINE PVOID InterlockedCompareExchangePointer(PVOID volatile *Destination,PVOID ExChange,PVOID Comperand) {
- PVOID prev;
- __asm__ __volatile__("lock ; cmpxchgq %1,%2" : "=a" (prev) : "q" (ExChange),"m" (*Destination), "0" (Comperand) : "memory");
- return prev;
- }
- __CRT_INLINE PVOID InterlockedExchangePointer(PVOID volatile *Target,PVOID Value) {
- __asm__ __volatile("lock ; xchgq %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
- }
-#endif /* !__CRT__NO_INLINE */
+ __forceinline LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value) { return InterlockedExchangeAdd64(Addend,Value) + Value; }
#define CacheLineFlush(Address) _mm_clflush(Address)
@@ -1741,13 +1665,8 @@
#define BitScanForward _BitScanForward
#define BitScanReverse _BitScanReverse
-#define InterlockedIncrement16 _InterlockedIncrement16
-#define InterlockedDecrement16 _InterlockedDecrement16
#define InterlockedCompareExchange16 _InterlockedCompareExchange16
-#define InterlockedIncrementAcquire InterlockedIncrement
-#define InterlockedIncrementRelease InterlockedIncrement
-
#ifdef _PREFIX_
BYTE __readfsbyte(DWORD Offset);
WORD __readfsword(DWORD Offset);
@@ -1883,35 +1802,9 @@
#endif /* end of _X86_ */
- LONG WINAPI InterlockedIncrement(LONG volatile *);
- LONG WINAPI InterlockedDecrement(LONG volatile *);
- LONG WINAPI InterlockedExchange(LONG volatile *, LONG);
-
-#if defined(__MINGW_INTRIN_INLINE) && (defined(__i386__) || defined(__x86_64))
- __MINGW_INTRIN_INLINE LONG WINAPI InterlockedIncrement(LONG volatile *Addend) {
- LONG ret = 1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret + 1;
- }
- __MINGW_INTRIN_INLINE LONG WINAPI InterlockedDecrement(LONG volatile *Addend) {
- LONG ret = -1;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,%1"
- : "+r" (ret), "+m" (*Addend)
- : : "memory");
- return ret - 1;
- }
- __MINGW_INTRIN_INLINE LONG WINAPI InterlockedExchange(LONG volatile *Target,LONG Value) {
- __asm__ __volatile__ ("lock ; xchgl %0,%1"
- : "=r"(Value)
- : "m"(*Target),"0"(Value)
- : "memory");
- return Value;
- }
-#endif
+ /* LONG WINAPI InterlockedIncrement(LONG volatile *); moved to psdk_inc/intrin-impl.h */
+ /* LONG WINAPI InterlockedDecrement(LONG volatile *); moved to psdk_inc/intrin-impl.h */
+ /* LONG WINAPI InterlockedExchange(LONG volatile *, LONG); moved to psdk_inc/intrin-impl.h */
#ifndef _LDT_ENTRY_DEFINED
#define _LDT_ENTRY_DEFINED