diff options
author | Donghee Na <donghee.na@python.org> | 2023-10-16 22:32:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 22:32:50 (GMT) |
commit | 86559ddfecefdda265d39e5e5035f72986becd78 (patch) | |
tree | f6c5ce93297f9736a887fed9137498570be321f6 /Modules/_testcapi | |
parent | 06f844eaa0a09b8524ade5734b4f2cc742a0a5c7 (diff) | |
download | cpython-86559ddfecefdda265d39e5e5035f72986becd78.zip cpython-86559ddfecefdda265d39e5e5035f72986becd78.tar.gz cpython-86559ddfecefdda265d39e5e5035f72986becd78.tar.bz2 |
gh-109693: Update _gil_runtime_state.locked to use pyatomic.h (gh-110836)
Diffstat (limited to 'Modules/_testcapi')
-rw-r--r-- | Modules/_testcapi/pyatomic.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testcapi/pyatomic.c b/Modules/_testcapi/pyatomic.c index 5aedf68..4f72844 100644 --- a/Modules/_testcapi/pyatomic.c +++ b/Modules/_testcapi/pyatomic.c @@ -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 */ }; |