Skip to content

Commit ebf9938

Browse files
pythongh-140544: cleanup HAVE_THREAD_LOCAL checks in pystate.c (python#140547)
1 parent 289360a commit ebf9938

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

Python/pystate.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,48 +67,34 @@ to avoid the expense of doing their own locking).
6767
For each of these functions, the GIL must be held by the current thread.
6868
*/
6969

70+
#ifndef HAVE_THREAD_LOCAL
71+
# error "no supported thread-local variable storage classifier"
72+
#endif
7073

71-
#ifdef HAVE_THREAD_LOCAL
7274
/* The attached thread state for the current thread. */
7375
_Py_thread_local PyThreadState *_Py_tss_tstate = NULL;
7476

7577
/* The "bound" thread state used by PyGILState_Ensure(),
7678
also known as a "gilstate." */
7779
_Py_thread_local PyThreadState *_Py_tss_gilstate = NULL;
78-
#endif
7980

8081
static inline PyThreadState *
8182
current_fast_get(void)
8283
{
83-
#ifdef HAVE_THREAD_LOCAL
8484
return _Py_tss_tstate;
85-
#else
86-
// XXX Fall back to the PyThread_tss_*() API.
87-
# error "no supported thread-local variable storage classifier"
88-
#endif
8985
}
9086

9187
static inline void
9288
current_fast_set(_PyRuntimeState *Py_UNUSED(runtime), PyThreadState *tstate)
9389
{
9490
assert(tstate != NULL);
95-
#ifdef HAVE_THREAD_LOCAL
9691
_Py_tss_tstate = tstate;
97-
#else
98-
// XXX Fall back to the PyThread_tss_*() API.
99-
# error "no supported thread-local variable storage classifier"
100-
#endif
10192
}
10293

10394
static inline void
10495
current_fast_clear(_PyRuntimeState *Py_UNUSED(runtime))
10596
{
106-
#ifdef HAVE_THREAD_LOCAL
10797
_Py_tss_tstate = NULL;
108-
#else
109-
// XXX Fall back to the PyThread_tss_*() API.
110-
# error "no supported thread-local variable storage classifier"
111-
#endif
11298
}
11399

114100
#define tstate_verify_not_active(tstate) \
@@ -2494,14 +2480,10 @@ _PyThreadState_Bind(PyThreadState *tstate)
24942480
uintptr_t
24952481
_Py_GetThreadLocal_Addr(void)
24962482
{
2497-
#ifdef HAVE_THREAD_LOCAL
24982483
// gh-112535: Use the address of the thread-local PyThreadState variable as
24992484
// a unique identifier for the current thread. Each thread has a unique
25002485
// _Py_tss_tstate variable with a unique address.
25012486
return (uintptr_t)&_Py_tss_tstate;
2502-
#else
2503-
# error "no supported thread-local variable storage classifier"
2504-
#endif
25052487
}
25062488
#endif
25072489

0 commit comments

Comments
 (0)