From 9a02890c8a23a9acae27e4ac6ae6d63c741dc899 Mon Sep 17 00:00:00 2001 From: Zalman Stern <1501716+zvookin@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:51:56 -0700 Subject: [PATCH] Some minor fixes for C++23 compilation errors. (#8422) First is just a requirement that a template be declared before use. Second is removing volatile from non-reference return types. Co-authored-by: Zalman Stern --- src/runtime/d3d12compute.cpp | 12 ++++++------ src/runtime/runtime_atomics.h | 30 +++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/runtime/d3d12compute.cpp b/src/runtime/d3d12compute.cpp index f4f85180a56e..8d472e22a0ba 100644 --- a/src/runtime/d3d12compute.cpp +++ b/src/runtime/d3d12compute.cpp @@ -232,6 +232,12 @@ WEAK void d3d12_free(void *p) { free(p); } +template +WEAK T zero_struct() { + T zero = {}; + return zero; +} + template WEAK T *malloct() { TRACELOG; @@ -244,12 +250,6 @@ WEAK T *malloct() { return p; } -template -WEAK T zero_struct() { - T zero = {}; - return zero; -} - #define hashmap_malloc(user_context, size) d3d12_malloc(size) #define hashmap_free(user_context, memory) d3d12_free(memory) #include "hashmap.h" diff --git a/src/runtime/runtime_atomics.h b/src/runtime/runtime_atomics.h index 61139a622d75..1e9a2367c3e0 100644 --- a/src/runtime/runtime_atomics.h +++ b/src/runtime/runtime_atomics.h @@ -39,27 +39,27 @@ ALWAYS_INLINE T atomic_fetch_add_acquire_release(T *addr, T val) { } template::type> -ALWAYS_INLINE T atomic_fetch_add_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_add_sequentially_consistent(T *addr, TV val) { return __sync_fetch_and_add(addr, val); } template::type> -ALWAYS_INLINE T atomic_fetch_sub_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_sub_sequentially_consistent(T *addr, TV val) { return __sync_fetch_and_sub(addr, val); } template::type> -ALWAYS_INLINE T atomic_fetch_or_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_or_sequentially_consistent(T *addr, TV val) { return __sync_fetch_and_or(addr, val); } -template -ALWAYS_INLINE T atomic_add_fetch_sequentially_consistent(T *addr, T val) { +template::type> +ALWAYS_INLINE TV atomic_add_fetch_sequentially_consistent(T *addr, TV val) { return __sync_add_and_fetch(addr, val); } -template -ALWAYS_INLINE T atomic_sub_fetch_sequentially_consistent(T *addr, T val) { +template::type> +ALWAYS_INLINE TV atomic_sub_fetch_sequentially_consistent(T *addr, TV val) { return __sync_sub_and_fetch(addr, val); } @@ -103,7 +103,7 @@ ALWAYS_INLINE T atomic_fetch_and_release(T *addr, T val) { } template::type> -ALWAYS_INLINE T atomic_fetch_and_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_and_sequentially_consistent(T *addr, TV val) { return __sync_fetch_and_and(addr, val); } @@ -165,27 +165,27 @@ ALWAYS_INLINE T atomic_fetch_add_acquire_release(T *addr, T val) { } template::type> -ALWAYS_INLINE T atomic_fetch_add_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_add_sequentially_consistent(T *addr, TV val) { return __atomic_fetch_add(addr, val, __ATOMIC_SEQ_CST); } template::type> -ALWAYS_INLINE T atomic_fetch_sub_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_sub_sequentially_consistent(T *addr, TV val) { return __atomic_fetch_sub(addr, val, __ATOMIC_SEQ_CST); } template::type> -ALWAYS_INLINE T atomic_fetch_or_sequentially_consistent(T *addr, TV val) { +ALWAYS_INLINE TV atomic_fetch_or_sequentially_consistent(T *addr, TV val) { return __atomic_fetch_or(addr, val, __ATOMIC_SEQ_CST); } -template -ALWAYS_INLINE T atomic_add_fetch_sequentially_consistent(T *addr, T val) { +template::type> +ALWAYS_INLINE TV atomic_add_fetch_sequentially_consistent(T *addr, TV val) { return __atomic_add_fetch(addr, val, __ATOMIC_SEQ_CST); } -template -ALWAYS_INLINE T atomic_sub_fetch_sequentially_consistent(T *addr, T val) { +template::type> +ALWAYS_INLINE TV atomic_sub_fetch_sequentially_consistent(T *addr, TV val) { return __atomic_sub_fetch(addr, val, __ATOMIC_SEQ_CST); }