summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Svetlitski <svetlitski@meta.com>2023-05-08 12:37:18 -0700
committerQi Wang <interwq@gmail.com>2023-05-08 15:00:02 -0700
commit70344a2d38eb71a162ea19d1a4fee8f0d168588b (patch)
tree27bfb946e19fa227284cbd4dde467ace353cde0a
parent6841110bd6ed17b32a5fed90c53c64555366a792 (diff)
downloadjemalloc-70344a2d38eb71a162ea19d1a4fee8f0d168588b.tar.gz
Make eligible functions `static`
The codebase is already very disciplined in making any function which can be `static`, but there are a few that appear to have slipped through the cracks.
-rw-r--r--include/jemalloc/internal/extent.h2
-rw-r--r--src/decay.c2
-rw-r--r--src/extent.c4
-rw-r--r--src/hpa.c2
-rw-r--r--test/unit/bit_util.c4
-rw-r--r--test/unit/double_free.c7
-rw-r--r--test/unit/nstime.c2
-rw-r--r--test/unit/pa.c3
-rw-r--r--test/unit/size_check.c4
9 files changed, 16 insertions, 14 deletions
diff --git a/include/jemalloc/internal/extent.h b/include/jemalloc/internal/extent.h
index 1d51d410..367793db 100644
--- a/include/jemalloc/internal/extent.h
+++ b/include/jemalloc/internal/extent.h
@@ -44,8 +44,6 @@ void extent_destroy_wrapper(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
edata_t *edata);
bool extent_commit_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
size_t offset, size_t length);
-bool extent_decommit_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
- size_t offset, size_t length);
bool extent_purge_lazy_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
size_t offset, size_t length);
bool extent_purge_forced_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
diff --git a/src/decay.c b/src/decay.c
index d801b2bc..dd107a34 100644
--- a/src/decay.c
+++ b/src/decay.c
@@ -14,7 +14,7 @@ static const uint64_t h_steps[SMOOTHSTEP_NSTEPS] = {
* Generate a new deadline that is uniformly random within the next epoch after
* the current one.
*/
-void
+static void
decay_deadline_init(decay_t *decay) {
nstime_copy(&decay->deadline, &decay->epoch);
nstime_add(&decay->deadline, &decay->interval);
diff --git a/src/extent.c b/src/extent.c
index cf3d1f31..3374dd58 100644
--- a/src/extent.c
+++ b/src/extent.c
@@ -43,6 +43,8 @@ static edata_t *extent_try_coalesce(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks,
static edata_t *extent_alloc_retained(tsdn_t *tsdn, pac_t *pac,
ehooks_t *ehooks, edata_t *expand_edata, size_t size, size_t alignment,
bool zero, bool *commit, bool guarded);
+static bool extent_decommit_wrapper(tsdn_t *tsdn, ehooks_t *ehooks,
+ edata_t *edata, size_t offset, size_t length);
/******************************************************************************/
@@ -1118,7 +1120,7 @@ extent_commit_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
/* growing_retained */ false);
}
-bool
+static bool
extent_decommit_wrapper(tsdn_t *tsdn, ehooks_t *ehooks, edata_t *edata,
size_t offset, size_t length) {
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
diff --git a/src/hpa.c b/src/hpa.c
index 1e736ad4..7462025c 100644
--- a/src/hpa.c
+++ b/src/hpa.c
@@ -83,7 +83,7 @@ hpa_alloc_ps(tsdn_t *tsdn, hpa_central_t *central) {
CACHELINE);
}
-hpdata_t *
+static hpdata_t *
hpa_central_extract(tsdn_t *tsdn, hpa_central_t *central, size_t size,
bool *oom) {
/* Don't yet support big allocations; these should get filtered out. */
diff --git a/test/unit/bit_util.c b/test/unit/bit_util.c
index 7d31b210..295abb1b 100644
--- a/test/unit/bit_util.c
+++ b/test/unit/bit_util.c
@@ -48,7 +48,7 @@ TEST_BEGIN(test_pow2_ceil_zu) {
}
TEST_END
-void
+static void
expect_lg_ceil_range(size_t input, unsigned answer) {
if (input == 1) {
expect_u_eq(0, answer, "Got %u as lg_ceil of 1", answer);
@@ -60,7 +60,7 @@ expect_lg_ceil_range(size_t input, unsigned answer) {
"Got %u as lg_ceil of %zu", answer, input);
}
-void
+static void
expect_lg_floor_range(size_t input, unsigned answer) {
if (input == 1) {
expect_u_eq(0, answer, "Got %u as lg_floor of 1", answer);
diff --git a/test/unit/double_free.c b/test/unit/double_free.c
index e73efe71..f1e50cd2 100644
--- a/test/unit/double_free.c
+++ b/test/unit/double_free.c
@@ -9,19 +9,20 @@ void fake_abort(const char *message) {
fake_abort_called = true;
}
-void
+static void
test_double_free_pre(void) {
safety_check_set_abort(&fake_abort);
fake_abort_called = false;
}
-void
+static void
test_double_free_post() {
expect_b_eq(fake_abort_called, true, "Double-free check didn't fire.");
safety_check_set_abort(NULL);
}
-bool tcache_enabled() {
+static bool
+tcache_enabled() {
bool enabled;
size_t sz = sizeof(enabled);
assert_d_eq(
diff --git a/test/unit/nstime.c b/test/unit/nstime.c
index 56238ab3..e7e11e61 100644
--- a/test/unit/nstime.c
+++ b/test/unit/nstime.c
@@ -201,7 +201,7 @@ TEST_BEGIN(test_nstime_divide) {
}
TEST_END
-void
+static void
test_nstime_since_once(nstime_t *t) {
nstime_t old_t;
nstime_copy(&old_t, t);
diff --git a/test/unit/pa.c b/test/unit/pa.c
index b1e2f6e9..d44bb95c 100644
--- a/test/unit/pa.c
+++ b/test/unit/pa.c
@@ -48,7 +48,8 @@ struct test_data_s {
extent_hooks_t hooks;
};
-test_data_t *init_test_data(ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms) {
+static test_data_t *
+init_test_data(ssize_t dirty_decay_ms, ssize_t muzzy_decay_ms) {
test_data_t *test_data = calloc(1, sizeof(test_data_t));
assert_ptr_not_null(test_data, "");
init_test_extent_hooks(&test_data->hooks);
diff --git a/test/unit/size_check.c b/test/unit/size_check.c
index accdc405..3cb3bc9c 100644
--- a/test/unit/size_check.c
+++ b/test/unit/size_check.c
@@ -14,7 +14,7 @@ void fake_abort(const char *message) {
#define LARGE_SIZE1 SC_LARGE_MINCLASS
#define LARGE_SIZE2 (LARGE_SIZE1 * 2)
-void *
+static void *
test_invalid_size_pre(size_t sz) {
safety_check_set_abort(&fake_abort);
@@ -25,7 +25,7 @@ test_invalid_size_pre(size_t sz) {
return ptr;
}
-void
+static void
test_invalid_size_post(void) {
expect_true(fake_abort_called, "Safety check didn't fire");
safety_check_set_abort(NULL);