[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-35081: Add _PyThreadState_GET() internal macro #10266

Merged
merged 2 commits into from Nov 1, 2018
Merged

bpo-35081: Add _PyThreadState_GET() internal macro #10266

merged 2 commits into from Nov 1, 2018

Conversation

Copy link
Member

vstinner commented Oct 31, 2018

PyThreadState_GET() is a macro accessing
_PyRuntime.gilstate.tstate_current variable or calling
PyThreadState_Get() depending on Py_BUILD_CORE.

Add a new _PyThreadState_GET() internal macro which is always
the efficient macro accessing directly the variable. _PyThreadState_GET()
is not available if Py_BUILD_CORE is not defined.

Changes:

  • Add a new internal _PyThreadState_GET() macro
  • Replace "PyThreadState_GET()->interp" with
    _PyInterpreterState_GET_UNSAFE()
  • Replace PyThreadState_GET() with _PyThreadState_GET() in internal C
    files, but keep PyThreadState_GET() in the public API.
  • _testcapimodule.c: replace PyThreadState_GET() with
    PyThreadState_Get(), the module is not compiled with Py_BUILD_CORE
    defined.

https://bugs.python.org/issue35081

Copy link
Member Author

Travis CI failed on running doctests:

xvfb-run:
   error:
   Xvfb
   failed
   to
   start

If Py_BUILD_CORE is defined, the PyThreadState_GET() macro access
_PyRuntime which comes from the internal pycore_state.h header.
Public headers must not require internal headers.

Move PyThreadState_GET() and _PyInterpreterState_GET_UNSAFE() from
Include/pystate.h to Include/internal/pycore_state.h, and rename
PyThreadState_GET() to _PyThreadState_GET() there.

The PyThreadState_GET() macro of pystate.h is now redefined when
pycore_state.h is included, to use the fast _PyThreadState_GET().

Changes:

* Add _PyThreadState_GET() macro
* Replace "PyThreadState_GET()->interp" with
  _PyInterpreterState_GET_UNSAFE()
* Replace PyThreadState_GET() with _PyThreadState_GET() in internal C
  files (compiled with Py_BUILD_CORE defined), but keep
  PyThreadState_GET() in the public header files.
* _testcapimodule.c: replace PyThreadState_GET() with
  PyThreadState_Get(); the module is not compiled with Py_BUILD_CORE
  defined.
* pycore_state.h now requires Py_BUILD_CORE to be defined.
vstinner merged commit 50b4857 into python:master Nov 1, 2018
vstinner deleted the pythreadstate_get branch November 1, 2018 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants