Skip to content

Commit a697fe7

Browse files
committed
allocator: use the compiler to compute header size
Rather than trying to compute the size of the magazine header manually, use the compiler's builtin `sizeof` operator.
1 parent 2df80a3 commit a697fe7

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

src/allocator.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -603,8 +603,6 @@ _dispatch_alloc_init(void)
603603

604604
dispatch_assert(sizeof(bitmap_t) == BYTES_PER_BITMAP);
605605
dispatch_assert(sizeof(bitmap_t) == BYTES_PER_SUPERMAP);
606-
dispatch_assert(sizeof(struct dispatch_magazine_header_s) ==
607-
SIZEOF_HEADER);
608606

609607
dispatch_assert(sizeof(struct dispatch_continuation_s) <=
610608
DISPATCH_CONTINUATION_SIZE);
@@ -614,8 +612,6 @@ _dispatch_alloc_init(void)
614612
dispatch_assert(sizeof(struct dispatch_magazine_s) == BYTES_PER_MAGAZINE);
615613

616614
// The header and maps sizes should match what we computed.
617-
dispatch_assert(SIZEOF_HEADER ==
618-
sizeof(((struct dispatch_magazine_s *)0x0)->header));
619615
dispatch_assert(SIZEOF_MAPS ==
620616
sizeof(((struct dispatch_magazine_s *)0x0)->maps));
621617

src/allocator_internal.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,7 @@ typedef unsigned long bitmap_t;
147147

148148
#define PADDING_TO_CONTINUATION_SIZE(x) (ROUND_UP_TO_CONTINUATION_SIZE(x) - (x))
149149

150-
#if defined(__LP64__)
151-
#define SIZEOF_HEADER 16
152-
#else
153-
#define SIZEOF_HEADER 8
154-
#endif
150+
#define SIZEOF_HEADER (sizeof(struct dispatch_magazine_header_s))
155151

156152
#define SIZEOF_SUPERMAPS (BYTES_PER_SUPERMAP * SUPERMAPS_PER_MAGAZINE)
157153
#define SIZEOF_MAPS (BYTES_PER_BITMAP * BITMAPS_PER_SUPERMAP * \

0 commit comments

Comments
 (0)