[issue22038] Implement atomic operations on non-x86 platforms

STINNER Victor report at bugs.python.org
Thu Dec 18 00:53:27 CET 2014


STINNER Victor added the comment:

atomicv2.patch:
> _Atomic int _value;

Why not using the atomic_int type from stdatomic.h here?

> https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

"__atomic_store_n(): The valid memory model variants are __ATOMIC_RELAXED, __ATOMIC_SEQ_CST, and __ATOMIC_RELEASE."

I understand that _Py_atomic_store_explicit() only accept some values for order. An assertion should be added here, maybe for any implementation. Something like:

#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
    (assert((ORDER) == __ATOMIC_RELAXED                       \
            || (ORDER) == __ATOMIC_SEQ_CST                    \
            || (ORDER) == __ATOMIC_RELEASE),                  \
     __atomic_store_n(&(ATOMIC_VAL)->_value, NEW_VAL, ORDER))

Same remark for _Py_atomic_load_explicit():

"__atomic_load_n(): The valid memory model variants are __ATOMIC_RELAXED, __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE, and __ATOMIC_CONSUME."

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22038>
_______________________________________


More information about the Python-bugs-list mailing list