forked from bartvdbraak/blender
atomic_ops: add atomic_cas_float
helper.
This commit is contained in:
parent
efb86b712d
commit
cf6e8edda5
@ -130,6 +130,9 @@ ATOMIC_INLINE unsigned int atomic_cas_u(unsigned int *v, unsigned int old, unsig
|
||||
|
||||
ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new);
|
||||
|
||||
|
||||
ATOMIC_INLINE float atomic_cas_float(float *v, float old, float _new);
|
||||
|
||||
/* WARNING! Float 'atomics' are really faked ones, those are actually closer to some kind of spinlock-sync'ed operation,
|
||||
* which means they are only efficient if collisions are highly unlikely (i.e. if probability of two threads
|
||||
* working on the same pointer at the same time is very low). */
|
||||
|
@ -191,6 +191,12 @@ ATOMIC_INLINE void *atomic_cas_ptr(void **v, void *old, void *_new)
|
||||
/* float operations. */
|
||||
ATOMIC_STATIC_ASSERT(sizeof(float) == sizeof(uint32_t), "sizeof(float) != sizeof(uint32_t)");
|
||||
|
||||
ATOMIC_INLINE float atomic_cas_float(float *v, float old, float _new)
|
||||
{
|
||||
uint32_t ret = atomic_cas_uint32((uint32_t *)v, *(uint32_t *)&old, *(uint32_t *)&_new);
|
||||
return *(float *)&ret;
|
||||
}
|
||||
|
||||
ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x)
|
||||
{
|
||||
float oldval, newval;
|
||||
|
Loading…
Reference in New Issue
Block a user