mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
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.
This commit is contained in:
parent
40f1c4f343
commit
fa9bb2ffe9
1 changed files with 6 additions and 5 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue