mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-02 10:14:15 +03:00
Folds several historical *_types/_structs/_externs/_inlines splits where the layering is no longer load-bearing. - large_externs.h -> large.h: renamed; it was a single-purpose function-prototype file. - background_thread_structs.h + background_thread_externs.h -> background_thread.h: merged. background_thread_inlines.h is kept separate because it depends on arena_inlines_a.h. - bin_inlines.h folded into bin.h, along with BIN_SHARDS_MAX / N_BIN_SHARDS_DEFAULT from bin_types.h. bin.h carries a forward decl of arena_binind_div_info (declared in arena_externs.h) so it stays hermetic without re-introducing the bin.h <-> arena_externs.h cycle. - tsd_binshards.h (new): houses tsd_binshards_t and its zero initializer. Keeping these out of bin.h lets tsd_internals.h pull in just what it needs during X-macro expansion, avoiding bin.h's mutex.h dependency (mutex.h itself depends on TSD machinery, so routing it through tsd_internals.h forms a chicken-and-egg). jemalloc_internal_includes.h: drops the now-redundant references to the deleted/merged headers.
40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#include "test/jemalloc_test.h"
|
|
|
|
extern void bin_dalloc_locked_begin(
|
|
bin_dalloc_locked_info_t *info, szind_t binind);
|
|
|
|
#define INVALID_ARENA_IND ((1U << MALLOCX_ARENA_BITS) - 1)
|
|
|
|
TEST_BEGIN(test_bin_slab_regind) {
|
|
szind_t binind;
|
|
|
|
for (binind = 0; binind < SC_NBINS; binind++) {
|
|
size_t regind;
|
|
edata_t slab;
|
|
const bin_info_t *bin_info = &bin_infos[binind];
|
|
edata_init(&slab, INVALID_ARENA_IND,
|
|
mallocx(bin_info->slab_size, MALLOCX_LG_ALIGN(LG_PAGE)),
|
|
bin_info->slab_size, true, binind, 0, extent_state_active,
|
|
false, true, EXTENT_PAI_PAC, EXTENT_NOT_HEAD);
|
|
expect_ptr_not_null(
|
|
edata_addr_get(&slab), "Unexpected malloc() failure");
|
|
bin_dalloc_locked_info_t dalloc_info;
|
|
bin_dalloc_locked_begin(&dalloc_info, binind);
|
|
for (regind = 0; regind < bin_info->nregs; regind++) {
|
|
void *reg = (void *)((uintptr_t)edata_addr_get(&slab)
|
|
+ (bin_info->reg_size * regind));
|
|
expect_zu_eq(
|
|
bin_slab_regind(&dalloc_info, binind, &slab, reg),
|
|
regind,
|
|
"Incorrect region index computed for size %zu",
|
|
bin_info->reg_size);
|
|
}
|
|
free(edata_addr_get(&slab));
|
|
}
|
|
}
|
|
TEST_END
|
|
|
|
int
|
|
main(void) {
|
|
return test(test_bin_slab_regind);
|
|
}
|