| author | |
| committer | |
| log | c31871065394c78d7d316b2a1709077437d29ccf |
| tree | 26f27f5407b035981de4bf1926f478afa436d159 |
| parent | 373e53d7c5940c875a3423a6797f7b5d4a7f36c8 |
2 files changed, 60 insertions(+), 14 deletions(-)
lib/zig.h+30-7| ... | ... | @@ -3636,7 +3636,7 @@ typedef int zig_memory_order; |
| 3636 | 3636 | #define zig_atomicrmw_min(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_min_ ##Type(obj, arg) |
| 3637 | 3637 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) |
| 3638 | 3638 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##Type(obj) | |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) | |
| 3640 | 3640 | #if _M_X64 |
| 3641 | 3641 | #define zig_fence(order) __faststorefence() |
| 3642 | 3642 | #else |
| ... | ... | @@ -3742,7 +3742,15 @@ typedef int zig_memory_order; |
| 3742 | 3742 | static inline void zig_msvc_atomic_store_##ZigType(Type volatile* obj, Type value) { \ |
| 3743 | 3743 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, (SigType)value); \ |
| 3744 | 3744 | } \ |
| 3745 | static inline Type zig_msvc_atomic_load_##ZigType(Type volatile* obj) { \ | |
| 3745 | static inline Type zig_msvc_atomic_load_zig_memory_order_relaxed_##ZigType(Type volatile* obj) { \ | |
| 3746 | return __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3747 | } \ | |
| 3748 | static inline Type zig_msvc_atomic_load_zig_memory_order_acquire_##ZigType(Type volatile* obj) { \ | |
| 3749 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3750 | _ReadWriteBarrier(); \ | |
| 3751 | return val; \ | |
| 3752 | } \ | |
| 3753 | static inline Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##ZigType(Type volatile* obj) { \ | |
| 3746 | 3754 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ |
| 3747 | 3755 | _ReadWriteBarrier(); \ |
| 3748 | 3756 | return val; \ |
| ... | ... | @@ -3760,7 +3768,7 @@ zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) |
| 3760 | 3768 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3761 | 3769 | #endif |
| 3762 | 3770 | |
| 3763 | #define zig_msvc_flt_atomics(Type, SigType, suffix) \ | |
| 3771 | #define zig_msvc_flt_atomics(Type, SigType, suffix, iso_suffix) \ | |
| 3764 | 3772 | static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \ |
| 3765 | 3773 | SigType exchange; \ |
| 3766 | 3774 | SigType comparand; \ |
| ... | ... | @@ -3778,15 +3786,30 @@ zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3778 | 3786 | memcpy(&value, &arg, sizeof(value)); \ |
| 3779 | 3787 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, value); \ |
| 3780 | 3788 | } \ |
| 3781 | static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \ | |
| 3789 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_relaxed_##Type(zig_##Type volatile* obj) { \ | |
| 3782 | 3790 | zig_##Type result; \ |
| 3783 | SigType initial = _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3791 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3784 | 3792 | memcpy(&result, &initial, sizeof(result)); \ |
| 3785 | 3793 | return result; \ |
| 3794 | } \ | |
| 3795 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_acquire_##Type(zig_##Type volatile* obj) { \ | |
| 3796 | zig_##Type result; \ | |
| 3797 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3798 | _ReadWriteBarrier(); \ | |
| 3799 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3800 | return result; \ | |
| 3801 | } \ | |
| 3802 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##Type(zig_##Type volatile* obj) { \ | |
| 3803 | zig_##Type result; \ | |
| 3804 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3805 | _ReadWriteBarrier(); \ | |
| 3806 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3807 | return result; \ | |
| 3786 | 3808 | } |
| 3787 | zig_msvc_flt_atomics(f32, long, ) | |
| 3809 | ||
| 3810 | zig_msvc_flt_atomics(f32, long, , 32) | |
| 3788 | 3811 | #if _M_X64 |
| 3789 | zig_msvc_flt_atomics(f64, int64_t, 64) | |
| 3812 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) | |
| 3790 | 3813 | #endif |
| 3791 | 3814 | |
| 3792 | 3815 | #if _M_IX86 |
stage1/zig.h+30-7| ... | ... | @@ -3636,7 +3636,7 @@ typedef int zig_memory_order; |
| 3636 | 3636 | #define zig_atomicrmw_min(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_min_ ##Type(obj, arg) |
| 3637 | 3637 | #define zig_atomicrmw_max(res, obj, arg, order, Type, ReprType) res = zig_msvc_atomicrmw_max_ ##Type(obj, arg) |
| 3638 | 3638 | #define zig_atomic_store( obj, arg, order, Type, ReprType) zig_msvc_atomic_store_ ##Type(obj, arg) |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##Type(obj) | |
| 3639 | #define zig_atomic_load(res, obj, order, Type, ReprType) res = zig_msvc_atomic_load_ ##order##_##Type(obj) | |
| 3640 | 3640 | #if _M_X64 |
| 3641 | 3641 | #define zig_fence(order) __faststorefence() |
| 3642 | 3642 | #else |
| ... | ... | @@ -3742,7 +3742,15 @@ typedef int zig_memory_order; |
| 3742 | 3742 | static inline void zig_msvc_atomic_store_##ZigType(Type volatile* obj, Type value) { \ |
| 3743 | 3743 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, (SigType)value); \ |
| 3744 | 3744 | } \ |
| 3745 | static inline Type zig_msvc_atomic_load_##ZigType(Type volatile* obj) { \ | |
| 3745 | static inline Type zig_msvc_atomic_load_zig_memory_order_relaxed_##ZigType(Type volatile* obj) { \ | |
| 3746 | return __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3747 | } \ | |
| 3748 | static inline Type zig_msvc_atomic_load_zig_memory_order_acquire_##ZigType(Type volatile* obj) { \ | |
| 3749 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3750 | _ReadWriteBarrier(); \ | |
| 3751 | return val; \ | |
| 3752 | } \ | |
| 3753 | static inline Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##ZigType(Type volatile* obj) { \ | |
| 3746 | 3754 | Type val = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ |
| 3747 | 3755 | _ReadWriteBarrier(); \ |
| 3748 | 3756 | return val; \ |
| ... | ... | @@ -3760,7 +3768,7 @@ zig_msvc_atomics(u64, uint64_t, __int64, 64, 64) |
| 3760 | 3768 | zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3761 | 3769 | #endif |
| 3762 | 3770 | |
| 3763 | #define zig_msvc_flt_atomics(Type, SigType, suffix) \ | |
| 3771 | #define zig_msvc_flt_atomics(Type, SigType, suffix, iso_suffix) \ | |
| 3764 | 3772 | static inline bool zig_msvc_cmpxchg_##Type(zig_##Type volatile* obj, zig_##Type* expected, zig_##Type desired) { \ |
| 3765 | 3773 | SigType exchange; \ |
| 3766 | 3774 | SigType comparand; \ |
| ... | ... | @@ -3778,15 +3786,30 @@ zig_msvc_atomics(i64, int64_t, __int64, 64, 64) |
| 3778 | 3786 | memcpy(&value, &arg, sizeof(value)); \ |
| 3779 | 3787 | (void)_InterlockedExchange##suffix((SigType volatile*)obj, value); \ |
| 3780 | 3788 | } \ |
| 3781 | static inline zig_##Type zig_msvc_atomic_load_##Type(zig_##Type volatile* obj) { \ | |
| 3789 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_relaxed_##Type(zig_##Type volatile* obj) { \ | |
| 3782 | 3790 | zig_##Type result; \ |
| 3783 | SigType initial = _InterlockedExchangeAdd##suffix((SigType volatile*)obj, (SigType)0); \ | |
| 3791 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3784 | 3792 | memcpy(&result, &initial, sizeof(result)); \ |
| 3785 | 3793 | return result; \ |
| 3794 | } \ | |
| 3795 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_acquire_##Type(zig_##Type volatile* obj) { \ | |
| 3796 | zig_##Type result; \ | |
| 3797 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3798 | _ReadWriteBarrier(); \ | |
| 3799 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3800 | return result; \ | |
| 3801 | } \ | |
| 3802 | static inline zig_##Type zig_msvc_atomic_load_zig_memory_order_seq_cst_##Type(zig_##Type volatile* obj) { \ | |
| 3803 | zig_##Type result; \ | |
| 3804 | SigType initial = __iso_volatile_load##iso_suffix((SigType volatile*)obj); \ | |
| 3805 | _ReadWriteBarrier(); \ | |
| 3806 | memcpy(&result, &initial, sizeof(result)); \ | |
| 3807 | return result; \ | |
| 3786 | 3808 | } |
| 3787 | zig_msvc_flt_atomics(f32, long, ) | |
| 3809 | ||
| 3810 | zig_msvc_flt_atomics(f32, long, , 32) | |
| 3788 | 3811 | #if _M_X64 |
| 3789 | zig_msvc_flt_atomics(f64, int64_t, 64) | |
| 3812 | zig_msvc_flt_atomics(f64, int64_t, 64, 64) | |
| 3790 | 3813 | #endif |
| 3791 | 3814 | |
| 3792 | 3815 | #if _M_IX86 |