libobs/util: Add long load/store atomic funcs
parent
f80fced014
commit
4543cd168d
|
@ -256,6 +256,16 @@ long os_atomic_dec_long(volatile long *val)
|
|||
return __sync_sub_and_fetch(val, 1);
|
||||
}
|
||||
|
||||
long os_atomic_set_long(volatile long *ptr, long val)
|
||||
{
|
||||
return __sync_lock_test_and_set(ptr, val);
|
||||
}
|
||||
|
||||
long os_atomic_load_long(const volatile long *ptr)
|
||||
{
|
||||
return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
bool os_atomic_compare_swap_long(volatile long *val, long old_val, long new_val)
|
||||
{
|
||||
return __sync_bool_compare_and_swap(val, old_val, new_val);
|
||||
|
|
|
@ -159,6 +159,16 @@ long os_atomic_dec_long(volatile long *val)
|
|||
return InterlockedDecrement(val);
|
||||
}
|
||||
|
||||
long os_atomic_set_long(volatile long *ptr, long val)
|
||||
{
|
||||
return (long)InterlockedExchange((volatile long*)ptr, (long)val);
|
||||
}
|
||||
|
||||
long os_atomic_load_long(const volatile long *ptr)
|
||||
{
|
||||
return (long)InterlockedOr((volatile long*)ptr, 0);
|
||||
}
|
||||
|
||||
bool os_atomic_compare_swap_long(volatile long *val, long old_val, long new_val)
|
||||
{
|
||||
return InterlockedCompareExchange(val, new_val, old_val) == old_val;
|
||||
|
|
|
@ -72,6 +72,8 @@ EXPORT int os_sem_wait(os_sem_t *sem);
|
|||
|
||||
EXPORT long os_atomic_inc_long(volatile long *val);
|
||||
EXPORT long os_atomic_dec_long(volatile long *val);
|
||||
EXPORT long os_atomic_set_long(volatile long *ptr, long val);
|
||||
EXPORT long os_atomic_load_long(const volatile long *ptr);
|
||||
|
||||
EXPORT bool os_atomic_compare_swap_long(volatile long *val,
|
||||
long old_val, long new_val);
|
||||
|
|
Loading…
Reference in New Issue