diff options
author | Happy <markaizer@gmail.com> | 2014-08-21 04:50:46 +0800 |
---|---|---|
committer | Happy <markaizer@gmail.com> | 2014-08-21 04:50:46 +0800 |
commit | f52e1007fe08c67003c0bc4c78231904dd3fd5cc (patch) | |
tree | 99907d827264e501774e58ab4630e41fa7103c02 /src/common/atomic.h | |
parent | 2410110dece79b4598c12f1c953219f1d0d1904a (diff) | |
parent | 769b1d05aa5cfa8cddfe7d21b35d5c5e4da3bbd6 (diff) | |
download | hercules-f52e1007fe08c67003c0bc4c78231904dd3fd5cc.tar.gz hercules-f52e1007fe08c67003c0bc4c78231904dd3fd5cc.tar.bz2 hercules-f52e1007fe08c67003c0bc4c78231904dd3fd5cc.tar.xz hercules-f52e1007fe08c67003c0bc4c78231904dd3fd5cc.zip |
Merge pull request #1 from HerculesWS/master
Update from original
Diffstat (limited to 'src/common/atomic.h')
-rw-r--r-- | src/common/atomic.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/common/atomic.h b/src/common/atomic.h index b1a4bda92..e73b1c464 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -1,26 +1,29 @@ // Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#ifndef _rA_ATOMIC_H_ -#define _rA_ATOMIC_H_ +#ifndef COMMON_ATOMIC_H +#define COMMON_ATOMIC_H -// Atomic Operations +// Atomic Operations // (Interlocked CompareExchange, Add .. and so on ..) -// +// // Implementation varies / depends on: // - Architecture // - Compiler // - Operating System // -// our Abstraction is fully API-Compatible to Microsofts implementation @ NT5.0+ -// +// our Abstraction is fully API-Compatible to Microsoft's implementation @ NT5.0+ +// #include "../common/cbasetypes.h" #if defined(_MSC_VER) #include "../common/winapi.h" +// This checks if C/C++ Compiler Version is 18.00 +#if _MSC_VER < 1800 + #if !defined(_M_X64) -// When compiling for windows 32bit, the 8byte interlocked operations are not provided by microsoft +// When compiling for windows 32bit, the 8byte interlocked operations are not provided by Microsoft // (because they need at least i586 so its not generic enough.. ... ) forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 _cmp){ _asm{ @@ -33,7 +36,7 @@ forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, mov ecx,4[edi]; mov esi,dest; - lock CMPXCHG8B [esi]; + lock CMPXCHG8B [esi]; } } @@ -80,9 +83,13 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v #endif //endif 32bit windows +#endif //endif _msc_ver check + #elif defined(__GNUC__) -#if !defined(__x86_64__) && !defined(__i386__) +// The __sync functions are available on x86 or ARMv6+ +#if !defined(__x86_64__) && !defined(__i386__) \ + && ( !defined(__ARM_ARCH_VERSION__) || __ARM_ARCH_VERSION__ < 6 ) #error Your Target Platfrom is not supported #endif @@ -136,7 +143,7 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ }//end: InterlockedExchange() -#endif //endif compiler decission +#endif //endif compiler decision -#endif +#endif /* COMMON_ATOMIC_H */ |