libobs/util: Add atomic bool load functions

master
jp9000 2015-11-18 10:14:57 -08:00
parent ba7b53f330
commit 598ae383bc
3 changed files with 11 additions and 0 deletions

View File

@ -266,6 +266,11 @@ bool os_atomic_set_bool(volatile bool *ptr, bool val)
return __sync_lock_test_and_set(ptr, val);
}
bool os_atomic_load_bool(const volatile bool *ptr)
{
return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);
}
void os_set_thread_name(const char *name)
{
#if defined(__APPLE__)

View File

@ -169,6 +169,11 @@ bool os_atomic_set_bool(volatile bool *ptr, bool val)
return (bool)InterlockedExchange8((volatile char*)ptr, (char)val);
}
bool os_atomic_load_bool(const volatile bool *ptr)
{
return (bool)InterlockedOr8((volatile char*)ptr, 0);
}
#define VC_EXCEPTION 0x406D1388
#pragma pack(push,8)

View File

@ -77,6 +77,7 @@ 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 bool os_atomic_load_bool(const volatile bool *ptr);
EXPORT void os_set_thread_name(const char *name);