Skip to content

Commit

Permalink
Some minor fixes for C++23 compilation errors. (#8422)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
zvookin and Zalman Stern authored Sep 23, 2024
1 parent 53124cd commit 9a02890
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/runtime/d3d12compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ WEAK void d3d12_free(void *p) {
free(p);
}

template<typename T>
WEAK T zero_struct() {
T zero = {};
return zero;
}

template<typename T>
WEAK T *malloct() {
TRACELOG;
Expand All @@ -244,12 +250,6 @@ WEAK T *malloct() {
return p;
}

template<typename T>
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"
Expand Down
30 changes: 15 additions & 15 deletions src/runtime/runtime_atomics.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,27 @@ ALWAYS_INLINE T atomic_fetch_add_acquire_release(T *addr, T val) {
}

template<typename T, typename TV = typename remove_volatile<T>::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<typename T, typename TV = typename remove_volatile<T>::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<typename T, typename TV = typename remove_volatile<T>::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<typename T>
ALWAYS_INLINE T atomic_add_fetch_sequentially_consistent(T *addr, T val) {
template<typename T, typename TV = typename remove_volatile<T>::type>
ALWAYS_INLINE TV atomic_add_fetch_sequentially_consistent(T *addr, TV val) {
return __sync_add_and_fetch(addr, val);
}

template<typename T>
ALWAYS_INLINE T atomic_sub_fetch_sequentially_consistent(T *addr, T val) {
template<typename T, typename TV = typename remove_volatile<T>::type>
ALWAYS_INLINE TV atomic_sub_fetch_sequentially_consistent(T *addr, TV val) {
return __sync_sub_and_fetch(addr, val);
}

Expand Down Expand Up @@ -103,7 +103,7 @@ ALWAYS_INLINE T atomic_fetch_and_release(T *addr, T val) {
}

template<typename T, typename TV = typename remove_volatile<T>::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);
}

Expand Down Expand Up @@ -165,27 +165,27 @@ ALWAYS_INLINE T atomic_fetch_add_acquire_release(T *addr, T val) {
}

template<typename T, typename TV = typename remove_volatile<T>::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<typename T, typename TV = typename remove_volatile<T>::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<typename T, typename TV = typename remove_volatile<T>::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<typename T>
ALWAYS_INLINE T atomic_add_fetch_sequentially_consistent(T *addr, T val) {
template<typename T, typename TV = typename remove_volatile<T>::type>
ALWAYS_INLINE TV atomic_add_fetch_sequentially_consistent(T *addr, TV val) {
return __atomic_add_fetch(addr, val, __ATOMIC_SEQ_CST);
}

template<typename T>
ALWAYS_INLINE T atomic_sub_fetch_sequentially_consistent(T *addr, T val) {
template<typename T, typename TV = typename remove_volatile<T>::type>
ALWAYS_INLINE TV atomic_sub_fetch_sequentially_consistent(T *addr, TV val) {
return __atomic_sub_fetch(addr, val, __ATOMIC_SEQ_CST);
}

Expand Down

0 comments on commit 9a02890

Please sign in to comment.