# define WITH_THREAD
#endif
+/* Some WebAssembly platforms do not provide a working pthread implementation.
+ * Thread support is stubbed and any attempt to create a new thread fails.
+ */
+#if (!defined(HAVE_PTHREAD_STUBS) && \
+ (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)))
+# define Py_CAN_START_THREADS 1
+#endif
+
#ifdef WITH_THREAD
# ifdef Py_BUILD_CORE
# ifdef HAVE_THREAD_LOCAL
}
}
+#ifdef Py_CAN_START_THREADS
static PyObject *
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 */
};