mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-07 12:17:28 +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,34 +1,34 @@
|
|||
#include "test/jemalloc_test.h"
|
||||
|
||||
static void
|
||||
mallctl_thread_name_get_impl(const char *thread_name_expected, const char *func,
|
||||
int line) {
|
||||
mallctl_thread_name_get_impl(
|
||||
const char *thread_name_expected, const char *func, int line) {
|
||||
const char *thread_name_old;
|
||||
size_t sz;
|
||||
size_t sz;
|
||||
|
||||
sz = sizeof(thread_name_old);
|
||||
expect_d_eq(mallctl("thread.prof.name", (void *)&thread_name_old, &sz,
|
||||
NULL, 0), 0,
|
||||
"%s():%d: Unexpected mallctl failure reading thread.prof.name",
|
||||
expect_d_eq(
|
||||
mallctl("thread.prof.name", (void *)&thread_name_old, &sz, NULL, 0),
|
||||
0, "%s():%d: Unexpected mallctl failure reading thread.prof.name",
|
||||
func, line);
|
||||
expect_str_eq(thread_name_old, thread_name_expected,
|
||||
"%s():%d: Unexpected thread.prof.name value", func, line);
|
||||
}
|
||||
|
||||
static void
|
||||
mallctl_thread_name_set_impl(const char *thread_name, const char *func,
|
||||
int line) {
|
||||
mallctl_thread_name_set_impl(
|
||||
const char *thread_name, const char *func, int line) {
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL,
|
||||
(void *)&thread_name, sizeof(thread_name)), 0,
|
||||
"%s():%d: Unexpected mallctl failure writing thread.prof.name",
|
||||
(void *)&thread_name, sizeof(thread_name)),
|
||||
0, "%s():%d: Unexpected mallctl failure writing thread.prof.name",
|
||||
func, line);
|
||||
mallctl_thread_name_get_impl(thread_name, func, line);
|
||||
}
|
||||
|
||||
#define mallctl_thread_name_get(a) \
|
||||
#define mallctl_thread_name_get(a) \
|
||||
mallctl_thread_name_get_impl(a, __func__, __LINE__)
|
||||
|
||||
#define mallctl_thread_name_set(a) \
|
||||
#define mallctl_thread_name_set(a) \
|
||||
mallctl_thread_name_set_impl(a, __func__, __LINE__)
|
||||
|
||||
TEST_BEGIN(test_prof_thread_name_validation) {
|
||||
|
|
@ -44,34 +44,35 @@ TEST_BEGIN(test_prof_thread_name_validation) {
|
|||
char long_name[] =
|
||||
"test case longer than expected; test case longer than expected";
|
||||
expect_zu_gt(strlen(long_name), PROF_THREAD_NAME_MAX_LEN,
|
||||
"Long test name not long enough");
|
||||
"Long test name not long enough");
|
||||
const char *test_name_long = long_name;
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL,
|
||||
(void *)&test_name_long, sizeof(test_name_long)), 0,
|
||||
"Unexpected mallctl failure from thread.prof.name");
|
||||
(void *)&test_name_long, sizeof(test_name_long)),
|
||||
0, "Unexpected mallctl failure from thread.prof.name");
|
||||
/* Long name cut to match. */
|
||||
long_name[PROF_THREAD_NAME_MAX_LEN - 1] = '\0';
|
||||
mallctl_thread_name_get(test_name_long);
|
||||
|
||||
/* NULL input shouldn't be allowed. */
|
||||
const char *test_name2 = NULL;
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL,
|
||||
(void *)&test_name2, sizeof(test_name2)), EINVAL,
|
||||
"Unexpected mallctl result writing to thread.prof.name");
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL, (void *)&test_name2,
|
||||
sizeof(test_name2)),
|
||||
EINVAL, "Unexpected mallctl result writing to thread.prof.name");
|
||||
|
||||
/* '\n' shouldn't be allowed. */
|
||||
const char *test_name3 = "test\ncase";
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL,
|
||||
(void *)&test_name3, sizeof(test_name3)), EINVAL,
|
||||
expect_d_eq(mallctl("thread.prof.name", NULL, NULL, (void *)&test_name3,
|
||||
sizeof(test_name3)),
|
||||
EINVAL,
|
||||
"Unexpected mallctl result writing \"%s\" to thread.prof.name",
|
||||
test_name3);
|
||||
|
||||
/* Simultaneous read/write shouldn't be allowed. */
|
||||
const char *thread_name_old;
|
||||
size_t sz = sizeof(thread_name_old);
|
||||
size_t sz = sizeof(thread_name_old);
|
||||
expect_d_eq(mallctl("thread.prof.name", (void *)&thread_name_old, &sz,
|
||||
(void *)&test_name1, sizeof(test_name1)), EPERM,
|
||||
"Unexpected mallctl result from thread.prof.name");
|
||||
(void *)&test_name1, sizeof(test_name1)),
|
||||
EPERM, "Unexpected mallctl result from thread.prof.name");
|
||||
|
||||
mallctl_thread_name_set("");
|
||||
}
|
||||
|
|
@ -80,7 +81,7 @@ TEST_END
|
|||
static void *
|
||||
thd_start(void *varg) {
|
||||
unsigned thd_ind = *(unsigned *)varg;
|
||||
char thread_name[16] = "";
|
||||
char thread_name[16] = "";
|
||||
unsigned i;
|
||||
|
||||
malloc_snprintf(thread_name, sizeof(thread_name), "thread %u", thd_ind);
|
||||
|
|
@ -107,7 +108,7 @@ TEST_BEGIN(test_prof_thread_name_threaded) {
|
|||
test_skip_if(opt_prof_sys_thread_name);
|
||||
|
||||
#define NTHREADS 4
|
||||
thd_t thds[NTHREADS];
|
||||
thd_t thds[NTHREADS];
|
||||
unsigned thd_args[NTHREADS];
|
||||
unsigned i;
|
||||
|
||||
|
|
@ -125,6 +126,5 @@ TEST_END
|
|||
int
|
||||
main(void) {
|
||||
return test(
|
||||
test_prof_thread_name_validation,
|
||||
test_prof_thread_name_threaded);
|
||||
test_prof_thread_name_validation, test_prof_thread_name_threaded);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue