Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6c6770d

Browse files
committed
Remove _PyRuntimeState_GetThreadState.
1 parent472fc84 commit6c6770d

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

‎Include/internal/pycore_pystate.h‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,6 @@ _Py_ThreadCanHandlePendingCalls(void)
328328
/* Variable and macro for in-line access to current thread
329329
and interpreter state */
330330

331-
staticinlinePyThreadState*_PyRuntimeState_GetThreadState(_PyRuntimeState*runtime) {
332-
return (PyThreadState*)_Py_atomic_load_relaxed(&runtime->gilstate.tstate_current);
333-
}
334-
335331
/* Get the current Python thread state.
336332
337333
Efficient macro reading directly the 'gilstate.tstate_current' atomic
@@ -341,7 +337,7 @@ static inline PyThreadState* _PyRuntimeState_GetThreadState(_PyRuntimeState *run
341337
The caller must hold the GIL.
342338
343339
See also PyThreadState_Get() and PyThreadState_GET(). */
344-
#define_PyThreadState_GET()_PyRuntimeState_GetThreadState(&_PyRuntime)
340+
#define_PyThreadState_GET()((PyThreadState*)_Py_atomic_load_relaxed(&_PyRuntime.gilstate.tstate_current))
345341

346342
/* Redefine PyThreadState_GET() as an alias to _PyThreadState_GET() */
347343
#undef PyThreadState_GET

‎Python/ceval.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,7 @@ _PyEval_Fini(void)
355355
void
356356
PyEval_AcquireLock(void)
357357
{
358-
_PyRuntimeState*runtime=&_PyRuntime;
359-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
358+
PyThreadState*tstate=_PyThreadState_GET();
360359
ensure_tstate_not_null(__func__,tstate);
361360

362361
take_gil(tstate);
@@ -366,7 +365,7 @@ void
366365
PyEval_ReleaseLock(void)
367366
{
368367
_PyRuntimeState*runtime=&_PyRuntime;
369-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
368+
PyThreadState*tstate=_PyThreadState_GET();
370369
/* This function must succeed when the current thread state is NULL.
371370
We therefore avoid PyThreadState_Get() which dumps a fatal error
372371
in debug mode. */
@@ -419,7 +418,7 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime)
419418
return;
420419
}
421420
recreate_gil(gil);
422-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
421+
PyThreadState*tstate=_PyThreadState_GET();
423422
ensure_tstate_not_null(__func__,tstate);
424423

425424
take_gil(tstate);

‎Python/pylifecycle.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,8 +1108,7 @@ _Py_InitializeMain(void)
11081108
if (_PyStatus_EXCEPTION(status)) {
11091109
returnstatus;
11101110
}
1111-
_PyRuntimeState*runtime=&_PyRuntime;
1112-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
1111+
PyThreadState*tstate=_PyThreadState_GET();
11131112
returnpyinit_main(tstate);
11141113
}
11151114

@@ -1337,7 +1336,7 @@ Py_FinalizeEx(void)
13371336
}
13381337

13391338
/* Get current thread state and interpreter pointer */
1340-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
1339+
PyThreadState*tstate=_PyThreadState_GET();
13411340
PyInterpreterState*interp=tstate->interp;
13421341

13431342
// Wrap up existing "threading"-module-created, non-daemon threads.
@@ -2207,7 +2206,7 @@ fatal_error(const char *prefix, const char *msg, int status)
22072206
_PyRuntimeState*runtime=&_PyRuntime;
22082207
fatal_error_dump_runtime(stream,runtime);
22092208

2210-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
2209+
PyThreadState*tstate=_PyThreadState_GET();
22112210
PyInterpreterState*interp=NULL;
22122211
if (tstate!=NULL) {
22132212
interp=tstate->interp;

‎Python/pystate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ int
10131013
PyThreadState_SetAsyncExc(unsigned longid,PyObject*exc)
10141014
{
10151015
_PyRuntimeState*runtime=&_PyRuntime;
1016-
PyInterpreterState*interp=_PyRuntimeState_GetThreadState(runtime)->interp;
1016+
PyInterpreterState*interp=_PyThreadState_GET()->interp;
10171017

10181018
/* Although the GIL is held, a few C API functions can be called
10191019
* without the GIL held, and in particular some that create and

‎Python/sysmodule.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ _PySys_ClearAuditHooks(void)
288288
{
289289
/* Must be finalizing to clear hooks */
290290
_PyRuntimeState*runtime=&_PyRuntime;
291-
PyThreadState*ts=_PyRuntimeState_GetThreadState(runtime);
291+
PyThreadState*ts=_PyThreadState_GET();
292292
PyThreadState*finalizing=_PyRuntimeState_GetFinalizing(runtime);
293293
assert(!ts||finalizing==ts);
294294
if (!ts||finalizing!=ts) {
@@ -318,7 +318,7 @@ int
318318
PySys_AddAuditHook(Py_AuditHookFunctionhook,void*userData)
319319
{
320320
_PyRuntimeState*runtime=&_PyRuntime;
321-
PyThreadState*tstate=_PyRuntimeState_GetThreadState(runtime);
321+
PyThreadState*tstate=_PyThreadState_GET();
322322

323323
/* Invoke existing audit hooks to allow them an opportunity to abort. */
324324
/* Cannot invoke hooks until we are initialized */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp