Fix windows build. Fix InterlockedIncrement for old gcc. TOTEST on linux.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1394 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
2e9ffbc136
commit
f66b7999d8
Source/Core
|
@ -189,7 +189,21 @@ void SetCurrentThreadName(const TCHAR* szThreadName)
|
|||
__except(EXCEPTION_CONTINUE_EXECUTION)
|
||||
{}
|
||||
}
|
||||
// TODO: check if ever inline
|
||||
LONG SyncInterlockedIncrement(LONG *Dest)
|
||||
{
|
||||
return InterlockedIncrement(Dest);
|
||||
}
|
||||
|
||||
LONG SyncInterlockedExchangeAdd(LONG *Dest, LONG Val)
|
||||
{
|
||||
return InterlockedExchangeAdd(Dest, Val);
|
||||
}
|
||||
|
||||
LONG SyncInterlockedExchange(LONG *Dest, LONG Val)
|
||||
{
|
||||
return InterlockedExchange(Dest, Val);
|
||||
}
|
||||
|
||||
#elif __GNUC__
|
||||
CriticalSection::CriticalSection(int spincount_unused)
|
||||
|
@ -343,53 +357,42 @@ void Event::Wait()
|
|||
pthread_mutex_unlock(&mutex_);
|
||||
}
|
||||
|
||||
LONG InterlockedIncrement(LONG *Addend)
|
||||
LONG SyncInterlockedIncrement(LONG *Dest)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return InterlockedIncrement(Addend);
|
||||
#else
|
||||
#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
|
||||
return __sync_add_and_fetch(Addend, 1);
|
||||
return __sync_add_and_fetch(Dest, 1);
|
||||
#else
|
||||
register int result;
|
||||
__asm__ __volatile__("lock; xadd %0,%1"
|
||||
: "=r" (result), "=m" (1)
|
||||
: "0" (Increment), "m" (1)
|
||||
: "=r" (result), "=m" (*Dest)
|
||||
: "0" (1), "m" (*Dest)
|
||||
: "memory");
|
||||
return result + 1;
|
||||
#endif
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
LONG InterlockedExchangeAdd(LONG *Addend, LONG Increment)
|
||||
LONG SyncInterlockedExchangeAdd(LONG *Dest, LONG Val)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return InterlockedExchangeAdd(Addend, Increment);
|
||||
#else
|
||||
#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
|
||||
return __sync_add_and_fetch(Addend, Increment);
|
||||
return __sync_add_and_fetch(Dest, Val);
|
||||
#else
|
||||
register int result;
|
||||
__asm__ __volatile__("lock; xadd %0,%1"
|
||||
: "=r" (result), "=m" (*Addend)
|
||||
: "0" (Increment), "m" (*Addend)
|
||||
: "=r" (result), "=m" (*Dest)
|
||||
: "0" (Val), "m" (*Dest)
|
||||
: "memory");
|
||||
return result + Increment;
|
||||
#endif
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
LONG InterlockedExchange(LONG *Addend, LONG Increment)
|
||||
|
||||
LONG SyncInterlockedExchange(LONG *Dest, LONG Val)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return InterlockedExchange(Addend, Increment);
|
||||
#else
|
||||
#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
|
||||
return __sync_lock_test_and_set(Addend, Increment);
|
||||
return __sync_lock_test_and_set(Dest, Val);
|
||||
#else
|
||||
// TODO:
|
||||
#error Implement support older GCC Versions
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -107,9 +107,9 @@ void SleepCurrentThread(int ms);
|
|||
|
||||
void SetCurrentThreadName(const char *name);
|
||||
|
||||
LONG InterlockedExchangeAdd(LONG *Addend, LONG Increment);
|
||||
LONG InterlockedExchange(LONG *Addend, LONG Increment);
|
||||
LONG InterlockedIncrement(LONG *Addend);
|
||||
LONG SyncInterlockedExchangeAdd(LONG *Dest, LONG Val);
|
||||
LONG SyncInterlockedExchange(LONG *Dest, LONG Val);
|
||||
LONG SyncInterlockedIncrement(LONG *Dest);
|
||||
|
||||
} // end of namespace Common
|
||||
|
||||
|
|
|
@ -171,8 +171,8 @@ void UpdateInterrupts();
|
|||
|
||||
//inline void WriteLow (u32& _reg, u16 lowbits) {_reg = (_reg & 0xFFFF0000) | lowbits;}
|
||||
//inline void WriteHigh(u32& _reg, u16 highbits) {_reg = (_reg & 0x0000FFFF) | ((u32)highbits << 16);}
|
||||
inline void WriteLow (volatile u32& _reg, u16 lowbits) {Common::InterlockedExchange((LONG*)&_reg,(_reg & 0xFFFF0000) | lowbits);}
|
||||
inline void WriteHigh(volatile u32& _reg, u16 highbits) {Common::InterlockedExchange((LONG*)&_reg,(_reg & 0x0000FFFF) | ((u32)highbits << 16));}
|
||||
inline void WriteLow (volatile u32& _reg, u16 lowbits) {Common::SyncInterlockedExchange((LONG*)&_reg,(_reg & 0xFFFF0000) | lowbits);}
|
||||
inline void WriteHigh(volatile u32& _reg, u16 highbits) {Common::SyncInterlockedExchange((LONG*)&_reg,(_reg & 0x0000FFFF) | ((u32)highbits << 16));}
|
||||
|
||||
inline u16 ReadLow (u32 _reg) {return (u16)(_reg & 0xFFFF);}
|
||||
inline u16 ReadHigh (u32 _reg) {return (u16)(_reg >> 16);}
|
||||
|
@ -182,7 +182,7 @@ int et_UpdateInterrupts;
|
|||
// for GP watchdog hack
|
||||
void IncrementGPWDToken()
|
||||
{
|
||||
Common::InterlockedIncrement((LONG*)&fifo.Fake_GPWDToken);
|
||||
Common::SyncInterlockedIncrement((LONG*)&fifo.Fake_GPWDToken);
|
||||
}
|
||||
|
||||
// Check every FAKE_GP_WATCHDOG_PERIOD if a PE-frame-finish occured
|
||||
|
@ -411,9 +411,9 @@ void Write16(const u16 _Value, const u32 _Address)
|
|||
{
|
||||
UCPCtrlReg tmpCtrl(_Value);
|
||||
|
||||
Common::InterlockedExchange((LONG*)&fifo.bFF_GPReadEnable, tmpCtrl.GPReadEnable);
|
||||
Common::InterlockedExchange((LONG*)&fifo.bFF_GPLinkEnable, tmpCtrl.GPLinkEnable);
|
||||
Common::InterlockedExchange((LONG*)&fifo.bFF_BPEnable, tmpCtrl.BPEnable);
|
||||
Common::SyncInterlockedExchange((LONG*)&fifo.bFF_GPReadEnable, tmpCtrl.GPReadEnable);
|
||||
Common::SyncInterlockedExchange((LONG*)&fifo.bFF_GPLinkEnable, tmpCtrl.GPLinkEnable);
|
||||
Common::SyncInterlockedExchange((LONG*)&fifo.bFF_BPEnable, tmpCtrl.BPEnable);
|
||||
|
||||
// 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
|
||||
|
@ -576,7 +576,7 @@ void GatherPipeBursted()
|
|||
fifo.CPWritePointer += GPFifo::GATHER_PIPE_SIZE;
|
||||
if (fifo.CPWritePointer >= fifo.CPEnd)
|
||||
fifo.CPWritePointer = fifo.CPBase;
|
||||
Common::InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
|
||||
Common::SyncInterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
|
||||
|
||||
// High watermark overflow handling (hacked way)
|
||||
u32 ct=0;
|
||||
|
@ -700,7 +700,7 @@ void UpdateFifoRegister()
|
|||
else
|
||||
dist = (wp - fifo.CPBase) + (fifo.CPEnd - rp);
|
||||
//fifo.CPReadWriteDistance = dist;
|
||||
Common::InterlockedExchange((LONG*)&fifo.CPReadWriteDistance, dist);
|
||||
Common::SyncInterlockedExchange((LONG*)&fifo.CPReadWriteDistance, dist);
|
||||
|
||||
if (!Core::g_CoreStartupParameter.bUseDualCore)
|
||||
CatchUpGPU();
|
||||
|
|
|
@ -202,7 +202,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge)
|
|||
{
|
||||
// we do it directly from videoThread because of
|
||||
// Super Monkey Ball Advance
|
||||
Common::InterlockedExchange((LONG*)&CommandProcessor::fifo.PEToken, _token);
|
||||
Common::SyncInterlockedExchange((LONG*)&CommandProcessor::fifo.PEToken, _token);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||
// check if we are able to run this buffer
|
||||
if ((_fifo.bFF_GPReadEnable) && _fifo.CPReadWriteDistance && !(_fifo.bFF_BPEnable && _fifo.bFF_Breakpoint))
|
||||
{
|
||||
Common::InterlockedExchange((LONG*)&_fifo.CPReadIdle, 0);
|
||||
Common::SyncInterlockedExchange((LONG*)&_fifo.CPReadIdle, 0);
|
||||
//video_initialize.pLog("RUN...........................",FALSE);
|
||||
int peek_counter = 0;
|
||||
while (_fifo.bFF_GPReadEnable && (_fifo.CPReadWriteDistance > 0))
|
||||
|
@ -125,7 +125,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||
if (readPtr == _fifo.CPBreakpoint)
|
||||
{
|
||||
video_initialize.pLog("!!! BP irq raised",FALSE);
|
||||
Common::InterlockedExchange((LONG*)&_fifo.bFF_Breakpoint, 1);
|
||||
Common::SyncInterlockedExchange((LONG*)&_fifo.bFF_Breakpoint, 1);
|
||||
|
||||
video_initialize.pUpdateInterrupts();
|
||||
break;
|
||||
|
@ -156,11 +156,11 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize)
|
|||
#endif
|
||||
}
|
||||
Video_SendFifoData(uData, distToSend);
|
||||
Common::InterlockedExchange((LONG*)&_fifo.CPReadPointer, readPtr);
|
||||
Common::InterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -distToSend);
|
||||
Common::SyncInterlockedExchange((LONG*)&_fifo.CPReadPointer, readPtr);
|
||||
Common::SyncInterlockedExchangeAdd((LONG*)&_fifo.CPReadWriteDistance, -distToSend);
|
||||
}
|
||||
//video_initialize.pLog("..........................IDLE",FALSE);
|
||||
Common::InterlockedExchange((LONG*)&_fifo.CPReadIdle, 1);
|
||||
Common::SyncInterlockedExchange((LONG*)&_fifo.CPReadIdle, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue