Module: vkd3d Branch: master Commit: 03fbf4a3dc45a022ee0c3bcd3069813cf0968963 URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/03fbf4a3dc45a022ee0c3bcd306981...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Thu Jan 18 19:50:00 2024 +0100
vkd3d-common: Introduce vkd3d_atomic_increment_u32().
---
include/private/vkd3d_common.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index f01c7125..6c8f8eed 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -278,20 +278,32 @@ static inline uint64_t vkd3d_atomic_add_fetch_u64(uint64_t volatile *x, uint64_t #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) { 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 -# if HAVE_SYNC_ADD_AND_FETCH 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 static inline LONG InterlockedDecrement(LONG volatile *x)