diff options
Diffstat (limited to 'examples/redis-unstable/deps/jemalloc/test/unit/slab.c')
| -rw-r--r-- | examples/redis-unstable/deps/jemalloc/test/unit/slab.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/redis-unstable/deps/jemalloc/test/unit/slab.c b/examples/redis-unstable/deps/jemalloc/test/unit/slab.c new file mode 100644 index 0000000..70fc5c7 --- /dev/null +++ b/examples/redis-unstable/deps/jemalloc/test/unit/slab.c | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | #include "test/jemalloc_test.h" | ||
| 2 | |||
| 3 | #define INVALID_ARENA_IND ((1U << MALLOCX_ARENA_BITS) - 1) | ||
| 4 | |||
| 5 | TEST_BEGIN(test_arena_slab_regind) { | ||
| 6 | szind_t binind; | ||
| 7 | |||
| 8 | for (binind = 0; binind < SC_NBINS; binind++) { | ||
| 9 | size_t regind; | ||
| 10 | edata_t slab; | ||
| 11 | const bin_info_t *bin_info = &bin_infos[binind]; | ||
| 12 | edata_init(&slab, INVALID_ARENA_IND, | ||
| 13 | mallocx(bin_info->slab_size, MALLOCX_LG_ALIGN(LG_PAGE)), | ||
| 14 | bin_info->slab_size, true, | ||
| 15 | binind, 0, extent_state_active, false, true, EXTENT_PAI_PAC, | ||
| 16 | EXTENT_NOT_HEAD); | ||
| 17 | expect_ptr_not_null(edata_addr_get(&slab), | ||
| 18 | "Unexpected malloc() failure"); | ||
| 19 | arena_dalloc_bin_locked_info_t dalloc_info; | ||
| 20 | arena_dalloc_bin_locked_begin(&dalloc_info, binind); | ||
| 21 | for (regind = 0; regind < bin_info->nregs; regind++) { | ||
| 22 | void *reg = (void *)((uintptr_t)edata_addr_get(&slab) + | ||
| 23 | (bin_info->reg_size * regind)); | ||
| 24 | expect_zu_eq(arena_slab_regind(&dalloc_info, binind, | ||
| 25 | &slab, reg), | ||
| 26 | regind, | ||
| 27 | "Incorrect region index computed for size %zu", | ||
| 28 | bin_info->reg_size); | ||
| 29 | } | ||
| 30 | free(edata_addr_get(&slab)); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | TEST_END | ||
| 34 | |||
| 35 | int | ||
| 36 | main(void) { | ||
| 37 | return test( | ||
| 38 | test_arena_slab_regind); | ||
| 39 | } | ||
