@@ -380,7 +380,16 @@ _Py_COMP_DIAG_IGNORE_DEPR_DECLS
380
380
static const _PyRuntimeState initial = _PyRuntimeState_INIT (_PyRuntime );
381
381
_Py_COMP_DIAG_POP
382
382
383
- #define NUMLOCKS 5
383
+ #define NUMLOCKS 6
384
+ #define LOCKPTRS (runtime ) \
385
+ { \
386
+ &(runtime)->interpreters.mutex, \
387
+ &(runtime)->xidregistry.mutex, \
388
+ &(runtime)->getargs.mutex, \
389
+ &(runtime)->unicode_state.ids.lock, \
390
+ &(runtime)->imports.extensions.mutex, \
391
+ &(runtime)->ceval.pending_mainthread.lock, \
392
+ }
384
393
385
394
static int
386
395
alloc_for_runtime (PyThread_type_lock locks [NUMLOCKS ])
@@ -427,13 +436,7 @@ init_runtime(_PyRuntimeState *runtime,
427
436
428
437
PyPreConfig_InitPythonConfig (& runtime -> preconfig );
429
438
430
- PyThread_type_lock * lockptrs [NUMLOCKS ] = {
431
- & runtime -> interpreters .mutex ,
432
- & runtime -> xidregistry .mutex ,
433
- & runtime -> getargs .mutex ,
434
- & runtime -> unicode_state .ids .lock ,
435
- & runtime -> imports .extensions .mutex ,
436
- };
439
+ PyThread_type_lock * lockptrs [NUMLOCKS ] = LOCKPTRS (runtime );
437
440
for (int i = 0 ; i < NUMLOCKS ; i ++ ) {
438
441
assert (locks [i ] != NULL );
439
442
* lockptrs [i ] = locks [i ];
@@ -512,13 +515,7 @@ _PyRuntimeState_Fini(_PyRuntimeState *runtime)
512
515
LOCK = NULL; \
513
516
}
514
517
515
- PyThread_type_lock * lockptrs [NUMLOCKS ] = {
516
- & runtime -> interpreters .mutex ,
517
- & runtime -> xidregistry .mutex ,
518
- & runtime -> getargs .mutex ,
519
- & runtime -> unicode_state .ids .lock ,
520
- & runtime -> imports .extensions .mutex ,
521
- };
518
+ PyThread_type_lock * lockptrs [NUMLOCKS ] = LOCKPTRS (runtime );
522
519
for (int i = 0 ; i < NUMLOCKS ; i ++ ) {
523
520
FREE_LOCK (* lockptrs [i ]);
524
521
}
@@ -541,13 +538,7 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
541
538
PyMemAllocatorEx old_alloc ;
542
539
_PyMem_SetDefaultAllocator (PYMEM_DOMAIN_RAW , & old_alloc );
543
540
544
- PyThread_type_lock * lockptrs [NUMLOCKS ] = {
545
- & runtime -> interpreters .mutex ,
546
- & runtime -> xidregistry .mutex ,
547
- & runtime -> getargs .mutex ,
548
- & runtime -> unicode_state .ids .lock ,
549
- & runtime -> imports .extensions .mutex ,
550
- };
541
+ PyThread_type_lock * lockptrs [NUMLOCKS ] = LOCKPTRS (runtime );
551
542
int reinit_err = 0 ;
552
543
for (int i = 0 ; i < NUMLOCKS ; i ++ ) {
553
544
reinit_err += _PyThread_at_fork_reinit (lockptrs [i ]);
0 commit comments