1a0698ed9Schristos #include "test/jemalloc_test.h" 2a0698ed9Schristos 3*7bdf38e5Schristos #define INVALID_ARENA_IND ((1U << MALLOCX_ARENA_BITS) - 1) 4*7bdf38e5Schristos 5a0698ed9Schristos TEST_BEGIN(test_arena_slab_regind) { 6a0698ed9Schristos szind_t binind; 7a0698ed9Schristos 8*7bdf38e5Schristos for (binind = 0; binind < SC_NBINS; binind++) { 9a0698ed9Schristos size_t regind; 10*7bdf38e5Schristos edata_t slab; 11a0698ed9Schristos const bin_info_t *bin_info = &bin_infos[binind]; 12*7bdf38e5Schristos edata_init(&slab, INVALID_ARENA_IND, 13*7bdf38e5Schristos mallocx(bin_info->slab_size, MALLOCX_LG_ALIGN(LG_PAGE)), 14*7bdf38e5Schristos bin_info->slab_size, true, 15*7bdf38e5Schristos binind, 0, extent_state_active, false, true, EXTENT_PAI_PAC, 16*7bdf38e5Schristos EXTENT_NOT_HEAD); 17*7bdf38e5Schristos expect_ptr_not_null(edata_addr_get(&slab), 18a0698ed9Schristos "Unexpected malloc() failure"); 19*7bdf38e5Schristos arena_dalloc_bin_locked_info_t dalloc_info; 20*7bdf38e5Schristos arena_dalloc_bin_locked_begin(&dalloc_info, binind); 21a0698ed9Schristos for (regind = 0; regind < bin_info->nregs; regind++) { 22*7bdf38e5Schristos void *reg = (void *)((uintptr_t)edata_addr_get(&slab) + 23a0698ed9Schristos (bin_info->reg_size * regind)); 24*7bdf38e5Schristos expect_zu_eq(arena_slab_regind(&dalloc_info, binind, 25*7bdf38e5Schristos &slab, reg), 26a0698ed9Schristos regind, 27a0698ed9Schristos "Incorrect region index computed for size %zu", 28a0698ed9Schristos bin_info->reg_size); 29a0698ed9Schristos } 30*7bdf38e5Schristos free(edata_addr_get(&slab)); 31a0698ed9Schristos } 32a0698ed9Schristos } 33a0698ed9Schristos TEST_END 34a0698ed9Schristos 35a0698ed9Schristos int 36a0698ed9Schristos main(void) { 37a0698ed9Schristos return test( 38a0698ed9Schristos test_arena_slab_regind); 39a0698ed9Schristos } 40