@@ -139,24 +139,20 @@ get_gc_state(void)
139139void
140140_PyGC_InitState (GCState * gcstate )
141141{
142- gcstate -> enabled = 1 ; /* automatic collection enabled? */
143-
144- #define _GEN_HEAD (n ) GEN_HEAD(gcstate, n)
145- struct gc_generation generations [NUM_GENERATIONS ] = {
146- /* PyGC_Head, threshold, count */
147- {{(uintptr_t )_GEN_HEAD (0 ), (uintptr_t )_GEN_HEAD (0 )}, 700 , 0 },
148- {{(uintptr_t )_GEN_HEAD (1 ), (uintptr_t )_GEN_HEAD (1 )}, 10 , 0 },
149- {{(uintptr_t )_GEN_HEAD (2 ), (uintptr_t )_GEN_HEAD (2 )}, 10 , 0 },
150- };
142+ #define INIT_HEAD (GEN ) \
143+ do { \
144+ GEN.head._gc_next = (uintptr_t)&GEN.head; \
145+ GEN.head._gc_prev = (uintptr_t)&GEN.head; \
146+ } while (0)
147+
151148 for (int i = 0 ; i < NUM_GENERATIONS ; i ++ ) {
152- gcstate -> generations [i ] = generations [i ];
149+ assert (gcstate -> generations [i ].count == 0 );
150+ INIT_HEAD (gcstate -> generations [i ]);
153151 };
154152 gcstate -> generation0 = GEN_HEAD (gcstate , 0 );
155- struct gc_generation permanent_generation = {
156- {(uintptr_t )& gcstate -> permanent_generation .head ,
157- (uintptr_t )& gcstate -> permanent_generation .head }, 0 , 0
158- };
159- gcstate -> permanent_generation = permanent_generation ;
153+ INIT_HEAD (gcstate -> permanent_generation );
154+
155+ #undef INIT_HEAD
160156}
161157
162158
0 commit comments