@@ -164,34 +164,34 @@ tstate_tss_reinit(Py_tss_t *key)
164
164
The GIL does no need to be held for these.
165
165
*/
166
166
167
- #define current_tss_initialized (runtime ) \
167
+ #define gilstate_tss_initialized (runtime ) \
168
168
tstate_tss_initialized(&(runtime)->autoTSSkey)
169
- #define current_tss_init (runtime ) \
169
+ #define gilstate_tss_init (runtime ) \
170
170
tstate_tss_init(&(runtime)->autoTSSkey)
171
- #define current_tss_fini (runtime ) \
171
+ #define gilstate_tss_fini (runtime ) \
172
172
tstate_tss_fini(&(runtime)->autoTSSkey)
173
- #define current_tss_get (runtime ) \
173
+ #define gilstate_tss_get (runtime ) \
174
174
tstate_tss_get(&(runtime)->autoTSSkey)
175
- #define _current_tss_set (runtime , tstate ) \
175
+ #define _gilstate_tss_set (runtime , tstate ) \
176
176
tstate_tss_set(&(runtime)->autoTSSkey, tstate)
177
- #define _current_tss_clear (runtime ) \
177
+ #define _gilstate_tss_clear (runtime ) \
178
178
tstate_tss_clear(&(runtime)->autoTSSkey)
179
- #define current_tss_reinit (runtime ) \
179
+ #define gilstate_tss_reinit (runtime ) \
180
180
tstate_tss_reinit(&(runtime)->autoTSSkey)
181
181
182
182
static inline void
183
- current_tss_set (_PyRuntimeState * runtime , PyThreadState * tstate )
183
+ gilstate_tss_set (_PyRuntimeState * runtime , PyThreadState * tstate )
184
184
{
185
185
assert (tstate != NULL && tstate -> interp -> runtime == runtime );
186
- if (_current_tss_set (runtime , tstate ) != 0 ) {
186
+ if (_gilstate_tss_set (runtime , tstate ) != 0 ) {
187
187
Py_FatalError ("failed to set current tstate (TSS)" );
188
188
}
189
189
}
190
190
191
191
static inline void
192
- current_tss_clear (_PyRuntimeState * runtime )
192
+ gilstate_tss_clear (_PyRuntimeState * runtime )
193
193
{
194
- if (_current_tss_clear (runtime ) != 0 ) {
194
+ if (_gilstate_tss_clear (runtime ) != 0 ) {
195
195
Py_FatalError ("failed to clear current tstate (TSS)" );
196
196
}
197
197
}
@@ -235,8 +235,8 @@ bind_tstate(PyThreadState *tstate)
235
235
(This is a better fix for SF bug #1010677 than the first one attempted.)
236
236
*/
237
237
// XXX Skipping like this does not play nice with multiple interpreters.
238
- if (current_tss_get (runtime ) == NULL ) {
239
- current_tss_set (runtime , tstate );
238
+ if (gilstate_tss_get (runtime ) == NULL ) {
239
+ gilstate_tss_set (runtime , tstate );
240
240
}
241
241
242
242
tstate -> thread_id = PyThread_get_thread_ident ();
@@ -260,10 +260,10 @@ unbind_tstate(PyThreadState *tstate)
260
260
#endif
261
261
_PyRuntimeState * runtime = tstate -> interp -> runtime ;
262
262
263
- if (current_tss_initialized (runtime ) &&
264
- tstate == current_tss_get (runtime ))
263
+ if (gilstate_tss_initialized (runtime ) &&
264
+ tstate == gilstate_tss_get (runtime ))
265
265
{
266
- current_tss_clear (runtime );
266
+ gilstate_tss_clear (runtime );
267
267
}
268
268
269
269
// We leave thread_id and native_thraed_id alone
@@ -297,7 +297,7 @@ holds_gil(PyThreadState *tstate)
297
297
assert (tstate != NULL );
298
298
_PyRuntimeState * runtime = tstate -> interp -> runtime ;
299
299
/* Must be the tstate for this thread */
300
- assert (tstate == current_tss_get (runtime ));
300
+ assert (tstate == gilstate_tss_get (runtime ));
301
301
return tstate == current_fast_get (runtime );
302
302
}
303
303
@@ -430,7 +430,7 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
430
430
memcpy (runtime , & initial , sizeof (* runtime ));
431
431
}
432
432
433
- if (current_tss_init (runtime ) != 0 ) {
433
+ if (gilstate_tss_init (runtime ) != 0 ) {
434
434
_PyRuntimeState_Fini (runtime );
435
435
return _PyStatus_NO_MEMORY ();
436
436
}
@@ -449,8 +449,8 @@ _PyRuntimeState_Init(_PyRuntimeState *runtime)
449
449
void
450
450
_PyRuntimeState_Fini (_PyRuntimeState * runtime )
451
451
{
452
- if (current_tss_initialized (runtime )) {
453
- current_tss_fini (runtime );
452
+ if (gilstate_tss_initialized (runtime )) {
453
+ gilstate_tss_fini (runtime );
454
454
}
455
455
456
456
if (PyThread_tss_is_created (& runtime -> trashTSSkey )) {
@@ -510,7 +510,7 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
510
510
511
511
}
512
512
513
- PyStatus status = current_tss_reinit (runtime );
513
+ PyStatus status = gilstate_tss_reinit (runtime );
514
514
if (_PyStatus_EXCEPTION (status )) {
515
515
return status ;
516
516
}
@@ -1671,12 +1671,12 @@ _PyThreadState_Swap(_PyRuntimeState *runtime, PyThreadState *newts)
1671
1671
*/
1672
1672
// XXX The above isn't true when multiple interpreters are involved.
1673
1673
#if defined(Py_DEBUG )
1674
- if (newts && current_tss_initialized (runtime )) {
1674
+ if (newts && gilstate_tss_initialized (runtime )) {
1675
1675
/* This can be called from PyEval_RestoreThread(). Similar
1676
1676
to it, we need to ensure errno doesn't change.
1677
1677
*/
1678
1678
int err = errno ;
1679
- PyThreadState * check = current_tss_get (runtime );
1679
+ PyThreadState * check = gilstate_tss_get (runtime );
1680
1680
if (check && check -> interp == newts -> interp && check != newts ) {
1681
1681
Py_FatalError ("Invalid thread state for this thread" );
1682
1682
}
@@ -1985,7 +1985,7 @@ _PyGILState_Init(PyInterpreterState *interp)
1985
1985
return _PyStatus_OK ();
1986
1986
}
1987
1987
_PyRuntimeState * runtime = interp -> runtime ;
1988
- assert (current_tss_get (runtime ) == NULL );
1988
+ assert (gilstate_tss_get (runtime ) == NULL );
1989
1989
assert (runtime -> gilstate .autoInterpreterState == NULL );
1990
1990
runtime -> gilstate .autoInterpreterState = interp ;
1991
1991
return _PyStatus_OK ();
@@ -2021,7 +2021,7 @@ _PyGILState_SetTstate(PyThreadState *tstate)
2021
2021
_PyRuntimeState * runtime = tstate -> interp -> runtime ;
2022
2022
2023
2023
assert (runtime -> gilstate .autoInterpreterState == tstate -> interp );
2024
- assert (current_tss_get (runtime ) == tstate );
2024
+ assert (gilstate_tss_get (runtime ) == tstate );
2025
2025
assert (tstate -> gilstate_counter == 1 );
2026
2026
#endif
2027
2027
@@ -2040,10 +2040,10 @@ PyThreadState *
2040
2040
PyGILState_GetThisThreadState (void )
2041
2041
{
2042
2042
_PyRuntimeState * runtime = & _PyRuntime ;
2043
- if (!current_tss_initialized (runtime )) {
2043
+ if (!gilstate_tss_initialized (runtime )) {
2044
2044
return NULL ;
2045
2045
}
2046
- return current_tss_get (runtime );
2046
+ return gilstate_tss_get (runtime );
2047
2047
}
2048
2048
2049
2049
int
@@ -2054,7 +2054,7 @@ PyGILState_Check(void)
2054
2054
return 1 ;
2055
2055
}
2056
2056
2057
- if (!current_tss_initialized (runtime )) {
2057
+ if (!gilstate_tss_initialized (runtime )) {
2058
2058
return 1 ;
2059
2059
}
2060
2060
@@ -2063,7 +2063,7 @@ PyGILState_Check(void)
2063
2063
return 0 ;
2064
2064
}
2065
2065
2066
- return (tstate == current_tss_get (runtime ));
2066
+ return (tstate == gilstate_tss_get (runtime ));
2067
2067
}
2068
2068
2069
2069
PyGILState_STATE
@@ -2079,10 +2079,10 @@ PyGILState_Ensure(void)
2079
2079
/* Ensure that _PyEval_InitThreads() and _PyGILState_Init() have been
2080
2080
called by Py_Initialize() */
2081
2081
assert (_PyEval_ThreadsInitialized (runtime ));
2082
- assert (current_tss_initialized (runtime ));
2082
+ assert (gilstate_tss_initialized (runtime ));
2083
2083
assert (runtime -> gilstate .autoInterpreterState != NULL );
2084
2084
2085
- PyThreadState * tcur = current_tss_get (runtime );
2085
+ PyThreadState * tcur = gilstate_tss_get (runtime );
2086
2086
int has_gil ;
2087
2087
if (tcur == NULL ) {
2088
2088
/* Create a new Python thread state for this thread */
@@ -2120,7 +2120,7 @@ void
2120
2120
PyGILState_Release (PyGILState_STATE oldstate )
2121
2121
{
2122
2122
_PyRuntimeState * runtime = & _PyRuntime ;
2123
- PyThreadState * tstate = current_tss_get (runtime );
2123
+ PyThreadState * tstate = gilstate_tss_get (runtime );
2124
2124
if (tstate == NULL ) {
2125
2125
Py_FatalError ("auto-releasing thread-state, "
2126
2126
"but no thread-state for this thread" );
0 commit comments