Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2016-06-10 01:00:33 +0300
committerBenoit Bolsee <benoit.bolsee@online.be>2016-06-11 23:15:25 +0300
commitfa9bb2ffe97334a5c686b954673af118c41d1a6d (patch)
treebc228ddaabadea120889ff6256391288ed6b5f10
parent40f1c4f34337d7dfb3fa5bcbd2daa2f602e12011 (diff)
Atomic ops: Fix atomic_add_uint32 and atomic_sub_uint32 in Windows
The assembler version in Windows used to return the previous value of the variable while all the other versions return the new value. This is now fixed for consistency. Note: this bug had no effect on blender because no part of the code use the return value of these functions, but the future BGE DeckLink module makes use of it to implement reference counter.
-rw-r--r--intern/atomic/intern/atomic_ops_unix.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/intern/atomic/intern/atomic_ops_unix.h b/intern/atomic/intern/atomic_ops_unix.h
index bf54750ea0d..55c00024244 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)