diff options
author | Benoit Foucher <benoit@zeroc.com> | 2015-05-06 15:43:34 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2015-05-06 15:43:34 +0200 |
commit | 0ab15fe587d5ad656be795e279b865fa9693d7a8 (patch) | |
tree | 7261c1cc8cc8ee6d1e6c9c7df94b2f7ded513202 /cpp/include | |
parent | Only add csharp to all-cross on Windows, add objective-c to all-cross on OSX. (diff) | |
download | ice-0ab15fe587d5ad656be795e279b865fa9693d7a8.tar.bz2 ice-0ab15fe587d5ad656be795e279b865fa9693d7a8.tar.xz ice-0ab15fe587d5ad656be795e279b865fa9693d7a8.zip |
Fixed Atomic.h to support VS2008 build
Diffstat (limited to 'cpp/include')
-rw-r--r-- | cpp/include/IceUtil/Atomic.h | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/cpp/include/IceUtil/Atomic.h b/cpp/include/IceUtil/Atomic.h index 66313eb6def..070f4c9581c 100644 --- a/cpp/include/IceUtil/Atomic.h +++ b/cpp/include/IceUtil/Atomic.h @@ -54,10 +54,10 @@ typedef std::atomic<int> Atomic; // volatile here is required by InterlockedExchangeXXX // family functions. // -# if defined(__MINGW32__) -typedef volatile long int ATOMIC_T; +# if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER <= 1500)) +typedef volatile LONG ATOMIC_T; # else -typedef volatile unsigned int ATOMIC_T; +typedef unsigned int ATOMIC_T; # endif #else typedef int ATOMIC_T; @@ -71,17 +71,17 @@ typedef int ATOMIC_T; class ICE_UTIL_API Atomic : public IceUtil::noncopyable { public: - + Atomic() : _ref(0) { } - + Atomic(int desired) : _ref(desired) { } - + inline int fetch_add(int value) { #if defined(_WIN32) @@ -95,11 +95,11 @@ public: return tmp; #endif } - + inline int fetch_sub(int value) { #if defined(_WIN32) -# if defined(__MINGW32__) +# if defined(__MINGW32__) || (defined(_MSC_VER) && (_MSC_VER <= 1500)) return InterlockedExchangeAdd(&_ref, -value); # else return InterlockedExchangeSubtract(&_ref, value); @@ -113,7 +113,7 @@ public: return tmp; #endif } - + inline int load() const { #if defined(_WIN32) @@ -125,7 +125,7 @@ public: return _ref; #endif } - + inline int exchange(int value) { #if defined(_WIN32) @@ -140,39 +140,39 @@ public: return _ref; #endif } - + inline int operator++() { return fetch_add(1) + 1; } - + inline int operator--() { return fetch_sub(1) - 1; } - + inline int operator++(int) { return fetch_add(1); } - + inline int operator--(int) { return fetch_sub(1); } - + inline operator int() { return load(); } - + inline operator int() const { return load(); } private: - + ATOMIC_T _ref; #if !defined(_WIN32) && !defined(ICE_HAS_GCC_BUILTINS) IceUtil::Mutex _mutex; |