@@ -3643,18 +3643,29 @@ zig_msvc_atomics(u64, uint64_t, __int64, 64)
3643
3643
zig_msvc_atomics (i64 , int64_t , __int64 , 64 )
3644
3644
#endif
3645
3645
3646
- #define zig_msvc_flt_atomics (Type , ReprType , suffix ) \
3646
+ #define zig_msvc_flt_atomics (Type , SigType , suffix ) \
3647
3647
static inline bool zig_msvc_cmpxchg_ ##Type (zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \
3648
- ReprType exchange; \
3649
- ReprType comparand; \
3650
- ReprType initial; \
3648
+ SigType exchange; \
3649
+ SigType comparand; \
3650
+ SigType initial; \
3651
3651
bool success; \
3652
3652
memcpy(&comparand, expected, sizeof(comparand)); \
3653
3653
memcpy(&exchange, &desired, sizeof(exchange)); \
3654
- initial = _InterlockedCompareExchange##suffix((ReprType volatile*)obj, exchange, comparand); \
3654
+ initial = _InterlockedCompareExchange##suffix((SigType volatile*)obj, exchange, comparand); \
3655
3655
success = initial == comparand; \
3656
3656
if (!success) memcpy(expected, &initial, sizeof(*expected)); \
3657
3657
return success; \
3658
+ } \
3659
+ static inline void zig_msvc_atomic_store_##Type(zig_##Type volatile* obj, zig_##Type arg) { \
3660
+ SigType value; \
3661
+ memcpy(&value, &arg, sizeof(value)); \
3662
+ (void)_InterlockedExchange##suffix((SigType volatile*)obj, value); \
3663
+ } \
3664
+ static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \
3665
+ zig_##Type result; \
3666
+ SigType initial = _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \
3667
+ memcpy(&result, &initial, sizeof(result)); \
3668
+ return result; \
3658
3669
}
3659
3670
zig_msvc_flt_atomics (f32 , long , )
3660
3671
#if _M_X64
0 commit comments