include: Move interlocked functions to winnt.h.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0762f6726c
commit
aef2e01772
|
@ -2919,138 +2919,6 @@ extern char * CDECL wine_get_unix_file_name( LPCWSTR dos );
|
|||
extern WCHAR * CDECL wine_get_dos_file_name( LPCSTR str );
|
||||
|
||||
|
||||
/* Interlocked functions */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#pragma intrinsic(_InterlockedCompareExchange)
|
||||
#pragma intrinsic(_InterlockedCompareExchange64)
|
||||
#pragma intrinsic(_InterlockedExchange)
|
||||
#pragma intrinsic(_InterlockedExchangeAdd)
|
||||
#pragma intrinsic(_InterlockedIncrement)
|
||||
#pragma intrinsic(_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*);
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
||||
{
|
||||
return _InterlockedCompareExchange( (long volatile *)dest, xchg, compare );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
|
||||
{
|
||||
return _InterlockedCompareExchange64( (long long volatile *)dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
|
||||
{
|
||||
return _InterlockedExchange( (long volatile *)dest, val );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
||||
{
|
||||
return _InterlockedExchangeAdd( (long volatile *)dest, incr );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
|
||||
{
|
||||
return _InterlockedIncrement( (long volatile *)dest );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
|
||||
{
|
||||
return _InterlockedDecrement( (long volatile *)dest );
|
||||
}
|
||||
|
||||
#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(__GNUC__)
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE PVOID WINAPI InterlockedCompareExchangePointer( PVOID volatile *dest, PVOID xchg, PVOID compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
|
||||
{
|
||||
LONG ret;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
__asm__ __volatile__( "lock; xchgl %0,(%1)"
|
||||
: "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#else
|
||||
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
||||
{
|
||||
return __sync_fetch_and_add( dest, incr );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
|
||||
{
|
||||
return __sync_add_and_fetch( dest, 1 );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
|
||||
{
|
||||
return __sync_add_and_fetch( dest, -1 );
|
||||
}
|
||||
|
||||
static FORCEINLINE PVOID WINAPI InterlockedExchangePointer( PVOID volatile *dest, PVOID val )
|
||||
{
|
||||
PVOID ret;
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#elif defined(__i386__)
|
||||
__asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#else
|
||||
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef __WINESRC__
|
||||
|
||||
static FORCEINLINE HANDLE WINAPI GetCurrentProcess(void)
|
||||
|
|
132
include/winnt.h
132
include/winnt.h
|
@ -6892,6 +6892,138 @@ static inline BOOLEAN BitScanReverse(DWORD *index, DWORD mask)
|
|||
|
||||
#endif
|
||||
|
||||
/* Interlocked functions */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#pragma intrinsic(_InterlockedCompareExchange)
|
||||
#pragma intrinsic(_InterlockedCompareExchange64)
|
||||
#pragma intrinsic(_InterlockedExchange)
|
||||
#pragma intrinsic(_InterlockedExchangeAdd)
|
||||
#pragma intrinsic(_InterlockedIncrement)
|
||||
#pragma intrinsic(_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*);
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
||||
{
|
||||
return _InterlockedCompareExchange( (long volatile *)dest, xchg, compare );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
|
||||
{
|
||||
return _InterlockedCompareExchange64( (long long volatile *)dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
|
||||
{
|
||||
return _InterlockedExchange( (long volatile *)dest, val );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
||||
{
|
||||
return _InterlockedExchangeAdd( (long volatile *)dest, incr );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
|
||||
{
|
||||
return _InterlockedIncrement( (long volatile *)dest );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
|
||||
{
|
||||
return _InterlockedDecrement( (long volatile *)dest );
|
||||
}
|
||||
|
||||
#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(__GNUC__)
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedCompareExchange( LONG volatile *dest, LONG xchg, LONG compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE void * WINAPI InterlockedCompareExchangePointer( void *volatile *dest, void *xchg, void *compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONGLONG WINAPI InterlockedCompareExchange64( LONGLONG volatile *dest, LONGLONG xchg, LONGLONG compare )
|
||||
{
|
||||
return __sync_val_compare_and_swap( dest, compare, xchg );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchange( LONG volatile *dest, LONG val )
|
||||
{
|
||||
LONG ret;
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
__asm__ __volatile__( "lock; xchgl %0,(%1)"
|
||||
: "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#else
|
||||
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedExchangeAdd( LONG volatile *dest, LONG incr )
|
||||
{
|
||||
return __sync_fetch_and_add( dest, incr );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedIncrement( LONG volatile *dest )
|
||||
{
|
||||
return __sync_add_and_fetch( dest, 1 );
|
||||
}
|
||||
|
||||
static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
|
||||
{
|
||||
return __sync_add_and_fetch( dest, -1 );
|
||||
}
|
||||
|
||||
static FORCEINLINE void * WINAPI InterlockedExchangePointer( void *volatile *dest, void *val )
|
||||
{
|
||||
void *ret;
|
||||
#ifdef __x86_64__
|
||||
__asm__ __volatile__( "lock; xchgq %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#elif defined(__i386__)
|
||||
__asm__ __volatile__( "lock; xchgl %0,(%1)" : "=r" (ret) :"r" (dest), "0" (val) : "memory" );
|
||||
#else
|
||||
do ret = *dest; while (!__sync_bool_compare_and_swap( dest, ret, val ));
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#ifdef _WIN64
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
|
Loading…
Reference in New Issue