From aabf2fed432d2bdc93a8a3f4a51a401085b7c828 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Fri, 11 Oct 2024 13:18:29 +0530 Subject: [PATCH 1/2] fix pthread_self on wasi --- Python/thread_pthread_stubs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/thread_pthread_stubs.h b/Python/thread_pthread_stubs.h index 4741e594e52e65..9bd04d84b3a97c 100644 --- a/Python/thread_pthread_stubs.h +++ b/Python/thread_pthread_stubs.h @@ -105,7 +105,7 @@ pthread_join(pthread_t thread, void** value_ptr) PyAPI_FUNC(pthread_t) pthread_self(void) { - return 0; + return (pthread_t)(uintptr_t)&py_tls_entries; } int From af039b141117de6fae4956e25bbab136bd4a6982 Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Fri, 11 Oct 2024 13:35:37 +0530 Subject: [PATCH 2/2] move initialization --- Python/thread_pthread_stubs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Python/thread_pthread_stubs.h b/Python/thread_pthread_stubs.h index 9bd04d84b3a97c..458f8fc5951720 100644 --- a/Python/thread_pthread_stubs.h +++ b/Python/thread_pthread_stubs.h @@ -1,5 +1,9 @@ #include "cpython/pthread_stubs.h" +typedef struct py_stub_tls_entry py_tls_entry; + +#define py_tls_entries (_PyRuntime.threads.stubs.tls_entries) + // mutex int pthread_mutex_init(pthread_mutex_t *restrict mutex, @@ -134,10 +138,6 @@ pthread_attr_destroy(pthread_attr_t *attr) } -typedef struct py_stub_tls_entry py_tls_entry; - -#define py_tls_entries (_PyRuntime.threads.stubs.tls_entries) - int pthread_key_create(pthread_key_t *key, void (*destr_function)(void *)) {