diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-23 03:41:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-23 03:41:08 +0100 |
commit | 52a327c1cbb86c7f2f5c460645889b23615261bf (patch) | |
tree | df67ef901c5300349c073e8031c4d410ba016ca7 /Modules | |
parent | Fix typos in sysmodule (GH-23883) (diff) | |
download | cpython-52a327c1cbb86c7f2f5c460645889b23615261bf.tar.gz cpython-52a327c1cbb86c7f2f5c460645889b23615261bf.tar.bz2 cpython-52a327c1cbb86c7f2f5c460645889b23615261bf.zip |
bpo-39465: Add pycore_atomic_funcs.h header (GH-20766)
Add pycore_atomic_funcs.h internal header file: similar to
pycore_atomic.h but don't require to declare variables as atomic.
Add _Py_atomic_size_get() and _Py_atomic_size_set() functions.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testinternalcapi.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index df4725ea0a1..ab6c5965d16 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -12,6 +12,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" +#include "pycore_atomic_funcs.h" // _Py_atomic_int_get() #include "pycore_bitutils.h" // _Py_bswap32() #include "pycore_gc.h" // PyGC_Head #include "pycore_hashtable.h" // _Py_hashtable_new() @@ -267,6 +268,17 @@ error: } +static PyObject* +test_atomic_funcs(PyObject *self, PyObject *Py_UNUSED(args)) +{ + // Test _Py_atomic_size_get() and _Py_atomic_size_set() + Py_ssize_t var = 1; + _Py_atomic_size_set(&var, 2); + assert(_Py_atomic_size_get(&var) == 2); + Py_RETURN_NONE; +} + + static PyMethodDef TestMethods[] = { {"get_configs", get_configs, METH_NOARGS}, {"get_recursion_depth", get_recursion_depth, METH_NOARGS}, @@ -276,6 +288,7 @@ static PyMethodDef TestMethods[] = { {"test_hashtable", test_hashtable, METH_NOARGS}, {"get_config", test_get_config, METH_NOARGS}, {"set_config", test_set_config, METH_O}, + {"test_atomic_funcs", test_atomic_funcs, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |