A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/9204fb8623896cc5f68ae350784ee25e8a7b2184 below:

Cleanup pystate.c and pystate.h (GH-10240) · python/cpython@9204fb8 · GitHub

4 4

#include "Python.h"

5 5

#include "internal/pystate.h"

6 6 7 -

#define GET_TSTATE() \

8 -

((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))

9 -

#define SET_TSTATE(value) \

10 -

_Py_atomic_store_relaxed(&_PyThreadState_Current, (uintptr_t)(value))

11 -

#define GET_INTERP_STATE() \

12 -

(GET_TSTATE()->interp)

7 +

#define _PyThreadState_SET(value) \

8 +

_Py_atomic_store_relaxed(&_PyRuntime.gilstate.tstate_current, \

9 +

(uintptr_t)(value))

13 10 14 11 15 12

/* --------------------------------------------------------------------------

@@ -309,7 +306,7 @@ _PyInterpreterState_DeleteExceptMain()

309 306

PyInterpreterState *

310 307

_PyInterpreterState_Get(void)

311 308

{

312 -

PyThreadState *tstate = GET_TSTATE();

309 +

PyThreadState *tstate = PyThreadState_GET();

313 310

if (tstate == NULL) {

314 311

Py_FatalError("_PyInterpreterState_Get(): no current thread state");

315 312

}

@@ -508,7 +505,7 @@ PyObject*

508 505

PyState_FindModule(struct PyModuleDef* module)

509 506

{

510 507

Py_ssize_t index = module->m_base.m_index;

511 -

PyInterpreterState *state = GET_INTERP_STATE();

508 +

PyInterpreterState *state = _PyInterpreterState_GET_UNSAFE();

512 509

PyObject *res;

513 510

if (module->m_slots) {

514 511

return NULL;

@@ -536,7 +533,7 @@ _PyState_AddModule(PyObject* module, struct PyModuleDef* def)

536 533

"PyState_AddModule called on module with slots");

537 534

return -1;

538 535

}

539 -

state = GET_INTERP_STATE();

536 +

state = _PyInterpreterState_GET_UNSAFE();

540 537

if (!state->modules_by_index) {

541 538

state->modules_by_index = PyList_New(0);

542 539

if (!state->modules_by_index)

554 551

PyState_AddModule(PyObject* module, struct PyModuleDef* def)

555 552

{

556 553

Py_ssize_t index;

557 -

PyInterpreterState *state = GET_INTERP_STATE();

554 +

PyInterpreterState *state = _PyInterpreterState_GET_UNSAFE();

558 555

if (!def) {

559 556

Py_FatalError("PyState_AddModule: Module Definition is NULL");

560 557

return -1;

@@ -581,7 +578,7 @@ PyState_RemoveModule(struct PyModuleDef* def)

581 578

"PyState_RemoveModule called on module with slots");

582 579

return -1;

583 580

}

584 -

state = GET_INTERP_STATE();

581 +

state = _PyInterpreterState_GET_UNSAFE();

585 582

if (index == 0) {

586 583

Py_FatalError("PyState_RemoveModule: Module index invalid.");

587 584

return -1;

@@ -601,7 +598,7 @@ PyState_RemoveModule(struct PyModuleDef* def)

601 598

void

602 599

_PyState_ClearModules(void)

603 600

{

604 -

PyInterpreterState *state = GET_INTERP_STATE();

601 +

PyInterpreterState *state = _PyInterpreterState_GET_UNSAFE();

605 602

if (state->modules_by_index) {

606 603

Py_ssize_t i;

607 604

for (i = 0; i < PyList_GET_SIZE(state->modules_by_index); i++) {

@@ -691,7 +688,7 @@ tstate_delete_common(PyThreadState *tstate)

691 688

void

692 689

PyThreadState_Delete(PyThreadState *tstate)

693 690

{

694 -

if (tstate == GET_TSTATE())

691 +

if (tstate == PyThreadState_GET())

695 692

Py_FatalError("PyThreadState_Delete: tstate is still current");

696 693

if (_PyRuntime.gilstate.autoInterpreterState &&

697 694

PyThread_tss_get(&_PyRuntime.gilstate.autoTSSkey) == tstate)

@@ -705,7 +702,7 @@ PyThreadState_Delete(PyThreadState *tstate)

705 702

void

706 703

PyThreadState_DeleteCurrent()

707 704

{

708 -

PyThreadState *tstate = GET_TSTATE();

705 +

PyThreadState *tstate = PyThreadState_GET();

709 706

if (tstate == NULL)

710 707

Py_FatalError(

711 708

"PyThreadState_DeleteCurrent: no current tstate");

@@ -715,7 +712,7 @@ PyThreadState_DeleteCurrent()

715 712

{

716 713

PyThread_tss_set(&_PyRuntime.gilstate.autoTSSkey, NULL);

717 714

}

718 -

SET_TSTATE(NULL);

715 +

_PyThreadState_SET(NULL);

719 716

PyEval_ReleaseLock();

720 717

}

721 718

@@ -760,14 +757,14 @@ _PyThreadState_DeleteExcept(PyThreadState *tstate)

760 757

PyThreadState *

761 758

_PyThreadState_UncheckedGet(void)

762 759

{

763 -

return GET_TSTATE();

760 +

return PyThreadState_GET();

764 761

}

765 762 766 763 767 764

PyThreadState *

768 765

PyThreadState_Get(void)

769 766

{

770 -

PyThreadState *tstate = GET_TSTATE();

767 +

PyThreadState *tstate = PyThreadState_GET();

771 768

if (tstate == NULL)

772 769

Py_FatalError("PyThreadState_Get: no current thread");

773 770

@@ -778,9 +775,9 @@ PyThreadState_Get(void)

778 775

PyThreadState *

779 776

PyThreadState_Swap(PyThreadState *newts)

780 777

{

781 -

PyThreadState *oldts = GET_TSTATE();

778 +

PyThreadState *oldts = PyThreadState_GET();

782 779 783 -

SET_TSTATE(newts);

780 +

_PyThreadState_SET(newts);

784 781

/* It should not be possible for more than one thread state

785 782

to be used for a thread. Check this the best we can in debug

786 783

builds.

@@ -809,7 +806,7 @@ PyThreadState_Swap(PyThreadState *newts)

809 806

PyObject *

810 807

PyThreadState_GetDict(void)

811 808

{

812 -

PyThreadState *tstate = GET_TSTATE();

809 +

PyThreadState *tstate = PyThreadState_GET();

813 810

if (tstate == NULL)

814 811

return NULL;

815 812

@@ -834,7 +831,7 @@ PyThreadState_GetDict(void)

834 831

int

835 832

PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)

836 833

{

837 -

PyInterpreterState *interp = GET_INTERP_STATE();

834 +

PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();

838 835

PyThreadState *p;

839 836 840 837

/* Although the GIL is held, a few C API functions can be called

@@ -960,7 +957,7 @@ PyThreadState_IsCurrent(PyThreadState *tstate)

960 957

{

961 958

/* Must be the tstate for this thread */

962 959

assert(PyGILState_GetThisThreadState()==tstate);

963 -

return tstate == GET_TSTATE();

960 +

return tstate == PyThreadState_GET();

964 961

}

965 962 966 963

/* Internal initialization/finalization functions called by

@@ -1087,7 +1084,7 @@ PyGILState_Check(void)

1087 1084

return 1;

1088 1085

}

1089 1086 1090 -

tstate = GET_TSTATE();

1087 +

tstate = PyThreadState_GET();

1091 1088

if (tstate == NULL)

1092 1089

return 0;

1093 1090

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4