mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d-common: Introduce vkd3d_atomic_increment_u32().
This commit is contained in:
committed by
Alexandre Julliard
parent
f69c8b1cc4
commit
03fbf4a3dc
Notes:
Alexandre Julliard
2024-01-18 23:21:43 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/576
@ -278,20 +278,32 @@ static inline uint64_t vkd3d_atomic_add_fetch_u64(uint64_t volatile *x, uint64_t
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t vkd3d_atomic_add_fetch_u32(uint32_t volatile *x, uint32_t val)
|
||||||
|
{
|
||||||
|
#if HAVE_SYNC_ADD_AND_FETCH
|
||||||
|
return __sync_add_and_fetch(x, val);
|
||||||
|
#elif defined(_WIN32)
|
||||||
|
return InterlockedAdd((LONG *)x, val);
|
||||||
|
#else
|
||||||
|
# error "vkd3d_atomic_add_fetch_u32() not implemented for this platform"
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static inline uint64_t vkd3d_atomic_increment_u64(uint64_t volatile *x)
|
static inline uint64_t vkd3d_atomic_increment_u64(uint64_t volatile *x)
|
||||||
{
|
{
|
||||||
return vkd3d_atomic_add_fetch_u64(x, 1);
|
return vkd3d_atomic_add_fetch_u64(x, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
|
||||||
|
{
|
||||||
|
return vkd3d_atomic_add_fetch_u32(x, 1);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# if HAVE_SYNC_ADD_AND_FETCH
|
|
||||||
static inline LONG InterlockedIncrement(LONG volatile *x)
|
static inline LONG InterlockedIncrement(LONG volatile *x)
|
||||||
{
|
{
|
||||||
return __sync_add_and_fetch(x, 1);
|
return vkd3d_atomic_increment_u32((uint32_t *)x);
|
||||||
}
|
}
|
||||||
# else
|
|
||||||
# error "InterlockedIncrement() not implemented for this platform"
|
|
||||||
# endif /* HAVE_SYNC_ADD_AND_FETCH */
|
|
||||||
|
|
||||||
# if HAVE_SYNC_SUB_AND_FETCH
|
# if HAVE_SYNC_SUB_AND_FETCH
|
||||||
static inline LONG InterlockedDecrement(LONG volatile *x)
|
static inline LONG InterlockedDecrement(LONG volatile *x)
|
||||||
|
Reference in New Issue
Block a user