mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-15 01:16:23 +03:00
Reformat the codebase with the clang-format 18.
This commit is contained in:
parent
0a6215c171
commit
f1bba4a87c
346 changed files with 18286 additions and 17770 deletions
|
|
@ -4,9 +4,9 @@
|
|||
* Size class that is a divisor of the page size, ideally 4+ regions per run.
|
||||
*/
|
||||
#if LG_PAGE <= 14
|
||||
#define SZ (ZU(1) << (LG_PAGE - 2))
|
||||
# define SZ (ZU(1) << (LG_PAGE - 2))
|
||||
#else
|
||||
#define SZ ZU(4096)
|
||||
# define SZ ZU(4096)
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
* if mmap()ed memory grows downward, downward growth of mmap()ed memory is
|
||||
* tested.
|
||||
*/
|
||||
#define NSLABS 8
|
||||
#define NSLABS 8
|
||||
|
||||
static unsigned
|
||||
binind_compute(void) {
|
||||
size_t sz;
|
||||
size_t sz;
|
||||
unsigned nbins, i;
|
||||
|
||||
sz = sizeof(nbins);
|
||||
|
|
@ -27,16 +27,17 @@ binind_compute(void) {
|
|||
|
||||
for (i = 0; i < nbins; i++) {
|
||||
size_t mib[4];
|
||||
size_t miblen = sizeof(mib)/sizeof(size_t);
|
||||
size_t miblen = sizeof(mib) / sizeof(size_t);
|
||||
size_t size;
|
||||
|
||||
expect_d_eq(mallctlnametomib("arenas.bin.0.size", mib,
|
||||
&miblen), 0, "Unexpected mallctlnametomb failure");
|
||||
expect_d_eq(mallctlnametomib("arenas.bin.0.size", mib, &miblen),
|
||||
0, "Unexpected mallctlnametomb failure");
|
||||
mib[2] = (size_t)i;
|
||||
|
||||
sz = sizeof(size);
|
||||
expect_d_eq(mallctlbymib(mib, miblen, (void *)&size, &sz, NULL,
|
||||
0), 0, "Unexpected mallctlbymib failure");
|
||||
expect_d_eq(
|
||||
mallctlbymib(mib, miblen, (void *)&size, &sz, NULL, 0), 0,
|
||||
"Unexpected mallctlbymib failure");
|
||||
if (size == SZ) {
|
||||
return i;
|
||||
}
|
||||
|
|
@ -49,24 +50,24 @@ binind_compute(void) {
|
|||
static size_t
|
||||
nregs_per_run_compute(void) {
|
||||
uint32_t nregs;
|
||||
size_t sz;
|
||||
size_t sz;
|
||||
unsigned binind = binind_compute();
|
||||
size_t mib[4];
|
||||
size_t miblen = sizeof(mib)/sizeof(size_t);
|
||||
size_t mib[4];
|
||||
size_t miblen = sizeof(mib) / sizeof(size_t);
|
||||
|
||||
expect_d_eq(mallctlnametomib("arenas.bin.0.nregs", mib, &miblen), 0,
|
||||
"Unexpected mallctlnametomb failure");
|
||||
mib[2] = (size_t)binind;
|
||||
sz = sizeof(nregs);
|
||||
expect_d_eq(mallctlbymib(mib, miblen, (void *)&nregs, &sz, NULL,
|
||||
0), 0, "Unexpected mallctlbymib failure");
|
||||
expect_d_eq(mallctlbymib(mib, miblen, (void *)&nregs, &sz, NULL, 0), 0,
|
||||
"Unexpected mallctlbymib failure");
|
||||
return nregs;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
arenas_create_mallctl(void) {
|
||||
unsigned arena_ind;
|
||||
size_t sz;
|
||||
size_t sz;
|
||||
|
||||
sz = sizeof(arena_ind);
|
||||
expect_d_eq(mallctl("arenas.create", (void *)&arena_ind, &sz, NULL, 0),
|
||||
|
|
@ -78,7 +79,7 @@ arenas_create_mallctl(void) {
|
|||
static void
|
||||
arena_reset_mallctl(unsigned arena_ind) {
|
||||
size_t mib[3];
|
||||
size_t miblen = sizeof(mib)/sizeof(size_t);
|
||||
size_t miblen = sizeof(mib) / sizeof(size_t);
|
||||
|
||||
expect_d_eq(mallctlnametomib("arena.0.reset", mib, &miblen), 0,
|
||||
"Unexpected mallctlnametomib() failure");
|
||||
|
|
@ -88,23 +89,23 @@ arena_reset_mallctl(unsigned arena_ind) {
|
|||
}
|
||||
|
||||
TEST_BEGIN(test_pack) {
|
||||
bool prof_enabled;
|
||||
bool prof_enabled;
|
||||
size_t sz = sizeof(prof_enabled);
|
||||
if (mallctl("opt.prof", (void *)&prof_enabled, &sz, NULL, 0) == 0) {
|
||||
test_skip_if(prof_enabled);
|
||||
}
|
||||
|
||||
unsigned arena_ind = arenas_create_mallctl();
|
||||
size_t nregs_per_run = nregs_per_run_compute();
|
||||
size_t nregs = nregs_per_run * NSLABS;
|
||||
size_t nregs_per_run = nregs_per_run_compute();
|
||||
size_t nregs = nregs_per_run * NSLABS;
|
||||
VARIABLE_ARRAY(void *, ptrs, nregs);
|
||||
size_t i, j, offset;
|
||||
|
||||
/* Fill matrix. */
|
||||
for (i = offset = 0; i < NSLABS; i++) {
|
||||
for (j = 0; j < nregs_per_run; j++) {
|
||||
void *p = mallocx(SZ, MALLOCX_ARENA(arena_ind) |
|
||||
MALLOCX_TCACHE_NONE);
|
||||
void *p = mallocx(
|
||||
SZ, MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE);
|
||||
expect_ptr_not_null(p,
|
||||
"Unexpected mallocx(%zu, MALLOCX_ARENA(%u) |"
|
||||
" MALLOCX_TCACHE_NONE) failure, run=%zu, reg=%zu",
|
||||
|
|
@ -119,16 +120,15 @@ TEST_BEGIN(test_pack) {
|
|||
* layout policy.
|
||||
*/
|
||||
offset = 0;
|
||||
for (i = offset = 0;
|
||||
i < NSLABS;
|
||||
i++, offset = (offset + 1) % nregs_per_run) {
|
||||
for (i = offset = 0; i < NSLABS;
|
||||
i++, offset = (offset + 1) % nregs_per_run) {
|
||||
for (j = 0; j < nregs_per_run; j++) {
|
||||
void *p = ptrs[(i * nregs_per_run) + j];
|
||||
if (offset == j) {
|
||||
continue;
|
||||
}
|
||||
dallocx(p, MALLOCX_ARENA(arena_ind) |
|
||||
MALLOCX_TCACHE_NONE);
|
||||
dallocx(
|
||||
p, MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -137,17 +137,16 @@ TEST_BEGIN(test_pack) {
|
|||
* that the matrix is unmodified.
|
||||
*/
|
||||
offset = 0;
|
||||
for (i = offset = 0;
|
||||
i < NSLABS;
|
||||
i++, offset = (offset + 1) % nregs_per_run) {
|
||||
for (i = offset = 0; i < NSLABS;
|
||||
i++, offset = (offset + 1) % nregs_per_run) {
|
||||
for (j = 0; j < nregs_per_run; j++) {
|
||||
void *p;
|
||||
|
||||
if (offset == j) {
|
||||
continue;
|
||||
}
|
||||
p = mallocx(SZ, MALLOCX_ARENA(arena_ind) |
|
||||
MALLOCX_TCACHE_NONE);
|
||||
p = mallocx(
|
||||
SZ, MALLOCX_ARENA(arena_ind) | MALLOCX_TCACHE_NONE);
|
||||
expect_ptr_eq(p, ptrs[(i * nregs_per_run) + j],
|
||||
"Unexpected refill discrepancy, run=%zu, reg=%zu\n",
|
||||
i, j);
|
||||
|
|
@ -161,6 +160,5 @@ TEST_END
|
|||
|
||||
int
|
||||
main(void) {
|
||||
return test(
|
||||
test_pack);
|
||||
return test(test_pack);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue