mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-09-12 18:50:22 -07:00
vkd3d-common: Introduce vkd3d_atomic_exchange_u32().
This commit is contained in:
committed by
Alexandre Julliard
parent
5c8a90a6c9
commit
b1c326ce56
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
@@ -442,6 +442,24 @@ static inline bool vkd3d_atomic_compare_exchange_u32(uint32_t volatile *x, uint3
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline uint32_t vkd3d_atomic_exchange_u32(uint32_t volatile *x, uint32_t val)
|
||||
{
|
||||
#if HAVE_ATOMIC_EXCHANGE_N
|
||||
return __atomic_exchange_n(x, val, __ATOMIC_SEQ_CST);
|
||||
#elif defined(_WIN32)
|
||||
return InterlockedExchange((LONG *)x, val);
|
||||
#else
|
||||
uint32_t expected;
|
||||
|
||||
do
|
||||
{
|
||||
expected = *x;
|
||||
} while (!vkd3d_atomic_compare_exchange_u32(x, expected, val));
|
||||
|
||||
return expected;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct vkd3d_mutex
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
Reference in New Issue
Block a user