diff --git a/Include/cpython/pyatomic.h b/Include/cpython/pyatomic.h index 96cc06ce3a61bc..6d106c1b499c69 100644 --- a/Include/cpython/pyatomic.h +++ b/Include/cpython/pyatomic.h @@ -482,56 +482,49 @@ _Py_atomic_store_ullong_relaxed(unsigned long long *obj, static inline void _Py_atomic_store_char_relaxed(char *obj, char value); - -// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ - -// Loads `*obj` (acquire operation) -static inline void * -_Py_atomic_load_ptr_acquire(const void *obj); - -static inline uintptr_t -_Py_atomic_load_uintptr_acquire(const uintptr_t *obj); - -// Stores `*obj = value` (release operation) static inline void -_Py_atomic_store_ptr_release(void *obj, void *value); +_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value); static inline void -_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value); +_Py_atomic_store_short_relaxed(short *obj, short value); static inline void -_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value); +_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value); static inline void -_Py_atomic_store_int_release(int *obj, int value); +_Py_atomic_store_long_relaxed(long *obj, long value); static inline void -_Py_atomic_store_uchar_release(unsigned char *obj, unsigned char value); +_Py_atomic_store_float_relaxed(float *obj, float value); static inline void -_Py_atomic_store_short_release(short *obj, short value); +_Py_atomic_store_double_relaxed(double *obj, double value); static inline void -_Py_atomic_store_ushort_release(unsigned short *obj, unsigned short value); +_Py_atomic_store_llong_relaxed(long long *obj, long long value); -static inline void -_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value); -static inline void -_Py_atomic_store_long_release(long *obj, long value); +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +// Loads `*obj` (acquire operation) +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj); +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj); + +// Stores `*obj = value` (release operation) static inline void -_Py_atomic_store_float_release(float *obj, float value); +_Py_atomic_store_ptr_release(void *obj, void *value); static inline void -_Py_atomic_store_double_release(double *obj, double value); +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value); static inline void -_Py_atomic_store_llong_release(long long *obj, long long value); +_Py_atomic_store_ssize_release(Py_ssize_t *obj, Py_ssize_t value); static inline void -_Py_atomic_store_ullong_release(unsigned long long *obj, - unsigned long long value); +_Py_atomic_store_int_release(int *obj, int value); static inline int _Py_atomic_load_int_acquire(const int *obj); diff --git a/Include/cpython/pyatomic_gcc.h b/Include/cpython/pyatomic_gcc.h index b11b8a2368d44c..b179e4c9a185a9 100644 --- a/Include/cpython/pyatomic_gcc.h +++ b/Include/cpython/pyatomic_gcc.h @@ -521,64 +521,55 @@ static inline void _Py_atomic_store_char_relaxed(char *obj, char value) { __atomic_store_n(obj, value, __ATOMIC_RELEASE); } - -// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ - -static inline void * -_Py_atomic_load_ptr_acquire(const void *obj) -{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_ACQUIRE); } - -static inline uintptr_t -_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) -{ return (uintptr_t)__atomic_load_n(obj, __ATOMIC_ACQUIRE); } - static inline void -_Py_atomic_store_ptr_release(void *obj, void *value) -{ __atomic_store_n((void **)obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_short_relaxed(short *obj, short value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_int_release(int *obj, int value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_uchar_release(unsigned char *obj, unsigned char value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_long_relaxed(long *obj, long value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_short_release(short *obj, short value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_float_relaxed(float *obj, float value) +{ __atomic_store(obj, &value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_ushort_release(unsigned short *obj, unsigned short value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_double_relaxed(double *obj, double value) +{ __atomic_store(obj, &value, __ATOMIC_RELAXED); } static inline void -_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } +_Py_atomic_store_llong_relaxed(long long *obj, long long value) +{ __atomic_store_n(obj, value, __ATOMIC_RELAXED); } -static inline void -_Py_atomic_store_long_release(long *obj, long value) -{ __atomic_store_n(obj, value, __ATOMIC_RELEASE); } -static inline void -_Py_atomic_store_float_release(float *obj, float value) -{ __atomic_store(obj, &value, __ATOMIC_RELEASE); } +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) +{ return (void *)__atomic_load_n((void * const *)obj, __ATOMIC_ACQUIRE); } + +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +{ return (uintptr_t)__atomic_load_n(obj, __ATOMIC_ACQUIRE); } static inline void -_Py_atomic_store_double_release(double *obj, double value) -{ __atomic_store(obj, &value, __ATOMIC_RELEASE); } +_Py_atomic_store_ptr_release(void *obj, void *value) +{ __atomic_store_n((void **)obj, value, __ATOMIC_RELEASE); } static inline void -_Py_atomic_store_llong_release(long long *obj, long long value) +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) { __atomic_store_n(obj, value, __ATOMIC_RELEASE); } static inline void -_Py_atomic_store_ullong_release(unsigned long long *obj, - unsigned long long value) +_Py_atomic_store_int_release(int *obj, int value) { __atomic_store_n(obj, value, __ATOMIC_RELEASE); } static inline void diff --git a/Include/cpython/pyatomic_msc.h b/Include/cpython/pyatomic_msc.h index 51708b97fc9479..a7600114a64aef 100644 --- a/Include/cpython/pyatomic_msc.h +++ b/Include/cpython/pyatomic_msc.h @@ -953,185 +953,116 @@ _Py_atomic_store_char_relaxed(char *obj, char value) *(volatile char *)obj = value; } - -// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ - -static inline void * -_Py_atomic_load_ptr_acquire(const void *obj) -{ -#if defined(_M_X64) || defined(_M_IX86) - return *(void * volatile *)obj; -#elif defined(_M_ARM64) - return (void *)__ldar64((unsigned __int64 volatile *)obj); -#else -# error "no implementation of _Py_atomic_load_ptr_acquire" -#endif -} - -static inline uintptr_t -_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +static inline void +_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value) { -#if defined(_M_X64) || defined(_M_IX86) - return *(uintptr_t volatile *)obj; -#elif defined(_M_ARM64) - return (uintptr_t)__ldar64((unsigned __int64 volatile *)obj); -#else -# error "no implementation of _Py_atomic_load_uintptr_acquire" -#endif + *(volatile unsigned char*)obj = value; } static inline void -_Py_atomic_store_ptr_release(void *obj, void *value) +_Py_atomic_store_short_relaxed(short *obj, short value) { -#if defined(_M_X64) || defined(_M_IX86) - *(void * volatile *)obj = value; -#elif defined(_M_ARM64) - __stlr64((unsigned __int64 volatile *)obj, (uintptr_t)value); -#else -# error "no implementation of _Py_atomic_store_ptr_release" -#endif + *(volatile short*)obj = value; } static inline void -_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) +_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value) { -#if defined(_M_X64) || defined(_M_IX86) - *(uintptr_t volatile *)obj = value; -#elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int64); - __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); -#else -# error "no implementation of _Py_atomic_store_uintptr_release" -#endif + *(volatile unsigned short*)obj = value; } static inline void -_Py_atomic_store_int_release(int *obj, int value) +_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value) { -#if defined(_M_X64) || defined(_M_IX86) - *(int volatile *)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_int_release" -#endif + *(volatile unsigned int*)obj = value; } static inline void -_Py_atomic_store_uchar_release(unsigned char *obj, unsigned char value) +_Py_atomic_store_long_relaxed(long *obj, long value) { -#if defined(_M_X64) || defined(_M_IX86) - *(unsigned char volatile *)obj = value; -#elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int8); - __stlr8((unsigned __int8 volatile *)obj, (unsigned __int8)value); -#else -# error "no implementation of _Py_atomic_store_uchar_release" -#endif + *(volatile long *)obj = value; } static inline void -_Py_atomic_store_short_release(short *obj, short value) +_Py_atomic_store_float_relaxed(float *obj, float value) { -#if defined(_M_X64) || defined(_M_IX86) - *(short volatile *)obj = value; -#elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int16); - __stlr16((unsigned __int16 volatile *)obj, (unsigned __int16)value); -#else -# error "no implementation of _Py_atomic_store_short_release" -#endif + *(volatile float *)obj = value; } static inline void -_Py_atomic_store_ushort_release(unsigned short *obj, unsigned short value) +_Py_atomic_store_double_relaxed(double *obj, double value) { -#if defined(_M_X64) || defined(_M_IX86) - *(unsigned short volatile *)obj = value; -#elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int16); - __stlr16((unsigned __int16 volatile *)obj, (unsigned __int16)value); -#else -# error "no implementation of _Py_atomic_store_ushort_release" -#endif + *(volatile double *)obj = value; } static inline void -_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value) +_Py_atomic_store_llong_relaxed(long long *obj, long long value) { -#if defined(_M_X64) || defined(_M_IX86) - *(unsigned int volatile *)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 + *(volatile long long*)obj = value; } -static inline void -_Py_atomic_store_long_release(long *obj, long value) + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) { #if defined(_M_X64) || defined(_M_IX86) - *(long volatile *)obj = value; + return *(void * volatile *)obj; #elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); - __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value); + return (void *)__ldar64((unsigned __int64 volatile *)obj); #else -# error "no implementation of _Py_atomic_store_long_release" +# error "no implementation of _Py_atomic_load_ptr_acquire" #endif } -static inline void -_Py_atomic_store_float_release(float *obj, float value) +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) { #if defined(_M_X64) || defined(_M_IX86) - *(float volatile *)obj = value; + return *(uintptr_t volatile *)obj; #elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); - __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value); + return (uintptr_t)__ldar64((unsigned __int64 volatile *)obj); #else -# error "no implementation of _Py_atomic_store_float_release" +# error "no implementation of _Py_atomic_load_uintptr_acquire" #endif } static inline void -_Py_atomic_store_double_release(double *obj, double value) +_Py_atomic_store_ptr_release(void *obj, void *value) { #if defined(_M_X64) || defined(_M_IX86) - *(double volatile *)obj = value; + *(void * volatile *)obj = value; #elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(unsigned __int64); - __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); + __stlr64((unsigned __int64 volatile *)obj, (uintptr_t)value); #else -# error "no implementation of _Py_atomic_store_double_release" +# error "no implementation of _Py_atomic_store_ptr_release" #endif } static inline void -_Py_atomic_store_llong_release(long long *obj, long long value) +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) { #if defined(_M_X64) || defined(_M_IX86) - *(long long volatile *)obj = value; + *(uintptr_t volatile *)obj = value; #elif defined(_M_ARM64) _Py_atomic_ASSERT_ARG_TYPE(unsigned __int64); __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); #else -# error "no implementation of _Py_atomic_store_llong_release" +# error "no implementation of _Py_atomic_store_uintptr_release" #endif } static inline void -_Py_atomic_store_ullong_release(unsigned long long *obj, unsigned long long value) +_Py_atomic_store_int_release(int *obj, int value) { #if defined(_M_X64) || defined(_M_IX86) - *(unsigned long long volatile *)obj = value; + *(int volatile *)obj = value; #elif defined(_M_ARM64) - _Py_atomic_ASSERT_ARG_TYPE(__int64); - __stlr64((unsigned __int64 volatile *)obj, (unsigned __int64)value); + _Py_atomic_ASSERT_ARG_TYPE(unsigned __int32); + __stlr32((unsigned __int32 volatile *)obj, (unsigned __int32)value); #else -# error "no implementation of _Py_atomic_store_ullong_release" +# error "no implementation of _Py_atomic_store_int_release" #endif } diff --git a/Include/cpython/pyatomic_std.h b/Include/cpython/pyatomic_std.h index c2a411466327ac..69a8b9e615ea5f 100644 --- a/Include/cpython/pyatomic_std.h +++ b/Include/cpython/pyatomic_std.h @@ -924,119 +924,110 @@ _Py_atomic_store_char_relaxed(char *obj, char value) memory_order_relaxed); } - -// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ - -static inline void * -_Py_atomic_load_ptr_acquire(const void *obj) -{ - _Py_USING_STD; - return atomic_load_explicit((const _Atomic(void*)*)obj, - memory_order_acquire); -} - -static inline uintptr_t -_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) +static inline void +_Py_atomic_store_uchar_relaxed(unsigned char *obj, unsigned char value) { _Py_USING_STD; - return atomic_load_explicit((const _Atomic(uintptr_t)*)obj, - memory_order_acquire); + atomic_store_explicit((_Atomic(unsigned char)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_ptr_release(void *obj, void *value) +_Py_atomic_store_short_relaxed(short *obj, short value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(void*)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(short)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) +_Py_atomic_store_ushort_relaxed(unsigned short *obj, unsigned short value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(uintptr_t)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(unsigned short)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_int_release(int *obj, int value) +_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(int)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(unsigned int)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_uchar_release(unsigned char *obj, unsigned char value) +_Py_atomic_store_long_relaxed(long *obj, long value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(unsigned char)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(long)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_short_release(short *obj, short value) +_Py_atomic_store_float_relaxed(float *obj, float value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(short)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(float)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_ushort_release(unsigned short *obj, unsigned short value) +_Py_atomic_store_double_relaxed(double *obj, double value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(unsigned short)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(double)*)obj, value, + memory_order_relaxed); } static inline void -_Py_atomic_store_uint_release(unsigned int *obj, unsigned int value) +_Py_atomic_store_llong_relaxed(long long *obj, long long value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(unsigned int)*)obj, value, - memory_order_release); + atomic_store_explicit((_Atomic(long long)*)obj, value, + memory_order_relaxed); } -static inline void -_Py_atomic_store_long_release(long *obj, long value) + +// --- _Py_atomic_load_ptr_acquire / _Py_atomic_store_ptr_release ------------ + +static inline void * +_Py_atomic_load_ptr_acquire(const void *obj) { _Py_USING_STD; - atomic_store_explicit((_Atomic(long)*)obj, value, - memory_order_release); + return atomic_load_explicit((const _Atomic(void*)*)obj, + memory_order_acquire); } -static inline void -_Py_atomic_store_float_release(float *obj, float value) +static inline uintptr_t +_Py_atomic_load_uintptr_acquire(const uintptr_t *obj) { _Py_USING_STD; - atomic_store_explicit((_Atomic(float)*)obj, value, - memory_order_release); + return atomic_load_explicit((const _Atomic(uintptr_t)*)obj, + memory_order_acquire); } static inline void -_Py_atomic_store_double_release(double *obj, double value) +_Py_atomic_store_ptr_release(void *obj, void *value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(double)*)obj, value, + atomic_store_explicit((_Atomic(void*)*)obj, value, memory_order_release); } static inline void -_Py_atomic_store_llong_release(long long *obj, long long value) +_Py_atomic_store_uintptr_release(uintptr_t *obj, uintptr_t value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(long long)*)obj, value, + atomic_store_explicit((_Atomic(uintptr_t)*)obj, value, memory_order_release); } static inline void -_Py_atomic_store_ullong_release(unsigned long long *obj, - unsigned long long value) +_Py_atomic_store_int_release(int *obj, int value) { _Py_USING_STD; - atomic_store_explicit((_Atomic(unsigned long long)*)obj, value, + atomic_store_explicit((_Atomic(int)*)obj, value, memory_order_release); } diff --git a/Include/internal/pycore_pyatomic_ft_wrappers.h b/Include/internal/pycore_pyatomic_ft_wrappers.h index 914dba0b5f6792..f7b81f757b33e8 100644 --- a/Include/internal/pycore_pyatomic_ft_wrappers.h +++ b/Include/internal/pycore_pyatomic_ft_wrappers.h @@ -65,48 +65,48 @@ extern "C" { _Py_atomic_store_char_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_CHAR_RELAXED(value) \ _Py_atomic_load_char_relaxed(&value) -#define FT_ATOMIC_STORE_UCHAR_RELEASE(value, new_value) \ - _Py_atomic_store_uchar_release(&value, new_value) +#define FT_ATOMIC_STORE_UCHAR_RELAXED(value, new_value) \ + _Py_atomic_store_uchar_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_UCHAR_RELAXED(value) \ _Py_atomic_load_uchar_relaxed(&value) -#define FT_ATOMIC_STORE_SHORT_RELEASE(value, new_value) \ - _Py_atomic_store_short_release(&value, new_value) +#define FT_ATOMIC_STORE_SHORT_RELAXED(value, new_value) \ + _Py_atomic_store_short_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_SHORT_RELAXED(value) \ _Py_atomic_load_short_relaxed(&value) -#define FT_ATOMIC_STORE_USHORT_RELEASE(value, new_value) \ - _Py_atomic_store_ushort_release(&value, new_value) +#define FT_ATOMIC_STORE_USHORT_RELAXED(value, new_value) \ + _Py_atomic_store_ushort_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_USHORT_RELAXED(value) \ _Py_atomic_load_ushort_relaxed(&value) -#define FT_ATOMIC_STORE_INT_RELEASE(value, new_value) \ - _Py_atomic_store_int_release(&value, new_value) +#define FT_ATOMIC_STORE_INT_RELAXED(value, new_value) \ + _Py_atomic_store_int_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_INT_RELAXED(value) \ _Py_atomic_load_int_relaxed(&value) -#define FT_ATOMIC_STORE_UINT_RELEASE(value, new_value) \ - _Py_atomic_store_uint_release(&value, new_value) +#define FT_ATOMIC_STORE_UINT_RELAXED(value, new_value) \ + _Py_atomic_store_uint_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_UINT_RELAXED(value) \ _Py_atomic_load_uint_relaxed(&value) -#define FT_ATOMIC_STORE_LONG_RELEASE(value, new_value) \ - _Py_atomic_store_long_release(&value, new_value) +#define FT_ATOMIC_STORE_LONG_RELAXED(value, new_value) \ + _Py_atomic_store_long_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_LONG_RELAXED(value) \ _Py_atomic_load_long_relaxed(&value) -#define FT_ATOMIC_STORE_ULONG(value, new_value) \ - _Py_atomic_store_ulong(&value, new_value) -#define FT_ATOMIC_STORE_SSIZE_RELEASE(value, new_value) \ - _Py_atomic_store_ssize_release(&value, new_value) -#define FT_ATOMIC_STORE_FLOAT_RELEASE(value, new_value) \ - _Py_atomic_store_float_release(&value, new_value) +#define FT_ATOMIC_STORE_ULONG_RELAXED(value, new_value) \ + _Py_atomic_store_ulong_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_SSIZE_RELAXED(value, new_value) \ + _Py_atomic_store_ssize_relaxed(&value, new_value) +#define FT_ATOMIC_STORE_FLOAT_RELAXED(value, new_value) \ + _Py_atomic_store_float_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_FLOAT_RELAXED(value) \ _Py_atomic_load_float_relaxed(&value) -#define FT_ATOMIC_STORE_DOUBLE_RELEASE(value, new_value) \ - _Py_atomic_store_double_release(&value, new_value) +#define FT_ATOMIC_STORE_DOUBLE_RELAXED(value, new_value) \ + _Py_atomic_store_double_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_DOUBLE_RELAXED(value) \ _Py_atomic_load_double_relaxed(&value) -#define FT_ATOMIC_STORE_LLONG_RELEASE(value, new_value) \ - _Py_atomic_store_llong_release(&value, new_value) +#define FT_ATOMIC_STORE_LLONG_RELAXED(value, new_value) \ + _Py_atomic_store_llong_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_LLONG_RELAXED(value) \ _Py_atomic_load_llong_relaxed(&value) -#define FT_ATOMIC_STORE_ULLONG_RELEASE(value, new_value) \ - _Py_atomic_store_ullong_release(&value, new_value) +#define FT_ATOMIC_STORE_ULLONG_RELAXED(value, new_value) \ + _Py_atomic_store_ullong_relaxed(&value, new_value) #define FT_ATOMIC_LOAD_ULLONG_RELAXED(value) \ _Py_atomic_load_ullong_relaxed(&value) diff --git a/Python/structmember.c b/Python/structmember.c index 5fbde435031631..28b1a2597e3f66 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -191,7 +191,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; - FT_ATOMIC_STORE_UCHAR_RELEASE(*(unsigned char*)addr, (unsigned char)long_val); + FT_ATOMIC_STORE_UCHAR_RELAXED(*(unsigned char*)addr, (unsigned char)long_val); if ((long_val > UCHAR_MAX) || (long_val < 0)) WARN("Truncation of value to unsigned char"); break; @@ -200,7 +200,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; - FT_ATOMIC_STORE_SHORT_RELEASE(*(short*)addr, (short)long_val); + FT_ATOMIC_STORE_SHORT_RELAXED(*(short*)addr, (short)long_val); if ((long_val > SHRT_MAX) || (long_val < SHRT_MIN)) WARN("Truncation of value to short"); break; @@ -209,7 +209,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; - FT_ATOMIC_STORE_USHORT_RELEASE(*(unsigned short*)addr, (unsigned short)long_val); + FT_ATOMIC_STORE_USHORT_RELAXED(*(unsigned short*)addr, (unsigned short)long_val); if ((long_val > USHRT_MAX) || (long_val < 0)) WARN("Truncation of value to unsigned short"); break; @@ -218,7 +218,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; - FT_ATOMIC_STORE_INT_RELEASE(*(int *)addr, (int)long_val); + FT_ATOMIC_STORE_INT_RELAXED(*(int *)addr, (int)long_val); if ((long_val > INT_MAX) || (long_val < INT_MIN)) WARN("Truncation of value to int"); break; @@ -236,7 +236,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (long_val == -1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_UINT_RELEASE(*(unsigned int *)addr, (unsigned int)(unsigned long)long_val); + FT_ATOMIC_STORE_UINT_RELAXED(*(unsigned int *)addr, (unsigned int)(unsigned long)long_val); WARN("Writing negative value into unsigned field"); } else { @@ -245,7 +245,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (ulong_val == (unsigned long)-1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_UINT_RELEASE(*(unsigned int *)addr, (unsigned int)ulong_val); + FT_ATOMIC_STORE_UINT_RELAXED(*(unsigned int *)addr, (unsigned int)ulong_val); if (ulong_val > UINT_MAX) { WARN("Truncation of value to unsigned int"); } @@ -253,7 +253,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) break; } case Py_T_LONG:{ - FT_ATOMIC_STORE_LONG_RELEASE(*(long*)addr, PyLong_AsLong(v)); + FT_ATOMIC_STORE_LONG_RELAXED(*(long*)addr, PyLong_AsLong(v)); if ((*(long*)addr == -1) && PyErr_Occurred()) return -1; break; @@ -271,7 +271,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (long_val == -1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_ULONG(*(unsigned long *)addr, (unsigned long)long_val); + FT_ATOMIC_STORE_ULONG_RELAXED(*(unsigned long *)addr, (unsigned long)long_val); WARN("Writing negative value into unsigned field"); } else { @@ -280,12 +280,12 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (ulong_val == (unsigned long)-1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_ULONG(*(unsigned long *)addr, ulong_val); + FT_ATOMIC_STORE_ULONG_RELAXED(*(unsigned long *)addr, ulong_val); } break; } case Py_T_PYSSIZET:{ - FT_ATOMIC_STORE_SSIZE_RELEASE(*(Py_ssize_t*)addr, PyLong_AsSsize_t(v)); + FT_ATOMIC_STORE_SSIZE_RELAXED(*(Py_ssize_t*)addr, PyLong_AsSsize_t(v)); if ((*(Py_ssize_t*)addr == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; @@ -295,11 +295,11 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) double double_val = PyFloat_AsDouble(v); if ((double_val == -1) && PyErr_Occurred()) return -1; - FT_ATOMIC_STORE_FLOAT_RELEASE(*(float*)addr, (float)double_val); + FT_ATOMIC_STORE_FLOAT_RELAXED(*(float*)addr, (float)double_val); break; } case Py_T_DOUBLE: - FT_ATOMIC_STORE_DOUBLE_RELEASE(*(double*)addr, PyFloat_AsDouble(v)); + FT_ATOMIC_STORE_DOUBLE_RELAXED(*(double*)addr, PyFloat_AsDouble(v)); if ((*(double*)addr == -1) && PyErr_Occurred()) return -1; break; @@ -329,7 +329,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) return -1; case Py_T_LONGLONG:{ long long value = PyLong_AsLongLong(v); - FT_ATOMIC_STORE_LLONG_RELEASE(*(long long*)addr, value); + FT_ATOMIC_STORE_LLONG_RELAXED(*(long long*)addr, value); if ((value == -1) && PyErr_Occurred()) return -1; break; @@ -345,7 +345,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (long_val == -1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_ULLONG_RELEASE(*(unsigned long long *)addr, (unsigned long long)(long long)long_val); + FT_ATOMIC_STORE_ULLONG_RELAXED(*(unsigned long long *)addr, (unsigned long long)(long long)long_val); WARN("Writing negative value into unsigned field"); } else { @@ -354,7 +354,7 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) if (ulonglong_val == (unsigned long long)-1 && PyErr_Occurred()) { return -1; } - FT_ATOMIC_STORE_ULLONG_RELEASE(*(unsigned long long *)addr, ulonglong_val); + FT_ATOMIC_STORE_ULLONG_RELAXED(*(unsigned long long *)addr, ulonglong_val); } break; }