From c64921e79b5e26bf0e39cf2c188979db85f8d3b3 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Tue, 30 Jan 2024 12:54:54 +0100 Subject: [PATCH] vkd3d-common: Get rid of InterlockedIncrement(). --- include/private/vkd3d_common.h | 5 ----- include/private/vkd3d_test.h | 40 ++++++++++++++++------------------ tests/vkd3d_api.c | 6 ++--- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/include/private/vkd3d_common.h b/include/private/vkd3d_common.h index 01e219b3..6f878cce 100644 --- a/include/private/vkd3d_common.h +++ b/include/private/vkd3d_common.h @@ -305,11 +305,6 @@ static inline uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x) } #ifndef _WIN32 -static inline LONG InterlockedIncrement(LONG volatile *x) -{ - return vkd3d_atomic_increment_u32((uint32_t *)x); -} - static inline LONG InterlockedDecrement(LONG volatile *x) { return vkd3d_atomic_decrement_u32((uint32_t *)x); diff --git a/include/private/vkd3d_test.h b/include/private/vkd3d_test.h index 081443c4..a337ac07 100644 --- a/include/private/vkd3d_test.h +++ b/include/private/vkd3d_test.h @@ -101,12 +101,12 @@ static void vkd3d_test_end_todo(void); struct vkd3d_test_state { - LONG success_count; - LONG failure_count; - LONG skip_count; - LONG todo_count; - LONG todo_success_count; - LONG bug_count; + unsigned int success_count; + unsigned int failure_count; + unsigned int skip_count; + unsigned int todo_count; + unsigned int todo_success_count; + unsigned int bug_count; unsigned int debug_level; @@ -150,13 +150,13 @@ vkd3d_test_check_assert_that(unsigned int line, bool result, const char *fmt, va { if (result) { - InterlockedIncrement(&vkd3d_test_state.success_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.success_count); if (vkd3d_test_state.debug_level > 1) vkd3d_test_printf(line, "Test succeeded.\n"); } else { - InterlockedIncrement(&vkd3d_test_state.failure_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.failure_count); vkd3d_test_printf(line, "Test failed: "); vprintf(fmt, args); } @@ -180,7 +180,7 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg if (is_bug && vkd3d_test_state.bug_enabled) { - InterlockedIncrement(&vkd3d_test_state.bug_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.bug_count); if (is_todo) result = !result; if (result) @@ -193,12 +193,12 @@ vkd3d_test_check_ok(unsigned int line, bool result, const char *fmt, va_list arg { if (result) { - InterlockedIncrement(&vkd3d_test_state.todo_success_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_success_count); vkd3d_test_printf(line, "Todo succeeded: "); } else { - InterlockedIncrement(&vkd3d_test_state.todo_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.todo_count); vkd3d_test_printf(line, "Todo: "); } vprintf(fmt, args); @@ -227,7 +227,7 @@ vkd3d_test_skip(unsigned int line, const char *fmt, ...) vkd3d_test_printf(line, "Test skipped: "); vprintf(fmt, args); va_end(args); - InterlockedIncrement(&vkd3d_test_state.skip_count); + vkd3d_atomic_increment_u32(&vkd3d_test_state.skip_count); } static void VKD3D_PRINTF_FUNC(2, 3) VKD3D_UNUSED @@ -293,16 +293,14 @@ int main(int argc, char **argv) vkd3d_test_main(argc, argv); - printf("%s: %lu tests executed (%lu failures, %lu skipped, %lu todo, %lu bugs).\n", + printf("%s: %u tests executed (%u failures, %u skipped, %u todo, %u bugs).\n", vkd3d_test_name, - (unsigned long)(vkd3d_test_state.success_count - + vkd3d_test_state.failure_count + vkd3d_test_state.todo_count - + vkd3d_test_state.todo_success_count), - (unsigned long)(vkd3d_test_state.failure_count - + vkd3d_test_state.todo_success_count), - (unsigned long)vkd3d_test_state.skip_count, - (unsigned long)vkd3d_test_state.todo_count, - (unsigned long)vkd3d_test_state.bug_count); + vkd3d_test_state.success_count + vkd3d_test_state.failure_count + + vkd3d_test_state.todo_count + vkd3d_test_state.todo_success_count, + vkd3d_test_state.failure_count + vkd3d_test_state.todo_success_count, + vkd3d_test_state.skip_count, + vkd3d_test_state.todo_count, + vkd3d_test_state.bug_count); if (test_platform) free(test_platform); diff --git a/tests/vkd3d_api.c b/tests/vkd3d_api.c index 5a585fec..29948783 100644 --- a/tests/vkd3d_api.c +++ b/tests/vkd3d_api.c @@ -625,7 +625,7 @@ static void test_adapter_luid(void) struct parent { IUnknown IUnknown_iface; - LONG refcount; + unsigned int refcount; }; static struct parent *parent_from_IUnknown(IUnknown *iface) @@ -651,14 +651,14 @@ static ULONG STDMETHODCALLTYPE parent_AddRef(IUnknown *iface) { struct parent *parent = parent_from_IUnknown(iface); - return InterlockedIncrement(&parent->refcount); + return vkd3d_atomic_increment_u32(&parent->refcount); } static ULONG STDMETHODCALLTYPE parent_Release(IUnknown *iface) { struct parent *parent = parent_from_IUnknown(iface); - return InterlockedDecrement(&parent->refcount); + return InterlockedDecrement((LONG *)&parent->refcount); } static const struct IUnknownVtbl parent_vtbl =