Jacek Caban : winbase.h: Unify MSVC interlocked functions declarations.

Alexandre Julliard julliard at winehq.org
Thu Apr 23 14:54:31 CDT 2020


Module: wine
Branch: master
Commit: 4b7b7a5f4c5c4659d210846266f475c13a4119d2
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4b7b7a5f4c5c4659d210846266f475c13a4119d2

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Apr 23 01:35:34 2020 +0200

winbase.h: Unify MSVC interlocked functions declarations.

And use intrinsic versions on x86.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 include/winbase.h | 101 ++++++++++++++++++++++++++----------------------------
 1 file changed, 49 insertions(+), 52 deletions(-)

diff --git a/include/winbase.h b/include/winbase.h
index 2aefd0e043..1d8e32d6cb 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2904,7 +2904,55 @@ extern WCHAR * CDECL wine_get_dos_file_name( LPCSTR str );
 
 /* Interlocked functions */
 
-#ifdef __i386__
+#ifdef _MSC_VER
+
+#pragma intrinsic(_InterlockedCompareExchange)
+#pragma intrinsic(_InterlockedCompareExchange64)
+#pragma intrinsic(_InterlockedExchange)
+#pragma intrinsic(_InterlockedExchangeAdd)
+#pragma intrinsic(_InterlockedIncrement)
+#pragma intrinsic(_InterlockedDecrement)
+
+#define InterlockedCompareExchange    _InterlockedCompareExchange
+#define InterlockedCompareExchange64  _InterlockedCompareExchange64
+#define InterlockedExchange           _InterlockedExchange
+#define InterlockedExchangeAdd        _InterlockedExchangeAdd
+#define InterlockedIncrement          _InterlockedIncrement
+#define InterlockedDecrement          _InterlockedDecrement
+
+long      InterlockedCompareExchange(long volatile*,long,long);
+long long InterlockedCompareExchange64(long long volatile*,long long,long long);
+long      InterlockedDecrement(long volatile*);
+long      InterlockedExchange(long volatile*,long);
+long      InterlockedExchangeAdd(long volatile*,long);
+long      InterlockedIncrement(long volatile*);
+
+#ifndef __i386__
+
+#pragma intrinsic(_InterlockedCompareExchangePointer)
+#pragma intrinsic(_InterlockedExchangePointer)
+
+#define InterlockedCompareExchangePointer    _InterlockedCompareExchangePointer
+#define InterlockedExchangePointer           _InterlockedExchangePointer
+
+void *InterlockedCompareExchangePointer(void *volatile*,void*,void*);
+void *InterlockedExchangePointer(void *volatile*,void*);
+
+#else
+
+static FORCEINLINE void *WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
+{
+    return (void *)InterlockedCompareExchange( (long volatile*)dest, (long)xchg, (long)compare );
+}
+
+static FORCEINLINE void *WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
+{
+    return (void *)InterlockedExchange( (long volatile*)dest, (long)val );
+}
+
+#endif
+
+#elif defined(__i386__)
 # if defined(__GNUC__) && !defined(_NTSYSTEM_) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
 
 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
@@ -2963,57 +3011,6 @@ static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest
 
 WINBASEAPI LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile*,LONGLONG,LONGLONG);
 
-#elif defined(_MSC_VER)
-
-#pragma intrinsic(_InterlockedCompareExchange)
-#pragma intrinsic(_InterlockedCompareExchangePointer)
-#pragma intrinsic(_InterlockedCompareExchange64)
-#pragma intrinsic(_InterlockedExchange)
-#pragma intrinsic(_InterlockedExchangePointer)
-#pragma intrinsic(_InterlockedExchangeAdd)
-#pragma intrinsic(_InterlockedIncrement)
-#pragma intrinsic(_InterlockedDecrement)
-
-static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
-{
-    return _InterlockedCompareExchange( dest, xchg, compare );
-}
-
-static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatile *dest, PVOID xchg, PVOID compare )
-{
-    return _InterlockedCompareExchangePointer( dest, xchg, compare );
-}
-
-static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
-{
-    return _InterlockedCompareExchange64( dest, xchg, compare );
-}
-
-static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
-{
-    return _InterlockedExchange( dest, val );
-}
-
-static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest, PVOID val )
-{
-    return _InterlockedExchangePointer( dest, val );
-}
-
-static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
-{
-    return _InterlockedExchangeAdd( dest, incr );
-}
-
-static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
-{
-    return _InterlockedIncrement( dest );
-}
-
-static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
-{
-    return _InterlockedDecrement( dest );
-}
-
 #elif defined(__GNUC__)
 
 static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )




More information about the wine-cvs mailing list