--- old/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp 2017-08-22 15:36:23.105167876 +0200 +++ new/src/os_cpu/linux_zero/vm/atomic_linux_zero.hpp 2017-08-22 15:36:22.941167882 +0200 @@ -74,7 +74,7 @@ } /* Atomically add an int to memory. */ -static inline int m68k_add_and_fetch(volatile int *ptr, int add_value) { +static inline int m68k_add_and_fetch(int add_value, volatile int *ptr) { for (;;) { // Loop until success. @@ -135,7 +135,7 @@ } /* Atomically add an int to memory. */ -static inline int arm_add_and_fetch(volatile int *ptr, int add_value) { +static inline int arm_add_and_fetch(int add_value, volatile int *ptr) { for (;;) { // Loop until a __kernel_cmpxchg succeeds. @@ -167,33 +167,42 @@ *dest = store_value; } -inline jint Atomic::add(jint add_value, volatile jint* dest) { +template +struct Atomic::PlatformAdd + : Atomic::AddAndFetch > +{ + template + D add_and_fetch(I add_value, D volatile* dest) const; +}; + +template<> +template +inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const { + STATIC_CAST(4 == sizeof(I)); + STATIC_CAST(4 == sizeof(D)); + #ifdef ARM - return arm_add_and_fetch(dest, add_value); + return add_using_helper(arm_add_and_fetch, add_value, dest); #else #ifdef M68K - return m68k_add_and_fetch(dest, add_value); + return add_using_helper(m68k_add_and_fetch, add_value, dest); #else return __sync_add_and_fetch(dest, add_value); #endif // M68K #endif // ARM } -inline intptr_t Atomic::add_ptr(intptr_t add_value, volatile intptr_t* dest) { -#ifdef ARM - return arm_add_and_fetch(dest, add_value); -#else -#ifdef M68K - return m68k_add_and_fetch(dest, add_value); -#else +template<> +template +inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const { + STATIC_CAST(8 == sizeof(I)); + STATIC_CAST(8 == sizeof(D)); + return __sync_add_and_fetch(dest, add_value); -#endif // M68K -#endif // ARM } -inline void* Atomic::add_ptr(intptr_t add_value, volatile void* dest) { - return (void *) add_ptr(add_value, (volatile intptr_t *) dest); -} +template<> +struct Atomic::PlatformAdd<2>: Atomic::AddShortUsingInt {}; inline void Atomic::inc(volatile jint* dest) { add(1, dest);