Skip to content

Commit f2399f9

Browse files
Move py_tls_entries to _PyRuntimeState.
1 parent cd70c96 commit f2399f9

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Include/internal/pycore_pythread.h

+13
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@ extern "C" {
99
#endif
1010

1111

12+
#if defined(HAVE_PTHREAD_STUBS)
13+
// pthread_key
14+
struct py_stub_tls_entry {
15+
bool in_use;
16+
void *value;
17+
};
18+
#endif
19+
1220
struct _pythread_runtime_state {
1321
int initialized;
22+
#if defined(HAVE_PTHREAD_STUBS)
23+
struct {
24+
struct py_stub_tls_entry tls_entries[PTHREAD_KEYS_MAX];
25+
} stub;
26+
#endif
1427
};
1528

1629

Python/thread_pthread_stubs.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,10 @@ pthread_attr_destroy(pthread_attr_t *attr)
124124
return 0;
125125
}
126126

127-
// pthread_key
128-
typedef struct {
129-
bool in_use;
130-
void *value;
131-
} py_tls_entry;
132127

133-
static py_tls_entry py_tls_entries[PTHREAD_KEYS_MAX] = {0};
128+
typedef struct py_stub_tls_entry py_tls_entry;
129+
130+
#define py_tls_entries (_PyRuntime.threads.stub.tls_entries)
134131

135132
int
136133
pthread_key_create(pthread_key_t *key, void (*destr_function)(void *))

Tools/c-analyzer/cpython/globals-to-fix.tsv

-1
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ Python/perf_trampoline.c - perf_status -
325325
Python/perf_trampoline.c - extra_code_index -
326326
Python/perf_trampoline.c - code_arena -
327327
Python/perf_trampoline.c - trampoline_api -
328-
Python/thread_pthread_stubs.h - py_tls_entries -
329328

330329

331330
##################################

0 commit comments

Comments
 (0)