8000 py/gc: Apply some code formatting cleanup. · micropython/micropython@d325ee4 · GitHub
[go: up one dir, main page]

Skip to content

Commit d325ee4

Browse files
projectgusdpgeorge
authored andcommitted
py/gc: Apply some code formatting cleanup.
This commit: - Breaks up some long lines for readability. - Fixes a potential macro argument expansion issue. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 8851800 commit d325ee4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

py/gc.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#define ATB_3_IS_FREE(a) (((a) & ATB_MASK_3) == 0)
8080

8181
#if MICROPY_GC_SPLIT_HEAP
82-
#define NEXT_AREA(area) (area->next)
82+
#define NEXT_AREA(area) ((area)->next)
8383
#else
8484
#define NEXT_AREA(area) (NULL)
8585
#endif
@@ -129,7 +129,13 @@ STATIC void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
129129
// => T = A * (1 + BLOCKS_PER_ATB / BLOCKS_PER_FTB + BLOCKS_PER_ATB * BYTES_PER_BLOCK)
130130
size_t total_byte_len = (byte *)end - (byte *)start;
131131
#if MICROPY_ENABLE_FINALISER
132-
area->gc_alloc_table_byte_len = (total_byte_len - ALLOC_TABLE_GAP_BYTE) * MP_BITS_PER_BYTE / (MP_BITS_PER_BYTE + MP_BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + MP_BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK);
132+
area->gc_alloc_table_byte_len = (total_byte_len - ALLOC_TABLE_GAP_BYTE)
133+
* MP_BITS_PER_BYTE
134+
/ (
135+
MP_BITS_PER_BYTE
136+
+ MP_BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB
137+
+ MP_BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK
138+
);
133139
#else
134140
area->gc_alloc_table_byte_len = (total_byte_len - ALLOC_TABLE_GAP_BYTE) / (1 + MP_BITS_PER_BYTE / 2 * BYTES_PER_BLOCK);
135141
#endif
@@ -165,11 +171,19 @@ STATIC void gc_setup_area(mp_state_mem_area_t *area, void *start, void *end) {
165171
#endif
166172

167173
DEBUG_printf("GC layout:\n");
168-
DEBUG_printf(" alloc table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(area).gc_alloc_table_start, MP_STATE_MEM(area).gc_alloc_table_byte_len, MP_STATE_MEM(area).gc_alloc_table_byte_len * BLOCKS_PER_ATB);
174+
DEBUG_printf(" alloc table at %p, length " UINT_FMT " bytes, "
175+
UINT_FMT " blocks\n",
176+
area->gc_alloc_table_start, area->gc_alloc_table_byte_len,
177+
area->gc_alloc_table_byte_len * BLOCKS_PER_ATB);
169178
#if MICROPY_ENABLE_FINALISER
170-
DEBUG_printf(" finaliser table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(area).gc_finaliser_table_start, gc_finaliser_table_byte_len, gc_finaliser_table_byte_len * BLOCKS_PER_FTB);
179+
DEBUG_printf(" finaliser table at %p, length " UINT_FMT " bytes, "
180+
UINT_FMT " blocks\n", area->gc_finaliser_table_start,
181+
gc_finaliser_table_byte_len,
182+
gc_finaliser_table_byte_len * BLOCKS_PER_FTB);
171183
#endif
172-
DEBUG_printf(" pool at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(area).gc_pool_start, gc_pool_block_len * BYTES_PER_BLOCK, gc_pool_block_len);
184+
DEBUG_printf(" pool at %p, length " UINT_FMT " bytes, "
185+
UINT_FMT " blocks\n", area->gc_pool_start,
186+
gc_pool_block_len * BYTES_PER_BLOCK, gc_pool_block_len);
173187
}
174188

175189
void gc_init(void *start, void *end) {

0 commit comments

Comments
 (0)
0