gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)

This commit is contained in:
Donghee Na 2023-10-17 07:32:50 +09:00 committed by GitHub
parent 06f844eaa0
commit 86559ddfec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 86 additions and 18 deletions

View file

@ -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 */
};