// def _Py_atomic_load_ptr_acquire(obj):
// return obj # acquire
//
-// def _Py_atomic_store_ptr_release(obj):
-// return obj # release
+// def _Py_atomic_store_ptr_release(obj, value):
+// obj = value # release
//
// def _Py_atomic_fence_seq_cst():
// # sequential consistency
static inline int
_Py_atomic_load_int_acquire(const int *obj);
+static inline void
+_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value);
+
static inline void
_Py_atomic_store_uint32_release(uint32_t *obj, uint32_t value);
_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value)
{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }
+static inline void
+_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)
+{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); }
+
static inline int
_Py_atomic_load_int_acquire(const int *obj)
{ return __atomic_load_n(obj, __ATOMIC_ACQUIRE); }
*(volatile unsigned short *)obj = value;
}
-static inline void
-_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)
-{
- *(volatile unsigned int *)obj = value;
-}
-
static inline void
_Py_atomic_store_long_relaxed(long *obj, long value)
{
#endif
}
+static inline void
+_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)
+{
+#if defined(_M_X64) || defined(_M_IX86)
+ *(volatile unsigned int *)obj = value;
+#elif defined(_M_ARM64)
+ _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32);
+ __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value);
+#else
+# error "no implementation of _Py_atomic_store_uint_release"
+#endif
+}
+
static inline void
_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value)
{
_Py_atomic_load_uint16(const uint16_t *obj)
{
_Py_USING_STD;
- return atomic_load((const _Atomic(uint32_t)*)obj);
+ return atomic_load((const _Atomic(uint16_t)*)obj);
}
static inline uint32_t
--- /dev/null
+Fix wrong type in ``_Py_atomic_load_uint16`` in the C11 atomics backend
+(``pyatomic_std.h``), which used a 32-bit atomic load instead of 16-bit.
+Found by Mohammed Zuhaib.