summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2023-11-09 23:37:11 (GMT)
committerGitHub <noreply@github.com>2023-11-09 23:37:11 (GMT)
commit289af8612283508b67d7969d7182070381b4349b (patch)
tree55d8082aad0a83f47ec27e0f3d7aab629ca53dec /Modules
parentb9f814ce6fdc2fd636bb01e60c60f3ed708a245f (diff)
downloadcpython-289af8612283508b67d7969d7182070381b4349b.zip
cpython-289af8612283508b67d7969d7182070381b4349b.tar.gz
cpython-289af8612283508b67d7969d7182070381b4349b.tar.bz2
gh-111569: Fix critical sections test on WebAssembly (GH-111897)
This adds a macro `Py_CAN_START_THREADS` that corresponds to the Python function `test.support.threading_helper.can_start_thread()`. WASI and some Emscripten builds do not have a working pthread implementation. This macro is used to guard the critical sections C API tests that require a working threads implementation.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_testinternalcapi/test_critical_sections.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi/test_critical_sections.c b/Modules/_testinternalcapi/test_critical_sections.c
index 238f29c..9392096 100644
--- a/Modules/_testinternalcapi/test_critical_sections.c
+++ b/Modules/_testinternalcapi/test_critical_sections.c
@@ -170,6 +170,7 @@ thread_critical_sections(void *arg)
}
}
+#ifdef Py_CAN_START_THREADS
static PyObject *
test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args))
{
@@ -194,12 +195,15 @@ test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args))
Py_DECREF(test_data.obj1);
Py_RETURN_NONE;
}
+#endif
static PyMethodDef test_methods[] = {
{"test_critical_sections", test_critical_sections, METH_NOARGS},
{"test_critical_sections_nest", test_critical_sections_nest, METH_NOARGS},
{"test_critical_sections_suspend", test_critical_sections_suspend, METH_NOARGS},
+#ifdef Py_CAN_START_THREADS
{"test_critical_sections_threads", test_critical_sections_threads, METH_NOARGS},
+#endif
{NULL, NULL} /* sentinel */
};