diff options
author | Sam Gross <colesbury@gmail.com> | 2023-11-09 23:37:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 23:37:11 (GMT) |
commit | 289af8612283508b67d7969d7182070381b4349b (patch) | |
tree | 55d8082aad0a83f47ec27e0f3d7aab629ca53dec /Include | |
parent | b9f814ce6fdc2fd636bb01e60c60f3ed708a245f (diff) | |
download | cpython-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 'Include')
-rw-r--r-- | Include/pyport.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/pyport.h b/Include/pyport.h index d30fcd7..abb526d 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -470,6 +470,14 @@ extern "C" { # 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 |