mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-109693: Remove pycore_atomic_funcs.h (#109694)
_PyUnicode_FromId() now uses pyatomic.h functions instead.
This commit is contained in:
parent
5b8f024683
commit
2aceb21ae6
6 changed files with 3 additions and 116 deletions
|
@ -40,7 +40,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include "Python.h"
|
||||
#include "pycore_abstract.h" // _PyIndex_Check()
|
||||
#include "pycore_atomic_funcs.h" // _Py_atomic_size_get()
|
||||
#include "pycore_bytes_methods.h" // _Py_bytes_lower()
|
||||
#include "pycore_bytesobject.h" // _PyBytes_Repeat()
|
||||
#include "pycore_ceval.h" // _PyEval_GetBuiltin()
|
||||
|
@ -1906,19 +1905,19 @@ _PyUnicode_FromId(_Py_Identifier *id)
|
|||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
struct _Py_unicode_ids *ids = &interp->unicode.ids;
|
||||
|
||||
Py_ssize_t index = _Py_atomic_size_get(&id->index);
|
||||
Py_ssize_t index = _Py_atomic_load_ssize(&id->index);
|
||||
if (index < 0) {
|
||||
struct _Py_unicode_runtime_ids *rt_ids = &interp->runtime->unicode_state.ids;
|
||||
|
||||
PyThread_acquire_lock(rt_ids->lock, WAIT_LOCK);
|
||||
// Check again to detect concurrent access. Another thread can have
|
||||
// initialized the index while this thread waited for the lock.
|
||||
index = _Py_atomic_size_get(&id->index);
|
||||
index = _Py_atomic_load_ssize(&id->index);
|
||||
if (index < 0) {
|
||||
assert(rt_ids->next_index < PY_SSIZE_T_MAX);
|
||||
index = rt_ids->next_index;
|
||||
rt_ids->next_index++;
|
||||
_Py_atomic_size_set(&id->index, index);
|
||||
_Py_atomic_store_ssize(&id->index, index);
|
||||
}
|
||||
PyThread_release_lock(rt_ids->lock);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue