0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

libobs/util: Add atomic functions for bool values

This commit is contained in:
jp9000 2015-11-03 14:09:03 -08:00
parent 40250a62f0
commit a914bb24fa
3 changed files with 12 additions and 0 deletions

View File

@ -261,6 +261,11 @@ 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);
}
bool os_atomic_set_bool(volatile bool *ptr, bool val)
{
return __sync_lock_test_and_set(ptr, val);
}
void os_set_thread_name(const char *name)
{
#if defined(__APPLE__)

View File

@ -181,6 +181,11 @@ bool os_atomic_compare_swap_long(volatile long *val, long old_val, long new_val)
return InterlockedCompareExchange(val, new_val, old_val) == old_val;
}
bool os_atomic_set_bool(volatile bool *ptr, bool val)
{
return (bool)InterlockedExchange8((volatile char*)ptr, (char)val);
}
#define VC_EXCEPTION 0x406D1388
#pragma pack(push,8)

View File

@ -76,6 +76,8 @@ EXPORT long os_atomic_dec_long(volatile long *val);
EXPORT bool os_atomic_compare_swap_long(volatile long *val,
long old_val, long new_val);
EXPORT bool os_atomic_set_bool(volatile bool *ptr, bool val);
EXPORT void os_set_thread_name(const char *name);