1#include "test/jemalloc_test.h" 2 3TEST_BEGIN(test_arena_slab_regind) 4{ 5 szind_t binind; 6 7 for (binind = 0; binind < NBINS; binind++) { 8 size_t regind; 9 extent_t slab; 10 const arena_bin_info_t *bin_info = &arena_bin_info[binind]; 11 extent_init(&slab, NULL, mallocx(bin_info->slab_size, 12 MALLOCX_LG_ALIGN(LG_PAGE)), bin_info->slab_size, 0, 0, true, 13 false, true, true); 14 assert_ptr_not_null(extent_addr_get(&slab), 15 "Unexpected malloc() failure"); 16 for (regind = 0; regind < bin_info->nregs; regind++) { 17 void *reg = (void *)((uintptr_t)extent_addr_get(&slab) + 18 (bin_info->reg_size * regind)); 19 assert_zu_eq(arena_slab_regind(&slab, binind, reg), 20 regind, 21 "Incorrect region index computed for size %zu", 22 bin_info->reg_size); 23 } 24 free(extent_addr_get(&slab)); 25 } 26} 27TEST_END 28 29int 30main(void) 31{ 32 return (test( 33 test_arena_slab_regind)); 34} 35