mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)
This commit is contained in:
parent
06f844eaa0
commit
86559ddfec
8 changed files with 86 additions and 18 deletions
|
@ -140,6 +140,21 @@ test_atomic_release_acquire(PyObject *self, PyObject *obj) {
|
|||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
test_atomic_load_store_int_release_acquire(PyObject *self, PyObject *obj) { \
|
||||
int x = 0;
|
||||
int y = 1;
|
||||
int z = 2;
|
||||
assert(_Py_atomic_load_int_acquire(&x) == 0);
|
||||
_Py_atomic_store_int_release(&x, y);
|
||||
assert(x == y);
|
||||
assert(_Py_atomic_load_int_acquire(&x) == y);
|
||||
_Py_atomic_store_int_release(&x, z);
|
||||
assert(x == z);
|
||||
assert(_Py_atomic_load_int_acquire(&x) == z);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
// NOTE: all tests should start with "test_atomic_" to be included
|
||||
// in test_pyatomic.py
|
||||
|
||||
|
@ -162,6 +177,7 @@ static PyMethodDef test_methods[] = {
|
|||
FOR_BITWISE_TYPES(BIND_TEST_AND_OR)
|
||||
{"test_atomic_fences", test_atomic_fences, METH_NOARGS},
|
||||
{"test_atomic_release_acquire", test_atomic_release_acquire, METH_NOARGS},
|
||||
{"test_atomic_load_store_int_release_acquire", test_atomic_load_store_int_release_acquire, METH_NOARGS},
|
||||
{NULL, NULL} /* sentinel */
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue