summaryrefslogtreecommitdiff
path: root/src/common/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/atomic.h')
-rw-r--r--src/common/atomic.h29
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 */