mirror of
https://github.com/python/cpython.git
synced 2025-08-27 12:16:04 +00:00
gh-114940: Add _Py_FOR_EACH_TSTATE_UNLOCKED(), and Friends (gh-127077)
This is a precursor to the actual fix for gh-114940, where we will change these macros to use the new lock. This change is almost entirely mechanical; the exceptions are the loops in codeobject.c and ceval.c, which now hold the "head" lock. Note that almost all of the uses of _Py_FOR_EACH_TSTATE_UNLOCKED() here will change to _Py_FOR_EACH_TSTATE_BEGIN() once we add the new per-interpreter lock.
This commit is contained in:
parent
bf542f8bb9
commit
9dabace39d
9 changed files with 79 additions and 87 deletions
|
@ -2895,20 +2895,22 @@ get_indices_in_use(PyInterpreterState *interp, struct flag_set *in_use)
|
|||
assert(interp->stoptheworld.world_stopped);
|
||||
assert(in_use->flags == NULL);
|
||||
int32_t max_index = 0;
|
||||
for (PyThreadState *p = interp->threads.head; p != NULL; p = p->next) {
|
||||
_Py_FOR_EACH_TSTATE_BEGIN(interp, p) {
|
||||
int32_t idx = ((_PyThreadStateImpl *) p)->tlbc_index;
|
||||
if (idx > max_index) {
|
||||
max_index = idx;
|
||||
}
|
||||
}
|
||||
_Py_FOR_EACH_TSTATE_END(interp);
|
||||
in_use->size = (size_t) max_index + 1;
|
||||
in_use->flags = PyMem_Calloc(in_use->size, sizeof(*in_use->flags));
|
||||
if (in_use->flags == NULL) {
|
||||
return -1;
|
||||
}
|
||||
for (PyThreadState *p = interp->threads.head; p != NULL; p = p->next) {
|
||||
_Py_FOR_EACH_TSTATE_BEGIN(interp, p) {
|
||||
in_use->flags[((_PyThreadStateImpl *) p)->tlbc_index] = 1;
|
||||
}
|
||||
_Py_FOR_EACH_TSTATE_END(interp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue