Reformat the codebase with the clang-format 18.

This commit is contained in:
guangli-dai 2025-06-13 12:31:12 -07:00 committed by Guangli Dai
parent ae4e729d15
commit 34f359e0ca
346 changed files with 18286 additions and 17770 deletions

View file

@ -11,14 +11,10 @@
/* NOLINTNEXTLINE(performance-no-int-to-ptr) */
#define SBRK_INVALID ((void *)-1)
const char *opt_dss = DSS_DEFAULT;
const char *opt_dss = DSS_DEFAULT;
const char *const dss_prec_names[] = {
"disabled",
"primary",
"secondary",
"N/A"
};
const char *const dss_prec_names[] = {
"disabled", "primary", "secondary", "N/A"};
/*
* Current dss precedence default, used when creating new arenas. NB: This is
@ -26,17 +22,16 @@ const char *const dss_prec_names[] = {
* guarantee that sizeof(dss_prec_t) is the same as sizeof(unsigned), and we use
* atomic operations to synchronize the setting.
*/
static atomic_u_t dss_prec_default = ATOMIC_INIT(
(unsigned)DSS_PREC_DEFAULT);
static atomic_u_t dss_prec_default = ATOMIC_INIT((unsigned)DSS_PREC_DEFAULT);
/* Base address of the DSS. */
static void *dss_base;
static void *dss_base;
/* Atomic boolean indicating whether a thread is currently extending DSS. */
static atomic_b_t dss_extending;
static atomic_b_t dss_extending;
/* Atomic boolean indicating whether the DSS is exhausted. */
static atomic_b_t dss_exhausted;
static atomic_b_t dss_exhausted;
/* Atomic current upper limit on DSS addresses. */
static atomic_p_t dss_max;
static atomic_p_t dss_max;
/******************************************************************************/
@ -76,7 +71,7 @@ extent_dss_extending_start(void) {
while (true) {
bool expected = false;
if (atomic_compare_exchange_weak_b(&dss_extending, &expected,
true, ATOMIC_ACQ_REL, ATOMIC_RELAXED)) {
true, ATOMIC_ACQ_REL, ATOMIC_RELAXED)) {
break;
}
spin_adaptive(&spinner);
@ -143,24 +138,24 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size,
goto label_oom;
}
bool head_state = opt_retain ? EXTENT_IS_HEAD :
EXTENT_NOT_HEAD;
bool head_state = opt_retain ? EXTENT_IS_HEAD
: EXTENT_NOT_HEAD;
/*
* Compute how much page-aligned gap space (if any) is
* necessary to satisfy alignment. This space can be
* recycled for later use.
*/
void *gap_addr_page = ALIGNMENT_ADDR2CEILING(max_cur,
PAGE);
void *gap_addr_page = ALIGNMENT_ADDR2CEILING(
max_cur, PAGE);
void *ret = ALIGNMENT_ADDR2CEILING(
gap_addr_page, alignment);
size_t gap_size_page = (uintptr_t)ret -
(uintptr_t)gap_addr_page;
size_t gap_size_page = (uintptr_t)ret
- (uintptr_t)gap_addr_page;
if (gap_size_page != 0) {
edata_init(gap, arena_ind_get(arena),
gap_addr_page, gap_size_page, false,
SC_NSIZES, extent_sn_next(
&arena->pa_shard.pac),
SC_NSIZES,
extent_sn_next(&arena->pa_shard.pac),
extent_state_active, false, true,
EXTENT_PAI_PAC, head_state);
}
@ -169,25 +164,25 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size,
* allocation space.
*/
void *dss_next = (void *)((byte_t *)ret + size);
if ((uintptr_t)ret < (uintptr_t)max_cur ||
(uintptr_t)dss_next < (uintptr_t)max_cur) {
if ((uintptr_t)ret < (uintptr_t)max_cur
|| (uintptr_t)dss_next < (uintptr_t)max_cur) {
goto label_oom; /* Wrap-around. */
}
/* Compute the increment, including subpage bytes. */
void *gap_addr_subpage = max_cur;
size_t gap_size_subpage = (uintptr_t)ret -
(uintptr_t)gap_addr_subpage;
void *gap_addr_subpage = max_cur;
size_t gap_size_subpage = (uintptr_t)ret
- (uintptr_t)gap_addr_subpage;
intptr_t incr = gap_size_subpage + size;
assert((uintptr_t)max_cur + incr == (uintptr_t)ret +
size);
assert(
(uintptr_t)max_cur + incr == (uintptr_t)ret + size);
/* Try to allocate. */
void *dss_prev = extent_dss_sbrk(incr);
if (dss_prev == max_cur) {
/* Success. */
atomic_store_p(&dss_max, dss_next,
ATOMIC_RELEASE);
atomic_store_p(
&dss_max, dss_next, ATOMIC_RELEASE);
extent_dss_extending_finish();
if (gap_size_page != 0) {
@ -203,17 +198,16 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size,
*commit = pages_decommit(ret, size);
}
if (*zero && *commit) {
edata_t edata = {0};
edata_t edata = {0};
ehooks_t *ehooks = arena_get_ehooks(
arena);
edata_init(&edata,
arena_ind_get(arena), ret, size,
size, false, SC_NSIZES,
edata_init(&edata, arena_ind_get(arena),
ret, size, size, false, SC_NSIZES,
extent_state_active, false, true,
EXTENT_PAI_PAC, head_state);
if (extent_purge_forced_wrapper(tsdn,
ehooks, &edata, 0, size)) {
ehooks, &edata, 0, size)) {
memset(ret, 0, size);
}
}
@ -225,8 +219,8 @@ extent_alloc_dss(tsdn_t *tsdn, arena_t *arena, void *new_addr, size_t size,
*/
if (dss_prev == SBRK_INVALID) {
/* OOM. */
atomic_store_b(&dss_exhausted, true,
ATOMIC_RELEASE);
atomic_store_b(
&dss_exhausted, true, ATOMIC_RELEASE);
goto label_oom;
}
}
@ -239,16 +233,16 @@ label_oom:
static bool
extent_in_dss_helper(void *addr, void *max) {
return ((uintptr_t)addr >= (uintptr_t)dss_base && (uintptr_t)addr <
(uintptr_t)max);
return ((uintptr_t)addr >= (uintptr_t)dss_base
&& (uintptr_t)addr < (uintptr_t)max);
}
bool
extent_in_dss(void *addr) {
cassert(have_dss);
return extent_in_dss_helper(addr, atomic_load_p(&dss_max,
ATOMIC_ACQUIRE));
return extent_in_dss_helper(
addr, atomic_load_p(&dss_max, ATOMIC_ACQUIRE));
}
bool
@ -257,14 +251,14 @@ extent_dss_mergeable(void *addr_a, void *addr_b) {
cassert(have_dss);
if ((uintptr_t)addr_a < (uintptr_t)dss_base && (uintptr_t)addr_b <
(uintptr_t)dss_base) {
if ((uintptr_t)addr_a < (uintptr_t)dss_base
&& (uintptr_t)addr_b < (uintptr_t)dss_base) {
return true;
}
max = atomic_load_p(&dss_max, ATOMIC_ACQUIRE);
return (extent_in_dss_helper(addr_a, max) ==
extent_in_dss_helper(addr_b, max));
return (extent_in_dss_helper(addr_a, max)
== extent_in_dss_helper(addr_b, max));
}
void
@ -273,7 +267,8 @@ extent_dss_boot(void) {
dss_base = extent_dss_sbrk(0);
atomic_store_b(&dss_extending, false, ATOMIC_RELAXED);
atomic_store_b(&dss_exhausted, dss_base == SBRK_INVALID, ATOMIC_RELAXED);
atomic_store_b(
&dss_exhausted, dss_base == SBRK_INVALID, ATOMIC_RELAXED);
atomic_store_p(&dss_max, dss_base, ATOMIC_RELAXED);
}