From ce2a28360dd7cb297c4e79b2c54ab4528a29bf0a Mon Sep 17 00:00:00 2001 From: bjorn Date: Thu, 30 Apr 2020 16:49:53 -0600 Subject: [PATCH] Unconditionally cast ref to volatile long on win32; This was originally a C++-only contribution, but clang also warns about it on windows when compiling as C. It's nice to have one less thing specific to C++. --- src/core/ref.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/core/ref.h b/src/core/ref.h index 21fb5ce3..79d2937f 100644 --- a/src/core/ref.h +++ b/src/core/ref.h @@ -17,18 +17,12 @@ static inline uint32_t ref_dec(Ref* ref) { return --*ref; } #elif defined(_MSC_VER) -#ifdef __cplusplus -#define _LOVR_REF_H_CPP_CAST (volatile long *) -#else -#define _LOVR_REF_H_CPP_CAST -#endif - // MSVC atomics #include typedef uint32_t Ref; -static inline uint32_t ref_inc(Ref* ref) { return _InterlockedIncrement(_LOVR_REF_H_CPP_CAST ref); } -static inline uint32_t ref_dec(Ref* ref) { return _InterlockedDecrement(_LOVR_REF_H_CPP_CAST ref); } +static inline uint32_t ref_inc(Ref* ref) { return _InterlockedIncrement((volatile long*) ref); } +static inline uint32_t ref_dec(Ref* ref) { return _InterlockedDecrement((volatile long*) ref); } #elif (defined(__GNUC_MINOR__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) \ || (__has_builtin(__atomic_add_fetch) && __has_builtin(__atomic_sub_fetch))