summaryrefslogtreecommitdiff
path: root/Source/Core/Common
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2008-12-04 10:58:45 +0000
committernakeee <nakeee@gmail.com>2008-12-04 10:58:45 +0000
commitb64877d464e5baeef8db8d6c6a09bc39b55bb178 (patch)
tree4a530c76f6281384fdd110718bceb582de60884e /Source/Core/Common
parent9692fca60ede477e1b6eaf86ce321c1011a47ee6 (diff)
merged windows/linux atomic operations,
please test on windows git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1391 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/Common')
-rw-r--r--Source/Core/Common/Src/Common.h1
-rw-r--r--Source/Core/Common/Src/Thread.cpp22
2 files changed, 18 insertions, 5 deletions
diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h
index d1c7983f31..307a520fd8 100644
--- a/Source/Core/Common/Src/Common.h
+++ b/Source/Core/Common/Src/Common.h
@@ -123,6 +123,7 @@ inline u32 _rotr(u32 x, int shift) {
return (x >> shift) | (x << (32 - shift));
}
+#define LONG int
#ifdef __LINUX__
typedef union _LARGE_INTEGER
{
diff --git a/Source/Core/Common/Src/Thread.cpp b/Source/Core/Common/Src/Thread.cpp
index 24ce43950a..a479999ab5 100644
--- a/Source/Core/Common/Src/Thread.cpp
+++ b/Source/Core/Common/Src/Thread.cpp
@@ -343,8 +343,11 @@ void Event::Wait()
pthread_mutex_unlock(&mutex_);
}
-int InterlockedIncrement(int *Addend)
+LONG InterlockedIncrement(LONG *Addend)
{
+#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);
#else
@@ -354,11 +357,15 @@ int InterlockedIncrement(int *Addend)
: "0" (Increment), "m" (1)
: "memory");
return result + 1;
-#endif
+#endif
+#endif
}
-int InterlockedExchangeAdd(int *Addend, int Increment)
+LONG InterlockedExchangeAdd(LONG *Addend, LONG Increment)
{
+#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);
#else
@@ -369,14 +376,19 @@ int InterlockedExchangeAdd(int *Addend, int Increment)
: "memory");
return result + Increment;
#endif
+#endif
}
-int InterlockedExchange(int *Addend, int Increment)
+LONG InterlockedExchange(LONG *Addend, LONG Increment)
{
+#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);
#else
// TODO:
- #warning Support older GCC Versions
+ #error Implement support older GCC Versions
+#endif
#endif
}