summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-11-15 20:36:45 +0000
committernakeee <nakeee@gmail.com>2008-11-15 20:36:45 +0000
commit06aff848e36c5103971fb59d91ac1bdf3be8690a (patch)
tree7d5130f7673e2991ab834a19bf499265ddc90865 /Source/Core
parent2a06f76f81cfb01bfda59b684d0d93bd84031fe4 (diff)
more porting
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1183 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Common/Src/Thread.cpp14
-rw-r--r--Source/Core/Common/Src/Thread.h1
-rw-r--r--Source/Core/Core/Src/HW/CommandProcessor.cpp6
3 files changed, 18 insertions, 3 deletions
diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp
index ce95776242..512e6be345 100644
--- a/Source/Core/Common/Src/Thread.cpp
+++ b/Source/Core/Common/Src/Thread.cpp
@@ -345,6 +345,20 @@ void Event::Wait()
pthread_mutex_unlock(&mutex_);
}
+int InterlockedIncrement(int *Addend)
+{
+#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
+ return __sync_add_and_fetch(Addend, 1);
+#else
+ register int result;
+ __asm__ __volatile__("lock; xadd %0,%1"
+ : "=r" (result), "=m" (1)
+ : "0" (Increment), "m" (1)
+ : "memory");
+ return result + 1;
+#endif
+}
+
int InterlockedExchangeAdd(int *Addend, int Increment)
{
#if defined(__GNUC__) && defined (__GNUC_MINOR__) && ((4 < __GNUC__) || (4 == __GNUC__ && 1 <= __GNUC_MINOR__))
diff --git a/Source/Core/Common/Src/Thread.h b/Source/Core/Common/Src/Thread.h
index 069397a838..73c273fdf4 100644
--- a/Source/Core/Common/Src/Thread.h
+++ b/Source/Core/Common/Src/Thread.h
@@ -117,6 +117,7 @@ void SetCurrentThreadName(const char *name);
#ifndef _WIN32
int InterlockedExchangeAdd(int *Addend, int Increment);
int InterlockedExchange(int *Addend, int Increment);
+int InterlockedIncrement(int *Addend);
#endif
} // end of namespace Common
diff --git a/Source/Core/Core/Src/HW/CommandProcessor.cpp b/Source/Core/Core/Src/HW/CommandProcessor.cpp
index 086806d1db..90f3bb9e22 100644
--- a/Source/Core/Core/Src/HW/CommandProcessor.cpp
+++ b/Source/Core/Core/Src/HW/CommandProcessor.cpp
@@ -173,10 +173,10 @@ int et_UpdateInterrupts;
// for GP watchdog hack
void IncrementGPWDToken()
{
-#ifdef WIN32
+#ifdef _WIN32
InterlockedIncrement((LONG*)&fifo.Fake_GPWDToken);
#else
- //TODO
+ Common::InterlockedIncrement((int*)&fifo.Fake_GPWDToken);
#endif
}
@@ -521,7 +521,7 @@ void GatherPipeBursted()
#ifdef _WIN32
InterlockedExchangeAdd((LONG*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
#else
- Common::InterlockedExchangeAdd((int*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
+ Common::InterlockedExchangeAdd((int*)&fifo.CPReadWriteDistance, GPFifo::GATHER_PIPE_SIZE);
#endif
// High watermark overflow handling (hacked way)