]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127117: Ensure the Correct Last Fields of PyInterpreterState and of _PyRuntimeStat...
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 22 Nov 2024 16:37:02 +0000 (09:37 -0700)
committerGitHub <noreply@github.com>
Fri, 22 Nov 2024 16:37:02 +0000 (09:37 -0700)
We add some comments so contributors can be aware and we move one out-of-place field up.

Include/internal/pycore_interp.h
Include/internal/pycore_runtime.h

index 5e4bcbf835a4d05fc786a9a346ad86f7dbdd7395..87cdcb5b119d15258d4c0efec3abc9c96d91de43 100644 (file)
@@ -283,6 +283,8 @@ struct _is {
 
     /* the initial PyInterpreterState.threads.head */
     _PyThreadStateImpl _initial_thread;
+    // _initial_thread should be the last field of PyInterpreterState.
+    // See https://github.com/python/cpython/issues/127117.
 };
 
 
index 2f2cec22cf1589c9ab36978c4df3e5c8f16b05a0..86d024535fdda82a36b0c78cb2467ecb69d9b129 100644 (file)
@@ -169,6 +169,12 @@ typedef struct pyruntimestate {
     struct _Py_unicode_runtime_state unicode_state;
     struct _types_runtime_state types;
 
+#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
+    // Used in "Python/emscripten_trampoline.c" to choose between type
+    // reflection trampoline and EM_JS trampoline.
+    bool wasm_type_reflection_available;
+#endif
+
     /* All the objects that are shared by the runtime's interpreters. */
     struct _Py_cached_objects cached_objects;
     struct _Py_static_objects static_objects;
@@ -189,13 +195,8 @@ typedef struct pyruntimestate {
 
     /* _PyRuntimeState.interpreters.main */
     PyInterpreterState _main_interpreter;
-
-#if defined(__EMSCRIPTEN__) && defined(PY_CALL_TRAMPOLINE)
-    // Used in "Python/emscripten_trampoline.c" to choose between type
-    // reflection trampoline and EM_JS trampoline.
-    bool wasm_type_reflection_available;
-#endif
-
+    // _main_interpreter should be the last field of _PyRuntimeState.
+    // See https://github.com/python/cpython/issues/127117.
 } _PyRuntimeState;