diff --git a/src/allocator.c b/src/allocator.c index e6ea77217..861678973 100644 --- a/src/allocator.c +++ b/src/allocator.c @@ -601,10 +601,7 @@ _dispatch_alloc_init(void) // Double-check our math. These are all compile time checks and don't // generate code. - dispatch_assert(sizeof(bitmap_t) == BYTES_PER_BITMAP); dispatch_assert(sizeof(bitmap_t) == BYTES_PER_SUPERMAP); - dispatch_assert(sizeof(struct dispatch_magazine_header_s) == - SIZEOF_HEADER); dispatch_assert(sizeof(struct dispatch_continuation_s) <= DISPATCH_CONTINUATION_SIZE); @@ -614,8 +611,6 @@ _dispatch_alloc_init(void) dispatch_assert(sizeof(struct dispatch_magazine_s) == BYTES_PER_MAGAZINE); // The header and maps sizes should match what we computed. - dispatch_assert(SIZEOF_HEADER == - sizeof(((struct dispatch_magazine_s *)0x0)->header)); dispatch_assert(SIZEOF_MAPS == sizeof(((struct dispatch_magazine_s *)0x0)->maps)); diff --git a/src/allocator_internal.h b/src/allocator_internal.h index abe4a1d43..fc34b955f 100644 --- a/src/allocator_internal.h +++ b/src/allocator_internal.h @@ -97,25 +97,21 @@ // Use the largest type your platform is comfortable doing atomic ops with. // TODO: rdar://11477843 typedef unsigned long bitmap_t; -#if defined(__LP64__) -#define BYTES_PER_BITMAP 8 -#else -#define BYTES_PER_BITMAP 4 -#endif +#define BYTES_PER_BITMAP sizeof(bitmap_t) #define BITMAP_C(v) ((bitmap_t)(v)) #define BITMAP_ALL_ONES (~BITMAP_C(0)) // Stop configuring. -#define CONTINUATIONS_PER_BITMAP (BYTES_PER_BITMAP * 8) -#define BITMAPS_PER_SUPERMAP (BYTES_PER_SUPERMAP * 8) +#define CONTINUATIONS_PER_BITMAP (BYTES_PER_BITMAP * CHAR_BIT) +#define BITMAPS_PER_SUPERMAP (BYTES_PER_SUPERMAP * CHAR_BIT) #define BYTES_PER_MAGAZINE (PAGES_PER_MAGAZINE * DISPATCH_ALLOCATOR_PAGE_SIZE) #define CONSUMED_BYTES_PER_BITMAP (BYTES_PER_BITMAP + \ (DISPATCH_CONTINUATION_SIZE * CONTINUATIONS_PER_BITMAP)) -#define BYTES_PER_SUPERMAP BYTES_PER_BITMAP +#define BYTES_PER_SUPERMAP sizeof(bitmap_t) #define CONSUMED_BYTES_PER_SUPERMAP (BYTES_PER_SUPERMAP + \ (BITMAPS_PER_SUPERMAP * CONSUMED_BYTES_PER_BITMAP)) @@ -147,11 +143,7 @@ typedef unsigned long bitmap_t; #define PADDING_TO_CONTINUATION_SIZE(x) (ROUND_UP_TO_CONTINUATION_SIZE(x) - (x)) -#if defined(__LP64__) -#define SIZEOF_HEADER 16 -#else -#define SIZEOF_HEADER 8 -#endif +#define SIZEOF_HEADER (sizeof(struct dispatch_magazine_header_s)) #define SIZEOF_SUPERMAPS (BYTES_PER_SUPERMAP * SUPERMAPS_PER_MAGAZINE) #define SIZEOF_MAPS (BYTES_PER_BITMAP * BITMAPS_PER_SUPERMAP * \