diff options
author | Kumar Aditya <kumaraditya@python.org> | 2024-12-18 15:19:00 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-18 15:19:00 (GMT) |
commit | 91c55085a959016250f1877e147ef379bb97dd12 (patch) | |
tree | 6fcdaae195ac3b2ebe8c91ac07c6f63352672bc9 /Include/internal | |
parent | 8a433b683fecafe1cb04469a301df2b4618167d0 (diff) | |
download | cpython-91c55085a959016250f1877e147ef379bb97dd12.zip cpython-91c55085a959016250f1877e147ef379bb97dd12.tar.gz cpython-91c55085a959016250f1877e147ef379bb97dd12.tar.bz2 |
gh-128033: change `PyMutex_LockFast` to take `PyMutex` as argument (#128054)
Change `PyMutex_LockFast` to take `PyMutex` as argument.
Diffstat (limited to 'Include/internal')
-rw-r--r-- | Include/internal/pycore_critical_section.h | 6 | ||||
-rw-r--r-- | Include/internal/pycore_lock.h | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/Include/internal/pycore_critical_section.h b/Include/internal/pycore_critical_section.h index 78cd0d5..9ba2fce 100644 --- a/Include/internal/pycore_critical_section.h +++ b/Include/internal/pycore_critical_section.h @@ -109,7 +109,7 @@ _PyCriticalSection_IsActive(uintptr_t tag) static inline void _PyCriticalSection_BeginMutex(PyCriticalSection *c, PyMutex *m) { - if (PyMutex_LockFast(&m->_bits)) { + if (PyMutex_LockFast(m)) { PyThreadState *tstate = _PyThreadState_GET(); c->_cs_mutex = m; c->_cs_prev = tstate->critical_section; @@ -170,8 +170,8 @@ _PyCriticalSection2_BeginMutex(PyCriticalSection2 *c, PyMutex *m1, PyMutex *m2) m2 = tmp; } - if (PyMutex_LockFast(&m1->_bits)) { - if (PyMutex_LockFast(&m2->_bits)) { + if (PyMutex_LockFast(m1)) { + if (PyMutex_LockFast(m2)) { PyThreadState *tstate = _PyThreadState_GET(); c->_cs_base._cs_mutex = m1; c->_cs_mutex2 = m2; diff --git a/Include/internal/pycore_lock.h b/Include/internal/pycore_lock.h index 57cbce8..8bcb23a 100644 --- a/Include/internal/pycore_lock.h +++ b/Include/internal/pycore_lock.h @@ -18,9 +18,10 @@ extern "C" { #define _Py_ONCE_INITIALIZED 4 static inline int -PyMutex_LockFast(uint8_t *lock_bits) +PyMutex_LockFast(PyMutex *m) { uint8_t expected = _Py_UNLOCKED; + uint8_t *lock_bits = &m->_bits; return _Py_atomic_compare_exchange_uint8(lock_bits, &expected, _Py_LOCKED); } |