[Bf-blender-cvs] [55a3840] decklink: Fix again assembler version of atomic_add_uint32 and atomic_sub_uint32

Benoit Bolsee noreply at git.blender.org
Wed May 18 23:45:14 CEST 2016


Commit: 55a38402ca909ad3dfb2b6088d900f27eb824c76
Author: Benoit Bolsee
Date:   Wed May 18 22:57:47 2016 +0200
Branches: decklink
https://developer.blender.org/rB55a38402ca909ad3dfb2b6088d900f27eb824c76

Fix again assembler version of atomic_add_uint32 and atomic_sub_uint32

The assembler version returns the previous value of the variable while
all the other versions return the new value.
This was fixed before but somehow it came back when the atomic module
was refactored.

===================================================================

M	intern/atomic/intern/atomic_ops_unix.h

===================================================================

diff --git a/intern/atomic/intern/atomic_ops_unix.h b/intern/atomic/intern/atomic_ops_unix.h
index bf54750..55c0002 100644
--- a/intern/atomic/intern/atomic_ops_unix.h
+++ b/intern/atomic/intern/atomic_ops_unix.h
@@ -129,23 +129,24 @@ ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _ne
 #elif (defined(__i386__) || defined(__amd64__) || defined(__x86_64__))
 ATOMIC_INLINE uint32_t atomic_add_uint32(uint32_t *p, uint32_t x)
 {
+	uint32_t ret = x;
 	asm volatile (
 	    "lock; xaddl %0, %1;"
-	    : "+r" (x), "=m" (*p) /* Outputs. */
+	    : "+r" (ret), "=m" (*p) /* Outputs. */
 	    : "m" (*p) /* Inputs. */
 	    );
-	return x;
+	return ret+x;
 }
 
 ATOMIC_INLINE uint32_t atomic_sub_uint32(uint32_t *p, uint32_t x)
 {
-	x = (uint32_t)(-(int32_t)x);
+	ret = (uint32_t)(-(int32_t)x);
 	asm volatile (
 	    "lock; xaddl %0, %1;"
-	    : "+r" (x), "=m" (*p) /* Outputs. */
+	    : "+r" (ret), "=m" (*p) /* Outputs. */
 	    : "m" (*p) /* Inputs. */
 	    );
-	return x;
+	return ret-x;
 }
 
 ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new)




More information about the Bf-blender-cvs mailing list