Skip to content

Commit 0848932

Browse files
gh-125161: return non zero value in pthread_self on wasi (#125303)
1 parent 022c50d commit 0848932

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Python/thread_pthread_stubs.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "cpython/pthread_stubs.h"
22

3+
typedef struct py_stub_tls_entry py_tls_entry;
4+
5+
#define py_tls_entries (_PyRuntime.threads.stubs.tls_entries)
6+
37
// mutex
48
int
59
pthread_mutex_init(pthread_mutex_t *restrict mutex,
@@ -105,7 +109,7 @@ pthread_join(pthread_t thread, void** value_ptr)
105109

106110
PyAPI_FUNC(pthread_t) pthread_self(void)
107111
{
108-
return 0;
112+
return (pthread_t)(uintptr_t)&py_tls_entries;
109113
}
110114

111115
int
@@ -134,10 +138,6 @@ pthread_attr_destroy(pthread_attr_t *attr)
134138
}
135139

136140

137-
typedef struct py_stub_tls_entry py_tls_entry;
138-
139-
#define py_tls_entries (_PyRuntime.threads.stubs.tls_entries)
140-
141141
int
142142
pthread_key_create(pthread_key_t *key, void (*destr_function)(void *))
143143
{

0 commit comments

Comments
 (0)