vkd3d-common: Introduce vkd3d_atomic_compare_exchange_u32().

This commit is contained in:
Henri Verbeet
2024-04-18 18:23:41 +02:00
committed by Alexandre Julliard
parent bfbd29efe6
commit 5c8a90a6c9
Notes: Alexandre Julliard 2024-04-25 00:15:41 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/829
3 changed files with 16 additions and 19 deletions

View File

@@ -431,6 +431,17 @@ static inline uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
return vkd3d_atomic_add_fetch_u32(x, 1);
}
static inline bool vkd3d_atomic_compare_exchange_u32(uint32_t volatile *x, uint32_t expected, uint32_t val)
{
#if HAVE_SYNC_BOOL_COMPARE_AND_SWAP
return __sync_bool_compare_and_swap(x, expected, val);
#elif defined(_WIN32)
return InterlockedCompareExchange((LONG *)x, val, expected) == expected;
#else
# error "vkd3d_atomic_compare_exchange_u32() not implemented for this platform"
#endif
}
struct vkd3d_mutex
{
#ifdef _WIN32