diff options
author | Jason Evans <jasone@canonware.com> | 2014-09-28 21:43:11 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2014-09-28 21:43:11 (GMT) |
commit | f97e5ac4ec8a5ae7ed74829e6c1bf6ce814947f5 (patch) | |
tree | 0ffae73077e48d9e51ce7537f3fa1afee39c9763 /src/bitmap.c | |
parent | 6ef80d68f092caf3b3802a73b8d716057b41864c (diff) | |
download | jemalloc-f97e5ac4ec8a5ae7ed74829e6c1bf6ce814947f5.zip jemalloc-f97e5ac4ec8a5ae7ed74829e6c1bf6ce814947f5.tar.gz jemalloc-f97e5ac4ec8a5ae7ed74829e6c1bf6ce814947f5.tar.bz2 |
Implement compile-time bitmap size computation.
Diffstat (limited to 'src/bitmap.c')
-rw-r--r-- | src/bitmap.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/bitmap.c b/src/bitmap.c index e2bd907..c733372 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -2,19 +2,6 @@ #include "jemalloc/internal/jemalloc_internal.h" /******************************************************************************/ -/* Function prototypes for non-inline static functions. */ - -static size_t bits2groups(size_t nbits); - -/******************************************************************************/ - -static size_t -bits2groups(size_t nbits) -{ - - return ((nbits >> LG_BITMAP_GROUP_NBITS) + - !!(nbits & BITMAP_GROUP_NBITS_MASK)); -} void bitmap_info_init(bitmap_info_t *binfo, size_t nbits) @@ -31,15 +18,16 @@ bitmap_info_init(bitmap_info_t *binfo, size_t nbits) * that requires only one group. */ binfo->levels[0].group_offset = 0; - group_count = bits2groups(nbits); + group_count = BITMAP_BITS2GROUPS(nbits); for (i = 1; group_count > 1; i++) { assert(i < BITMAP_MAX_LEVELS); binfo->levels[i].group_offset = binfo->levels[i-1].group_offset + group_count; - group_count = bits2groups(group_count); + group_count = BITMAP_BITS2GROUPS(group_count); } binfo->levels[i].group_offset = binfo->levels[i-1].group_offset + group_count; + assert(binfo->levels[i].group_offset <= BITMAP_GROUPS_MAX); binfo->nlevels = i; binfo->nbits = nbits; } |