summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-06-20 16:00:25 (GMT)
committerGitHub <noreply@github.com>2024-06-20 16:00:25 (GMT)
commit3cb6c4cd60bec1acbcd960f5e7bd65f78152dbdd (patch)
treef5b72124507a3c8ea7e5938bdb2cdb7563ca1ac1 /Modules
parent7c7aa5a99cce256ff726654038092a333a1f0531 (diff)
downloadcpython-3cb6c4cd60bec1acbcd960f5e7bd65f78152dbdd.zip
cpython-3cb6c4cd60bec1acbcd960f5e7bd65f78152dbdd.tar.gz
cpython-3cb6c4cd60bec1acbcd960f5e7bd65f78152dbdd.tar.bz2
[3.13] gh-117511: Make PyMutex public in the non-limited API (GH-117731) (#120800)
(cherry picked from commit 3af7263037de1d0ef63b070fc7bfc2cf042eaebe)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi/test_lock.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_testinternalcapi/test_lock.c b/Modules/_testinternalcapi/test_lock.c
index 1544fe1..8d67841 100644
--- a/Modules/_testinternalcapi/test_lock.c
+++ b/Modules/_testinternalcapi/test_lock.c
@@ -36,9 +36,9 @@ test_lock_basic(PyObject *self, PyObject *obj)
// uncontended lock and unlock
PyMutex_Lock(&m);
- assert(m.v == 1);
+ assert(m._bits == 1);
PyMutex_Unlock(&m);
- assert(m.v == 0);
+ assert(m._bits == 0);
Py_RETURN_NONE;
}
@@ -57,10 +57,10 @@ lock_thread(void *arg)
_Py_atomic_store_int(&test_data->started, 1);
PyMutex_Lock(m);
- assert(m->v == 1);
+ assert(m->_bits == 1);
PyMutex_Unlock(m);
- assert(m->v == 0);
+ assert(m->_bits == 0);
_PyEvent_Notify(&test_data->done);
}
@@ -73,7 +73,7 @@ test_lock_two_threads(PyObject *self, PyObject *obj)
memset(&test_data, 0, sizeof(test_data));
PyMutex_Lock(&test_data.m);
- assert(test_data.m.v == 1);
+ assert(test_data.m._bits == 1);
PyThread_start_new_thread(lock_thread, &test_data);
@@ -82,17 +82,17 @@ test_lock_two_threads(PyObject *self, PyObject *obj)
uint8_t v;
do {
pysleep(10); // allow some time for the other thread to try to lock
- v = _Py_atomic_load_uint8_relaxed(&test_data.m.v);
+ v = _Py_atomic_load_uint8_relaxed(&test_data.m._bits);
assert(v == 1 || v == 3);
iters++;
} while (v != 3 && iters < 200);
// both the "locked" and the "has parked" bits should be set
- assert(test_data.m.v == 3);
+ assert(test_data.m._bits == 3);
PyMutex_Unlock(&test_data.m);
PyEvent_Wait(&test_data.done);
- assert(test_data.m.v == 0);
+ assert(test_data.m._bits == 0);
Py_RETURN_NONE;
}