Skip to content

Commit c474d54

Browse files
Move py_tls_entries to _PyRuntimeState.
1 parent e412a4d commit c474d54

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Include/internal/pycore_pythread.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,17 @@ extern "C" {
4646
#endif
4747

4848

49+
#if defined(HAVE_PTHREAD_STUBS)
50+
// pthread_key
51+
struct py_stub_tls_entry {
52+
bool in_use;
53+
void *value;
54+
};
55+
#endif
56+
4957
struct _pythread_runtime_state {
5058
int initialized;
59+
5160
#ifdef _USE_PTHREADS
5261
// This matches when thread_pthread.h is used.
5362
struct {
@@ -60,6 +69,12 @@ struct _pythread_runtime_state {
6069
} _condattr_monotonic;
6170

6271
#endif // USE_PTHREADS
72+
73+
#if defined(HAVE_PTHREAD_STUBS)
74+
struct {
75+
struct py_stub_tls_entry tls_entries[PTHREAD_KEYS_MAX];
76+
} stub;
77+
#endif
6378
};
6479

6580

Python/thread_pthread_stubs.h

Lines changed: 3 additions & 6 deletions
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ Python/perf_trampoline.c - perf_status -
317317
Python/perf_trampoline.c - extra_code_index -
318318
Python/perf_trampoline.c - code_arena -
319319
Python/perf_trampoline.c - trampoline_api -
320-
Python/thread_pthread_stubs.h - py_tls_entries -
321320

322321

323322
##################################

0 commit comments

Comments
 (0)