mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-02 18:17:54 +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
|
|
@ -1,6 +1,7 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
|
||||
const char *malloc_conf = "background_thread:false,narenas:1,max_background_threads:8";
|
||||
const char *malloc_conf =
|
||||
"background_thread:false,narenas:1,max_background_threads:8";
|
||||
|
||||
static unsigned
|
||||
max_test_narenas(void) {
|
||||
|
|
@ -21,14 +22,14 @@ TEST_BEGIN(test_deferred) {
|
|||
test_skip_if(!have_background_thread);
|
||||
|
||||
unsigned id;
|
||||
size_t sz_u = sizeof(unsigned);
|
||||
size_t sz_u = sizeof(unsigned);
|
||||
|
||||
for (unsigned i = 0; i < max_test_narenas(); i++) {
|
||||
expect_d_eq(mallctl("arenas.create", &id, &sz_u, NULL, 0), 0,
|
||||
"Failed to create arena");
|
||||
}
|
||||
|
||||
bool enable = true;
|
||||
bool enable = true;
|
||||
size_t sz_b = sizeof(bool);
|
||||
expect_d_eq(mallctl("background_thread", NULL, NULL, &enable, sz_b), 0,
|
||||
"Failed to enable background threads");
|
||||
|
|
@ -44,29 +45,32 @@ TEST_BEGIN(test_max_background_threads) {
|
|||
size_t max_n_thds;
|
||||
size_t opt_max_n_thds;
|
||||
size_t sz_m = sizeof(max_n_thds);
|
||||
expect_d_eq(mallctl("opt.max_background_threads",
|
||||
&opt_max_n_thds, &sz_m, NULL, 0), 0,
|
||||
"Failed to get opt.max_background_threads");
|
||||
expect_d_eq(mallctl("max_background_threads", &max_n_thds, &sz_m, NULL,
|
||||
0), 0, "Failed to get max background threads");
|
||||
expect_d_eq(mallctl("opt.max_background_threads", &opt_max_n_thds,
|
||||
&sz_m, NULL, 0),
|
||||
0, "Failed to get opt.max_background_threads");
|
||||
expect_d_eq(
|
||||
mallctl("max_background_threads", &max_n_thds, &sz_m, NULL, 0), 0,
|
||||
"Failed to get max background threads");
|
||||
expect_zu_eq(opt_max_n_thds, max_n_thds,
|
||||
"max_background_threads and "
|
||||
"opt.max_background_threads should match");
|
||||
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &max_n_thds,
|
||||
sz_m), 0, "Failed to set max background threads");
|
||||
expect_d_eq(
|
||||
mallctl("max_background_threads", NULL, NULL, &max_n_thds, sz_m), 0,
|
||||
"Failed to set max background threads");
|
||||
size_t size_zero = 0;
|
||||
expect_d_ne(mallctl("max_background_threads", NULL, NULL, &size_zero,
|
||||
sz_m), 0, "Should not allow zero background threads");
|
||||
expect_d_ne(
|
||||
mallctl("max_background_threads", NULL, NULL, &size_zero, sz_m), 0,
|
||||
"Should not allow zero background threads");
|
||||
|
||||
unsigned id;
|
||||
size_t sz_u = sizeof(unsigned);
|
||||
size_t sz_u = sizeof(unsigned);
|
||||
|
||||
for (unsigned i = 0; i < max_test_narenas(); i++) {
|
||||
expect_d_eq(mallctl("arenas.create", &id, &sz_u, NULL, 0), 0,
|
||||
"Failed to create arena");
|
||||
}
|
||||
|
||||
bool enable = true;
|
||||
bool enable = true;
|
||||
size_t sz_b = sizeof(bool);
|
||||
expect_d_eq(mallctl("background_thread", NULL, NULL, &enable, sz_b), 0,
|
||||
"Failed to enable background threads");
|
||||
|
|
@ -75,16 +79,18 @@ TEST_BEGIN(test_max_background_threads) {
|
|||
size_t new_max_thds = max_n_thds - 1;
|
||||
if (new_max_thds > 0) {
|
||||
expect_d_eq(mallctl("max_background_threads", NULL, NULL,
|
||||
&new_max_thds, sz_m), 0,
|
||||
"Failed to set max background threads");
|
||||
&new_max_thds, sz_m),
|
||||
0, "Failed to set max background threads");
|
||||
expect_zu_eq(n_background_threads, new_max_thds,
|
||||
"Number of background threads should decrease by 1.\n");
|
||||
}
|
||||
new_max_thds = 1;
|
||||
expect_d_eq(mallctl("max_background_threads", NULL, NULL, &new_max_thds,
|
||||
sz_m), 0, "Failed to set max background threads");
|
||||
expect_d_ne(mallctl("max_background_threads", NULL, NULL, &size_zero,
|
||||
sz_m), 0, "Should not allow zero background threads");
|
||||
expect_d_eq(
|
||||
mallctl("max_background_threads", NULL, NULL, &new_max_thds, sz_m),
|
||||
0, "Failed to set max background threads");
|
||||
expect_d_ne(
|
||||
mallctl("max_background_threads", NULL, NULL, &size_zero, sz_m), 0,
|
||||
"Should not allow zero background threads");
|
||||
expect_zu_eq(n_background_threads, new_max_thds,
|
||||
"Number of background threads should be 1.\n");
|
||||
}
|
||||
|
|
@ -92,7 +98,5 @@ TEST_END
|
|||
|
||||
int
|
||||
main(void) {
|
||||
return test_no_reentrancy(
|
||||
test_deferred,
|
||||
test_max_background_threads);
|
||||
return test_no_reentrancy(test_deferred, test_max_background_threads);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue