---
mingw-w64-crt/intrincs/ilockadd.c | 31
+++---------------------
mingw-w64-crt/intrincs/ilockadd64.c | 19 +++------------
mingw-w64-headers/include/psdk_inc/intrin-impl.h | 22 +++++++++++++++++
mingw-w64-headers/include/winnt.h | 11 +++------
4 files changed, 32 insertions(+), 51 deletions(-)
diff --git a/mingw-w64-crt/intrincs/ilockadd.c b/mingw-w64-crt/intrincs/ilockadd.c
index 8e3d2f2..6c4806b 100644
--- a/mingw-w64-crt/intrincs/ilockadd.c
+++ b/mingw-w64-crt/intrincs/ilockadd.c
@@ -1,29 +1,4 @@
-#include <intrin.h>
-
-__LONG32 _InterlockedAdd(__LONG32 volatile *, __LONG32); /* not in intrin.h */
-__LONG32 _InterlockedAdd(__LONG32 volatile *Addend, __LONG32 Value)
-{
-/* return InterlockedExchangeAdd(Addend,Value) + Value; */
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_)
- __LONG32 ret;
- __asm__ __volatile__ ("lock\n\t"
- "xaddl %0,(%1)"
- : "=r" (ret)
- : "r" (Addend), "0" (Value)
- : "memory");
- return ret + Value;
-#else
- return __sync_fetch_and_add(Addend, Value) + Value;
-#endif
-}
-
-#ifdef _WIN64
-__LONG32 InterlockedAdd(__LONG32 volatile *, __LONG32) __attribute__((alias("_InterlockedAdd")));
-#else
-__LONG32 __stdcall InterlockedAdd(__LONG32 volatile *Addend, __LONG32 Value);
-__LONG32 __stdcall InterlockedAdd(__LONG32 volatile *Addend, __LONG32 Value)
-{
- return _InterlockedAdd(Addend, Value);
-}
-#endif
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedAdd /* Causes code generation in intrin-impl.h */
+#include <intrin.h>
diff --git a/mingw-w64-crt/intrincs/ilockadd64.c b/mingw-w64-crt/intrincs/ilockadd64.c
index 995753d..ad74acb 100644
--- a/mingw-w64-crt/intrincs/ilockadd64.c
+++ b/mingw-w64-crt/intrincs/ilockadd64.c
@@ -1,17 +1,4 @@
-#include <intrin.h>
-
-__int64 _InterlockedAdd64(__int64 volatile *, __int64); /* not in intrin.h */
-__int64 _InterlockedAdd64(__int64 volatile *Addend, __int64 Value)
-{
-/* return InterlockedExchangeAdd64(Addend,Value) + Value; */
- __int64 ret;
- __asm__ __volatile__ ("lock\n\t"
- "xaddq %0,(%1)"
- : "=r" (ret)
- : "r" (Addend), "0" (Value)
- : "memory");
- return ret + Value;
-}
-
-__int64 InterlockedAdd64(__int64 volatile *, __int64) __attribute__((alias("_InterlockedAdd64")));
+#define __INTRINSIC_ONLYSPECIAL
+#define __INTRINSIC_SPECIAL__InterlockedAdd64 /* Causes code generation in intrin-impl.h */
+#include <intrin.h>
diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index f570638..71d6096 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -430,11 +430,13 @@ supports ReadWriteBarrier, map all 3 to do the same. */
#define __INTRINSIC_SPECIAL__InterlockedCompareExchange16
#define __INTRINSIC_SPECIAL__InterlockedIncrement
#define __INTRINSIC_SPECIAL__InterlockedDecrement
+#define __INTRINSIC_SPECIAL__InterlockedAdd
#define __INTRINSIC_SPECIAL__InterlockedExchange
#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd
#define __INTRINSIC_SPECIAL__InterlockedCompareExchange
#define __INTRINSIC_SPECIAL__InterlockedIncrement64
#define __INTRINSIC_SPECIAL__InterlockedDecrement64
+#define __INTRINSIC_SPECIAL__InterlockedAdd64
#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd64
#define __INTRINSIC_SPECIAL__InterlockedExchange64
#define __INTRINSIC_SPECIAL__InterlockedCompareExchange64
@@ -481,6 +483,7 @@ supports ReadWriteBarrier, map all 3 to do the same. */
#define __INTRINSIC_SPECIAL__InterlockedIncrement
#define __INTRINSIC_SPECIAL__InterlockedDecrement
+#define __INTRINSIC_SPECIAL__InterlockedAdd
#define __INTRINSIC_SPECIAL__InterlockedExchange
#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd
#define __INTRINSIC_SPECIAL__InterlockedCompareExchange
@@ -491,6 +494,7 @@ supports ReadWriteBarrier, map all 3 to do the same. */
#define __INTRINSIC_SPECIAL__InterlockedXor64
#define __INTRINSIC_SPECIAL__InterlockedIncrement64
#define __INTRINSIC_SPECIAL__InterlockedDecrement64
+#define __INTRINSIC_SPECIAL__InterlockedAdd64
#define __INTRINSIC_SPECIAL__InterlockedExchange64
#define __INTRINSIC_SPECIAL__InterlockedExchangeAdd64
#define __INTRINSIC_SPECIAL__InterlockedCompareExchange64
@@ -992,6 +996,24 @@ __LONG32 _InterlockedDecrement(__LONG32 volatile *Addend) {
#define __INTRINSIC_DEFINED__InterlockedDecrement
#endif /* __INTRINSIC_PROLOG */
+#if __INTRINSIC_PROLOG(_InterlockedAdd)
+__MINGW_EXTENSION __LONG32 _InterlockedAdd(__LONG32 volatile *Addend, __LONG32 Value);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__LONG32 _InterlockedAdd(__LONG32 volatile *Addend, __LONG32 Value) {
+ return __sync_add_and_fetch(Addend, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedAdd
+#endif /* __INTRINSIC_PROLOG */
+
+#if __INTRINSIC_PROLOG(_InterlockedAdd64)
+__MINGW_EXTENSION __int64 _InterlockedAdd64(__int64 volatile *Addend, __int64 Value);
+__MINGW_EXTENSION __INTRINSICS_USEINLINE
+__int64 _InterlockedAdd64(__int64 volatile *Addend, __int64 Value) {
+ return __sync_add_and_fetch(Addend, Value);
+}
+#define __INTRINSIC_DEFINED__InterlockedAdd64
+#endif /* __INTRINSIC_PROLOG */
+
#if __INTRINSIC_PROLOG(_InterlockedExchange)
__LONG32 _InterlockedExchange(__LONG32 volatile *Target, __LONG32 Value);
__INTRINSICS_USEINLINE
diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h
index b703125..bfecb7b 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -1498,21 +1498,16 @@ inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((i
/* 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);
+ /* LONG InterlockedAdd(LONG volatile *Addend,LONG Value); moved to psdk_inc/intrin-impl.h */
/* 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 */
-
- __forceinline LONG InterlockedAdd(LONG volatile *Addend,LONG Value) { return InterlockedExchangeAdd(Addend,Value) + Value; }
-
/* LONG64 InterlockedExchangeAdd64(LONG64 volatile *Addend,LONG64 Value); moved to psdk_inc/intrin-impl.h */
- LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value);
+ /* LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value); moved to psdk_inc/intrin-impl.h */
/* 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 */
- __forceinline LONG64 InterlockedAdd64(LONG64 volatile *Addend,LONG64 Value) { return InterlockedExchangeAdd64(Addend,Value) + Value; }
-
#define CacheLineFlush(Address) _mm_clflush(Address)
# if defined(__cplusplus)
@@ -1958,6 +1953,8 @@ extern "C" {
#define BitScanReverse _BitScanReverse
#define InterlockedCompareExchange16 _InterlockedCompareExchange16
+#define InterlockedAdd _InterlockedAdd
+#define InterlockedAdd64 _InterlockedAdd64
#ifdef _PREFIX_
/* BYTE __readfsbyte(DWORD Offset); moved to psdk_inc/intrin-impl.h */
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public