mirror of https://github.com/bjornbytes/lovr.git
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++.
This commit is contained in:
parent
eea73792a6
commit
ce2a28360d
|
@ -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 <intrin.h>
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue