Skip to content

Avoid Standalone Sub-structs In pycore_runtime.h #125604

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

Closed
ericsnowcurrently opened this issue Oct 16, 2024 · 1 comment
Closed

Avoid Standalone Sub-structs In pycore_runtime.h #125604

ericsnowcurrently opened this issue Oct 16, 2024 · 1 comment
Assignees
Labels
3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@ericsnowcurrently
Copy link
Member

ericsnowcurrently commented Oct 16, 2024

pycore_runtime.h is where the _PyRuntimeState struct is declared. Nearly every one of the structs it relies on ("sub-struct") is found in the internal header file that corresponds to that struct's subject matter, rather than in pycore_runtime.h. There are only a few that are declared in pycore_runtime.h, mostly because it was easier to put them there than create the appropriate header files.

In the interest of keeping the focus of pycore_runtime.h on _PyRuntimeState, I'd like to clear out the standalone sub-structs there.

The involves the following:

  • _Py_DebugOffsets - move to its own header file (pycore_debugger_utils.h)
  • struct _getargs_runtime_state - inline in _PyRuntimeState
  • struct _gilstate_runtime_state - inline in _PyRuntimeState
  • _Py_AuditHookEntry - move to its own header file (pycore_audit.h); also move the other audit-related APIs to pycore_audit.h or audit.h (to be added)
  • struct _reftracer_runtime_state - move to pycore_object_state.h

_Py_DebugOffsets is the most meaningful one to move since it is so big (visually occludes _PyRuntimeState). For _Py_AuditHookEntry, we probably should have added pycore_audit.h in the first place.

Linked PRs

@ericsnowcurrently ericsnowcurrently added interpreter-core (Objects, Python, Grammar, and Parser dirs) 3.14 bugs and security fixes labels Oct 16, 2024
@ericsnowcurrently ericsnowcurrently self-assigned this Oct 16, 2024
@kumaraditya303
Copy link
Contributor

SGTM!

ericsnowcurrently added a commit that referenced this issue Oct 18, 2024
…125605)

This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed.

We do the following:

* add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there
* inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState
* move struct _reftracer_runtime_state to the existing pycore_object_state.h
* add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks
* add audit.h and cpython/audit.h and move the existing audit-related API there
*move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
pythongh-125605)

This is essentially a cleanup, moving a handful of API declarations to the header files where they fit best, creating new ones when needed.

We do the following:

* add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there
* inline struct _getargs_runtime_state and struct _gilstate_runtime_state in _PyRuntimeState
* move struct _reftracer_runtime_state to the existing pycore_object_state.h
* add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and _PySys_ClearAuditHooks
* add audit.h and cpython/audit.h and move the existing audit-related API there
*move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h, and remove the now-empty cpython/sysmodule.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

2 participants