mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
gh-112069: Make PySet_GET_SIZE to be atomic safe. (gh-118053)
gh-112069: Make PySet_GET_SIZE to be atomic operation
This commit is contained in:
parent
8f25cc9920
commit
710c01be94
2 changed files with 4 additions and 1 deletions
|
|
@ -62,6 +62,10 @@ typedef struct {
|
|||
(assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))
|
||||
|
||||
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
|
||||
#ifdef Py_GIL_DISABLED
|
||||
return _Py_atomic_load_ssize_relaxed(&(_PySet_CAST(so)->used));
|
||||
#else
|
||||
return _PySet_CAST(so)->used;
|
||||
#endif
|
||||
}
|
||||
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue