Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitaef9180

Browse files
committed
gh-111569: Fix critical sections test on WebAssembly
This adds a macro `Py_CAN_START_THREADS` that corresponds to the Pythonfunction `test.support.threading_helper.can_start_thread()`. WASI andsome Emscripten builds do not have a working pthread implementation.This macro is used to guard the critical sections C API tests thatrequire a working threads implementation.
1 parent6f09f69 commitaef9180

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

‎Include/pyport.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,13 @@ extern "C" {
470470
#defineWITH_THREAD
471471
#endif
472472

473+
/* Some WebAssembly platforms do not provide a working pthread implementation.
474+
* Thread support is stubbed and any attempt to create a new thread fails.
475+
*/
476+
#if !defined(__wasi__) && (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__))
477+
#definePy_CAN_START_THREADS1
478+
#endif
479+
473480
#ifdef WITH_THREAD
474481
#ifdef Py_BUILD_CORE
475482
#ifdef HAVE_THREAD_LOCAL

‎Modules/_testinternalcapi/test_critical_sections.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ thread_critical_sections(void *arg)
170170
}
171171
}
172172

173+
#ifdefPy_CAN_START_THREADS
173174
staticPyObject*
174175
test_critical_sections_threads(PyObject*self,PyObject*Py_UNUSED(args))
175176
{
@@ -194,12 +195,15 @@ test_critical_sections_threads(PyObject *self, PyObject *Py_UNUSED(args))
194195
Py_DECREF(test_data.obj1);
195196
Py_RETURN_NONE;
196197
}
198+
#endif
197199

198200
staticPyMethodDeftest_methods[]= {
199201
{"test_critical_sections",test_critical_sections,METH_NOARGS},
200202
{"test_critical_sections_nest",test_critical_sections_nest,METH_NOARGS},
201203
{"test_critical_sections_suspend",test_critical_sections_suspend,METH_NOARGS},
204+
#ifdefPy_CAN_START_THREADS
202205
{"test_critical_sections_threads",test_critical_sections_threads,METH_NOARGS},
206+
#endif
203207
{NULL,NULL}/* sentinel */
204208
};
205209

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp