@@ -238,7 +238,18 @@ struct type_cache {
238238struct _is {
239239
240240 struct _is * next ;
241- struct _ts * tstate_head ;
241+
242+ struct pythreads {
243+ uint64_t next_unique_id ;
244+ struct _ts * head ;
245+ /* Used in Modules/_threadmodule.c. */
246+ long count ;
247+ /* Support for runtime thread stack size tuning.
248+ A value of 0 means using the platform's default stack size
249+ or the size specified by the THREAD_STACK_SIZE macro. */
250+ /* Used in Python/thread.c. */
251+ size_t stacksize ;
252+ } threads ;
242253
243254 /* Reference to the _PyRuntime global variable. This field exists
244255 to not have to pass runtime in addition to tstate to a function.
@@ -250,6 +261,11 @@ struct _is {
250261 int requires_idref ;
251262 PyThread_type_lock id_mutex ;
252263
264+ /* Has been initialized to a safe state.
265+
266+ In order to be effective, this must be set to 0 during or right
267+ after allocation. */
268+ int _initialized ;
253269 int finalizing ;
254270
255271 struct _ceval_state ceval ;
@@ -268,14 +284,6 @@ struct _is {
268284 // (-1: "off", 1: "on", 0: no override)
269285 int override_frozen_modules ;
270286
271- /* Used in Modules/_threadmodule.c. */
272- long num_threads ;
273- /* Support for runtime thread stack size tuning.
274- A value of 0 means using the platform's default stack size
275- or the size specified by the THREAD_STACK_SIZE macro. */
276- /* Used in Python/thread.c. */
277- size_t pythread_stacksize ;
278-
279287 PyObject * codec_search_path ;
280288 PyObject * codec_search_cache ;
281289 PyObject * codec_error_registry ;
@@ -302,8 +310,6 @@ struct _is {
302310 PyObject * after_forkers_child ;
303311#endif
304312
305- uint64_t tstate_next_unique_id ;
306-
307313 struct _warnings_runtime_state warnings ;
308314 struct atexit_state atexit ;
309315
0 commit comments