summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorSonicadvance1 <sonicadvance1@gmail.com>2008-10-30 19:48:26 +0000
committerSonicadvance1 <sonicadvance1@gmail.com>2008-10-30 19:48:26 +0000
commit0ab16c6af00a51cf6ba64cba2155bbb8c6e51781 (patch)
treecba2a0487bd5c43446c9bc9c1253fd43d8f92456 /Source/Core
parenta5ca940d649a30f899527ba18512ffd87a2ed385 (diff)
Added InterlockedExchange to Linux side
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1018 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/Thread.cpp9
-rw-r--r--Source/Core/Common/Src/Thread.h1
-rw-r--r--Source/Core/Core/Src/HW/CommandProcessor.cpp8
-rw-r--r--Source/Core/VideoCommon/Src/Fifo.cpp4
4 files changed, 15 insertions, 7 deletions
diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp
index 95b5d1ca65..ce95776242 100644
--- a/Source/Core/Common/Src/Thread.cpp
+++ b/Source/Core/Common/Src/Thread.cpp
@@ -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
diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h
index e71306baf1..069397a838 100644
--- a/Source/Core/Common/Src/Thread.h
+++ b/Source/Core/Common/Src/Thread.h
@@ -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
diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp
index e3890aa2c5..79761edff5 100644
--- a/Source/Core/Core/Src/HW/CommandProcessor.cpp
+++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp
@@ -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
diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp
index 0e0f454f25..6b19c07b4d 100644
--- a/Source/Core/VideoCommon/Src/Fifo.cpp
+++ b/Source/Core/VideoCommon/Src/Fifo.cpp
@@ -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