Commit 61c0dcdb authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

include/winbase.h: MSC compiler implements interlocked* APIs as intrinsics in x86_64 mode.

parent 9d949605
...@@ -2435,6 +2435,10 @@ WINBASEAPI LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile*,LONGL ...@@ -2435,6 +2435,10 @@ WINBASEAPI LONGLONG WINAPI InterlockedCompareExchange64(LONGLONG volatile*,LONGL
#else /* __i386__ */ #else /* __i386__ */
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchange)
#endif
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare ) static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2442,12 +2446,18 @@ static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, ...@@ -2442,12 +2446,18 @@ static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest,
__asm__ __volatile__( "lock; cmpxchgl %2,(%1)" __asm__ __volatile__( "lock; cmpxchgl %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" ); : "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedCompareExchange( dest, xchg, compare );
#else #else
extern int interlocked_cmpxchg( int *dest, int xchg, int compare ); extern int interlocked_cmpxchg( int *dest, int xchg, int compare );
return interlocked_cmpxchg( (int *)dest, xchg, compare ); return interlocked_cmpxchg( (int *)dest, xchg, compare );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchangePointer)
#endif
static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatile *dest, PVOID xchg, PVOID compare ) static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatile *dest, PVOID xchg, PVOID compare )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2455,12 +2465,18 @@ static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatil ...@@ -2455,12 +2465,18 @@ static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatil
__asm__ __volatile__( "lock; cmpxchgq %2,(%1)" __asm__ __volatile__( "lock; cmpxchgq %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" ); : "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedCompareExchangePointer( dest, xchg, compare );
#else #else
extern void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare ); extern void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare );
return interlocked_cmpxchg_ptr( (void **)dest, xchg, compare ); return interlocked_cmpxchg_ptr( (void **)dest, xchg, compare );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedCompareExchange64)
#endif
static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare ) static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2468,12 +2484,18 @@ static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volati ...@@ -2468,12 +2484,18 @@ static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volati
__asm__ __volatile__( "lock; cmpxchgq %2,(%1)" __asm__ __volatile__( "lock; cmpxchgq %2,(%1)"
: "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" ); : "=a" (ret) : "r" (dest), "r" (xchg), "0" (compare) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedCompareExchange64( dest, xchg, compare );
#else #else
extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare ); extern __int64 interlocked_cmpxchg64( __int64 *dest, __int64 xchg, __int64 compare );
return interlocked_cmpxchg64( (__int64 *)dest, xchg, compare ); return interlocked_cmpxchg64( (__int64 *)dest, xchg, compare );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchange)
#endif
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val ) static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2481,12 +2503,18 @@ static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG va ...@@ -2481,12 +2503,18 @@ static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG va
__asm__ __volatile__( "lock; xchgl %0,(%1)" __asm__ __volatile__( "lock; xchgl %0,(%1)"
: "=r" (ret) :"r" (dest), "0" (val) : "memory" ); : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedExchange( dest, val );
#else #else
extern int interlocked_xchg( int *dest, int val ); extern int interlocked_xchg( int *dest, int val );
return interlocked_xchg( (int *)dest, val ); return interlocked_xchg( (int *)dest, val );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchangePointer)
#endif
static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest, PVOID val ) static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest, PVOID val )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2494,12 +2522,18 @@ static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest ...@@ -2494,12 +2522,18 @@ static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest
__asm__ __volatile__( "lock; xchgq %0,(%1)" __asm__ __volatile__( "lock; xchgq %0,(%1)"
: "=r" (ret) :"r" (dest), "0" (val) : "memory" ); : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedExchangePointer( dest, val );
#else #else
extern void *interlocked_xchg_ptr( void **dest, void *val ); extern void *interlocked_xchg_ptr( void **dest, void *val );
return interlocked_xchg_ptr( (void **)dest, val ); return interlocked_xchg_ptr( (void **)dest, val );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedExchangeAdd)
#endif
static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr ) static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
{ {
#if defined(__x86_64__) && defined(__GNUC__) #if defined(__x86_64__) && defined(__GNUC__)
...@@ -2507,20 +2541,38 @@ static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG ...@@ -2507,20 +2541,38 @@ static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG
__asm__ __volatile__( "lock; xaddl %0,(%1)" __asm__ __volatile__( "lock; xaddl %0,(%1)"
: "=r" (ret) : "r" (dest), "0" (incr) : "memory" ); : "=r" (ret) : "r" (dest), "0" (incr) : "memory" );
return ret; return ret;
#elif defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedExchangeAdd( dest, incr );
#else #else
extern int interlocked_xchg_add( int *dest, int incr ); extern int interlocked_xchg_add( int *dest, int incr );
return interlocked_xchg_add( (int *)dest, incr ); return interlocked_xchg_add( (int *)dest, incr );
#endif #endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedIncrement)
#endif
static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest ) static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
{ {
#if defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedIncrement( dest );
#else
return InterlockedExchangeAdd( dest, 1 ) + 1; return InterlockedExchangeAdd( dest, 1 ) + 1;
#endif
} }
#if defined(__x86_64__) && defined(_MSC_VER)
#pragma intrinsic(_InterlockedDecrement)
#endif
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest ) static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
{ {
#if defined(__x86_64__) && defined(_MSC_VER)
return _InterlockedDecrement( dest );
#else
return InterlockedExchangeAdd( dest, -1 ) - 1; return InterlockedExchangeAdd( dest, -1 ) - 1;
#endif
} }
#endif /* __i386__ */ #endif /* __i386__ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment