Skip to content

Commit 0f6e863

Browse files
committed
allocator: use compiler to compute sizeof bitmap_t
Rather than hardcoding the sizeof(bitmap_t) based on `__LP64__` use the compiler builtin `sizeof` to compute the size.
1 parent a697fe7 commit 0f6e863

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/allocator.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,6 @@ _dispatch_alloc_init(void)
601601
// Double-check our math. These are all compile time checks and don't
602602
// generate code.
603603

604-
dispatch_assert(sizeof(bitmap_t) == BYTES_PER_BITMAP);
605604
dispatch_assert(sizeof(bitmap_t) == BYTES_PER_SUPERMAP);
606605

607606
dispatch_assert(sizeof(struct dispatch_continuation_s) <=

src/allocator_internal.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@
9797
// Use the largest type your platform is comfortable doing atomic ops with.
9898
// TODO: rdar://11477843
9999
typedef unsigned long bitmap_t;
100-
#if defined(__LP64__)
101-
#define BYTES_PER_BITMAP 8
102-
#else
103-
#define BYTES_PER_BITMAP 4
104-
#endif
100+
#define BYTES_PER_BITMAP sizeof(bitmap_t)
105101

106102
#define BITMAP_C(v) ((bitmap_t)(v))
107103
#define BITMAP_ALL_ONES (~BITMAP_C(0))
@@ -115,7 +111,7 @@ typedef unsigned long bitmap_t;
115111
#define CONSUMED_BYTES_PER_BITMAP (BYTES_PER_BITMAP + \
116112
(DISPATCH_CONTINUATION_SIZE * CONTINUATIONS_PER_BITMAP))
117113

118-
#define BYTES_PER_SUPERMAP BYTES_PER_BITMAP
114+
#define BYTES_PER_SUPERMAP sizeof(bitmap_t)
119115
#define CONSUMED_BYTES_PER_SUPERMAP (BYTES_PER_SUPERMAP + \
120116
(BITMAPS_PER_SUPERMAP * CONSUMED_BYTES_PER_BITMAP))
121117

0 commit comments

Comments
 (0)