Added InterlockedExchange to Linux side

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1018 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Sonicadvance1 2008-10-30 19:48:26 +00:00
parent a5ca940d64
commit 0ab16c6af0
4 changed files with 15 additions and 7 deletions

View File

@ -358,6 +358,15 @@ int InterlockedExchangeAdd(int *Addend, int Increment)
return result + Increment;
#endif
}
int InterlockedExchange(int *Addend, int Increment)
{
#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
return __sync_lock_test_and_set(Addend, Increment);
#else
// TODO:
#warning Support older GCC Versions
#endif
}
#endif

View File

@ -116,6 +116,7 @@ void SetCurrentThreadName(const char *name);
#ifndef _WIN32
int InterlockedExchangeAdd(int *Addend, int Increment);
int InterlockedExchange(int *Addend, int Increment);
#endif
} // end of namespace Common

View File

@ -360,11 +360,9 @@ void Write16(const u16 _Value, const u32 _Address)
InterlockedExchange((LONG*)&fifo.bFF_GPLinkEnable, m_CPCtrlReg.GPLinkEnable);
InterlockedExchange((LONG*)&fifo.bFF_BPEnable, m_CPCtrlReg.BPEnable);
#else
#warning "Hi pingouin lover :p. Just make sure the following is ok for linux please."
// TODO: safely?
fifo.bFF_GPReadEnable = m_CPCtrlReg.GPReadEnable;
fifo.bFF_GPLinkEnable = m_CPCtrlReg.GPLinkEnable;
fifo.bFF_BPEnable = m_CPCtrlReg.BPEnable;
Common::InterlockedExchange((int*)&fifo.bFF_GPReadEnable, m_CPCtrlReg.GPReadEnable);
Common::InterlockedExchange((int*)&fifo.bFF_GPLinkEnable, m_CPCtrlReg.GPLinkEnable);
Common::InterlockedExchange((int*)&fifo.bFF_BPEnable, m_CPCtrlReg.BPEnable);
#endif
// TOCHECK (mb2): could BP irq be cleared with w16 to STATUS_REGISTER?
// funny hack: eg in MP1 if we disable the clear breakpoint ability by commenting this block

View File

@ -135,7 +135,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
#ifdef _WIN32
InterlockedExchange((LONG*)&_fifo.bFF_Breakpoint, 1);
#else
_fifo.bFF_Breakpoint = true;
Common::InterlockedExchange((int*)&_fifo.bFF_Breakpoint, 1);
#endif
video_initialize.pUpdateInterrupts();
break;
@ -159,7 +159,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
InterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -32);
//LeaveCriticalSection(&_fifo.sync);
#else
_fifo.CPReadPointer = readPtr;
Common::InterlockedExchange((int*)&_fifo.CPReadPointer, readPtr);
Common::InterlockedExchangeAdd((int*)&_fifo.CPReadWriteDistance, -32);
_fifo.sync->Leave();
#endif