]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131238: Remove pycore_runtime.h from pycore_pystate.h (#131356)
authorVictor Stinner <vstinner@python.org>
Wed, 19 Mar 2025 16:33:24 +0000 (17:33 +0100)
committerGitHub <noreply@github.com>
Wed, 19 Mar 2025 16:33:24 +0000 (17:33 +0100)
* Remove includes from pycore_pystate.h:

  * pycore_runtime_structs.h
  * pycore_runtime.h
  * pycore_tstate.h
  * pycore_interp.h

* Reorganize internal headers. Move _gc_thread_state from
  pycore_interp_structs.h to pycore_tstate.h.
* Add 3 new header files to PCbuild/pythoncore.vcxproj.

16 files changed:
Include/internal/pycore_call.h
Include/internal/pycore_interp.h
Include/internal/pycore_interp_structs.h
Include/internal/pycore_pystate.h
Include/internal/pycore_tstate.h
Include/internal/pycore_tuple.h
Makefile.pre.in
Modules/_testinternalcapi/test_critical_sections.c
Modules/_winapi.c
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Parser/action_helpers.c
Parser/myreadline.c
Python/bltinmodule.c
Python/dynload_win.c
Python/pytime.c

index 38d005c039f7a392dd174582a8766d85c13f58f9..32ac3d17f2207780748795f6e4ffd9bf5dd178c4 100644 (file)
@@ -8,6 +8,7 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+#include "pycore_code.h"          // EVAL_CALL_STAT_INC_IF_FUNCTION()
 #include "pycore_pystate.h"       // _PyThreadState_GET()
 #include "pycore_stats.h"
 
index a5502629769e8e8ca1a017e04d9d76d44e1ebfc1..740b0c7ec46093092e721fb71887d3eb2bedee3d 100644 (file)
@@ -42,7 +42,6 @@ extern "C" {
 #include "pycore_warnings.h"      // struct _warnings_runtime_state
 
 
-
 /* interpreter state */
 
 #define _PyInterpreterState_WHENCE_NOTSET -1
@@ -134,6 +133,9 @@ PyAPI_FUNC(PyStatus) _PyInterpreterState_New(
     PyThreadState *tstate,
     PyInterpreterState **pinterp);
 
+extern const PyConfig* _PyInterpreterState_GetConfig(
+    PyInterpreterState *interp);
+
 #ifdef __cplusplus
 }
 #endif
index bdeb7f0199853b4a795c179721a7b163bb09760e..de1b41da369161f0836f31d2d2f1a739aaec8c86 100644 (file)
@@ -5,9 +5,10 @@ extern "C" {
 #endif
 
 #include "pycore_ast_state.h"     // struct ast_state
-#include "pycore_llist.h"
+#include "pycore_llist.h"         // struct llist_node
 #include "pycore_pymath.h"        // _PY_SHORT_FLOAT_REPR
-#include "pycore_structs.h"
+#include "pycore_structs.h"       // PyHamtObject
+#include "pycore_tstate.h"        // _PyThreadStateImpl
 #include "pycore_typedefs.h"      // _PyRuntimeState
 
 
@@ -246,13 +247,6 @@ struct _gc_runtime_state {
 #endif
 };
 
-#ifdef Py_GIL_DISABLED
-struct _gc_thread_state {
-    /* Thread-local allocation count. */
-    Py_ssize_t alloc_count;
-};
-#endif
-
 #include "pycore_gil.h"
 
 /****** Thread state **************/
index 2fad2c64b6f5b50b3c9fb519521c1374679247a8..864e0f5d1db28922bc857dedcdb81e9a2bc4c84a 100644 (file)
@@ -8,11 +8,8 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
-#include "pycore_runtime_structs.h" // _PyRuntime
-#include "pycore_runtime.h"         // _PyRuntimeState_GetFinalizing
-#include "pycore_tstate.h"          // _PyThreadStateImpl
+#include "pycore_typedefs.h"      // _PyRuntimeState
 
-extern const PyConfig* _PyInterpreterState_GetConfig(PyInterpreterState *interp);
 
 // Values for PyThreadState.state. A thread must be in the "attached" state
 // before calling most Python APIs. If the GIL is enabled, then "attached"
index 6f50bb2f26307aff70cf5bf0601c856f85413ee1..b73cd6828b5199f6abb447822aabc7070d5330b8 100644 (file)
@@ -14,6 +14,13 @@ extern "C" {
 #include "pycore_qsbr.h"            // struct qsbr
 
 
+#ifdef Py_GIL_DISABLED
+struct _gc_thread_state {
+    /* Thread-local allocation count. */
+    Py_ssize_t alloc_count;
+};
+#endif
+
 // Every PyThreadState is actually allocated as a _PyThreadStateImpl. The
 // PyThreadState fields are exposed as part of the C API, although most fields
 // are intended to be private. The _PyThreadStateImpl fields not exposed.
index dc68d6648b9ec8757ebe3f72f730c68eb495e6a8..da6754ff7dbd4fe30f6479fbada5c3189e14e12b 100644 (file)
@@ -8,6 +8,8 @@ extern "C" {
 #  error "this header requires Py_BUILD_CORE define"
 #endif
 
+#include "pycore_structs.h"       // _PyStackRef
+
 extern void _PyTuple_MaybeUntrack(PyObject *);
 extern void _PyTuple_DebugMallocStats(FILE *out);
 
index 076312807f3cc700015040feaf19d6fd051f9325..db84eb61a780a77f80bcfb514c25e3e1dee658bb 100644 (file)
@@ -1305,11 +1305,11 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/internal/pycore_sliceobject.h \
                $(srcdir)/Include/internal/pycore_stats.h \
                $(srcdir)/Include/internal/pycore_strhex.h \
+               $(srcdir)/Include/internal/pycore_stackref.h \
                $(srcdir)/Include/internal/pycore_structs.h \
                $(srcdir)/Include/internal/pycore_structseq.h \
                $(srcdir)/Include/internal/pycore_symtable.h \
                $(srcdir)/Include/internal/pycore_sysmodule.h \
-               $(srcdir)/Include/internal/pycore_stackref.h \
                $(srcdir)/Include/internal/pycore_time.h \
                $(srcdir)/Include/internal/pycore_token.h \
                $(srcdir)/Include/internal/pycore_traceback.h \
@@ -1317,13 +1317,13 @@ PYTHON_HEADERS= \
                $(srcdir)/Include/internal/pycore_tstate.h \
                $(srcdir)/Include/internal/pycore_tuple.h \
                $(srcdir)/Include/internal/pycore_typedefs.h \
-               $(srcdir)/Include/internal/pycore_uniqueid.h \
                $(srcdir)/Include/internal/pycore_typeobject.h \
                $(srcdir)/Include/internal/pycore_typevarobject.h \
                $(srcdir)/Include/internal/pycore_ucnhash.h \
                $(srcdir)/Include/internal/pycore_unicodeobject.h \
                $(srcdir)/Include/internal/pycore_unicodeobject_generated.h \
                $(srcdir)/Include/internal/pycore_unionobject.h \
+               $(srcdir)/Include/internal/pycore_uniqueid.h \
                $(srcdir)/Include/internal/pycore_uop_ids.h \
                $(srcdir)/Include/internal/pycore_uop_metadata.h \
                $(srcdir)/Include/internal/pycore_warnings.h \
index 1df960f9881f7093128b6ca285f72c53c9c1080d..e0ba37abcdd33293d879676ebdf51ddfd8413fec 100644 (file)
@@ -3,9 +3,12 @@
  */
 
 #include "parts.h"
-
 #include "pycore_critical_section.h"
 
+#ifdef MS_WINDOWS
+#  include <windows.h>            // Sleep()
+#endif
+
 #ifdef Py_GIL_DISABLED
 #define assert_nogil assert
 #define assert_gil(x)
index fd518212717c40bc9f79015e8138e769a46ff3b9..9aff28173a504273f7d3554325a9ce74c006a8b5 100644 (file)
 #include "pycore_moduleobject.h"  // _PyModule_GetState()
 #include "pycore_pylifecycle.h"   // _Py_IsInterpreterFinalizing()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET
-#include "pycore_unicodeobject.h" // _PyUnicode_WideCharString_Opt_Converter
-
+#include "pycore_unicodeobject.h" // for Argument Clinic
 
 
 #ifndef WINDOWS_LEAN_AND_MEAN
-#define WINDOWS_LEAN_AND_MEAN
+#  define WINDOWS_LEAN_AND_MEAN
 #endif
-#include "windows.h"
+#include <windows.h>
 #include <winioctl.h>
 #include <crtdbg.h>
 #include "winreparse.h"
index 2a245e931fc9b8458e9521ba2a54ab56ad90e74f..d2c9664b08a7556b274d41ccbe7f766ed5bf7572 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_initconfig.h" />
     <ClInclude Include="..\Include\internal\pycore_instruction_sequence.h" />
     <ClInclude Include="..\Include\internal\pycore_interp.h" />
+    <ClInclude Include="..\Include\internal\pycore_interp_structs.h" />
     <ClInclude Include="..\Include\internal\pycore_intrinsics.h" />
     <ClInclude Include="..\Include\internal\pycore_jit.h" />
     <ClInclude Include="..\Include\internal\pycore_list.h" />
index 28cd3ec507ac3389f09b3857530afb2373a05a77..816bde53ffbc8a10125bf5679f5946a2aa8b8536 100644 (file)
     <ClInclude Include="..\Include\internal\pycore_interp.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_interp_structs.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_intrinsics.h">
       <Filter>Include\cpython</Filter>
     </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_runtime_init_generated.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_runtime_structs.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_semaphore.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_strhex.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
+    <ClInclude Include="..\Include\internal\pycore_structs.h">
+      <Filter>Include\internal</Filter>
+    </ClInclude>
     <ClInclude Include="..\Include\internal\pycore_sysmodule.h">
       <Filter>Include\internal</Filter>
     </ClInclude>
index 0baec5b93afd7a3eb4dcd515de67abaf21e4021c..b72a69c242328a85ab53d25f2efad038d2255abe 100644 (file)
@@ -1,12 +1,11 @@
 #include <Python.h>
+#include "pycore_pystate.h"         // _PyInterpreterState_GET()
+#include "pycore_runtime.h"         // _PyRuntime
+#include "pycore_unicodeobject.h"   // _PyUnicode_InternImmortal()
 
 #include "pegen.h"
 #include "string_parser.h"          // _PyPegen_decode_string()
 
-#include "pycore_pystate.h"         // _PyInterpreterState_GET()
-#include "pycore_unicodeobject.h"   // _PyUnicode_InternImmortal()
-#include "pycore_unicodeobject.h"   // _PyUnicode_InternImmortal()
-
 
 void *
 _PyPegen_dummy_name(Parser *p, ...)
index 74c44ff77717f588783360b09334240b35ee49df..99c5760cd51442cae6c04683d6b142859dbe8bac 100644 (file)
@@ -11,7 +11,8 @@
 
 #include "Python.h"
 #include "pycore_fileutils.h"     // _Py_BEGIN_SUPPRESS_IPH
-#include "pycore_pystate.h"   // _PyThreadState_GET()
+#include "pycore_interp.h"        // _PyInterpreterState_GetConfig()
+#include "pycore_pystate.h"       // _PyThreadState_GET()
 #ifdef MS_WINDOWS
 #  ifndef WIN32_LEAN_AND_MEAN
 #    define WIN32_LEAN_AND_MEAN
index 3174105fbe32e233389b5884ce1e9dac4850ccd0..1b87e6e0b6c7e4be60e16181e6043192a34611e0 100644 (file)
@@ -6,6 +6,7 @@
 #include "pycore_ceval.h"         // _PyEval_Vector()
 #include "pycore_compile.h"       // _PyAST_Compile()
 #include "pycore_fileutils.h"     // _PyFile_Flush
+#include "pycore_interp.h"        // _PyInterpreterState_GetConfig()
 #include "pycore_long.h"          // _PyLong_CompactValue
 #include "pycore_modsupport.h"    // _PyArg_NoKwnames()
 #include "pycore_object.h"        // _Py_AddToAllObjects()
index a0ac31c80a5f6e33088c8f25f82f071a8eebee67..6324063401e51f3b8abf8e08f5f44ece81e7117a 100644 (file)
@@ -3,9 +3,10 @@
 
 #include "Python.h"
 #include "pycore_fileutils.h"     // _Py_add_relfile()
+#include "pycore_importdl.h"      // dl_funcptr
+#include "pycore_interp.h"        // _PyInterpreterState_GetConfig()
 #include "pycore_pystate.h"       // _PyInterpreterState_GET()
 
-#include "pycore_importdl.h"      // dl_funcptr
 #include "patchlevel.h"           // PY_MAJOR_VERSION
 #include <windows.h>
 
index 23e1608633940efc5028fb04b6274bdde4216e29..67cf643726449096c54de3e451f8044f5e9c64fc 100644 (file)
@@ -1,7 +1,8 @@
 #include "Python.h"
 #include "pycore_initconfig.h"    // _PyStatus_ERR
-#include "pycore_time.h"          // PyTime_t
 #include "pycore_pystate.h"       // _Py_AssertHoldsTstate()
+#include "pycore_runtime.h"       // _PyRuntime
+#include "pycore_time.h"          // PyTime_t
 
 #include <time.h>                 // gmtime_r()
 #ifdef HAVE_SYS_TIME_H