[redcode/crythread-2nd-pass] removed MultiThread.h along with external CryInterlocked* definitions

Signed-off-by: AMZN-ScottR <24445312+AMZN-ScottR@users.noreply.github.com>
This commit is contained in:
AMZN-ScottR
2021-08-11 16:38:54 -07:00
parent 337ea488b6
commit c173dee2bc
6 changed files with 1 additions and 419 deletions
+1 -84
View File
@@ -1292,90 +1292,7 @@ short CryGetAsyncKeyState(int vKey)
return 0;
}
#if defined(LINUX) || defined(APPLE) || defined(DEFINE_CRY_INTERLOCKED_INCREMENT)
//[K01]: http://www.memoryhole.net/kyle/2007/05/atomic_incrementing.html
//http://forums.devx.com/archive/index.php/t-160558.html
//////////////////////////////////////////////////////////////////////////
DLL_EXPORT LONG CryInterlockedIncrement(LONG volatile* lpAddend)
{
/*int r;
__asm__ __volatile__ (
"lock ; xaddl %0, (%1) \n\t"
: "=r" (r)
: "r" (lpAddend), "0" (1)
: "memory"
);
return (LONG) (r + 1); */// add, since we get the original value back.
return __sync_fetch_and_add(lpAddend, 1) + 1;
}
//////////////////////////////////////////////////////////////////////////
DLL_EXPORT LONG CryInterlockedDecrement(LONG volatile* lpAddend)
{
/*int r;
__asm__ __volatile__ (
"lock ; xaddl %0, (%1) \n\t"
: "=r" (r)
: "r" (lpAddend), "0" (-1)
: "memory"
);
return (LONG) (r - 1); */// subtract, since we get the original value back.
return __sync_fetch_and_sub(lpAddend, 1) - 1;
}
//////////////////////////////////////////////////////////////////////////
DLL_EXPORT LONG CryInterlockedExchangeAdd(LONG volatile* lpAddend, LONG Value)
{
/* LONG r;
__asm__ __volatile__ (
#if defined(LINUX64) || defined(APPLE) // long is 64 bits on amd64.
"lock ; xaddq %0, (%1) \n\t"
#else
"lock ; xaddl %0, (%1) \n\t"
#endif
: "=r" (r)
: "r" (lpAddend), "0" (Value)
: "memory"
);
return r;*/
return __sync_fetch_and_add(lpAddend, Value);
}
DLL_EXPORT LONG CryInterlockedOr(LONG volatile* Destination, LONG Value)
{
return __sync_fetch_and_or(Destination, Value);
}
DLL_EXPORT LONG CryInterlockedCompareExchange(LONG volatile* dst, LONG exchange, LONG comperand)
{
return __sync_val_compare_and_swap(dst, comperand, exchange);
/*LONG r;
__asm__ __volatile__ (
#if defined(LINUX64) || defined(APPLE) // long is 64 bits on amd64.
"lock ; cmpxchgq %2, (%1) \n\t"
#else
"lock ; cmpxchgl %2, (%1) \n\t"
#endif
: "=a" (r)
: "r" (dst), "r" (exchange), "0" (comperand)
: "memory"
);
return r;*/
}
DLL_EXPORT void* CryInterlockedCompareExchangePointer(void* volatile* dst, void* exchange, void* comperand)
{
return __sync_val_compare_and_swap(dst, comperand, exchange);
//return (void*)CryInterlockedCompareExchange((long volatile*)dst, (long)exchange, (long)comperand);
}
DLL_EXPORT void* CryInterlockedExchangePointer(void* volatile* dst, void* exchange)
{
__sync_synchronize();
return __sync_lock_test_and_set(dst, exchange);
//return (void*)CryInterlockedCompareExchange((long volatile*)dst, (long)exchange, (long)comperand);
}
#if defined(LINUX) || defined(APPLE)
threadID CryGetCurrentThreadId()
{