aboutsummaryrefslogtreecommitdiffstats
path: root/src/large.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-05-01 23:10:42 -0700
committerJason Evans <jasone@canonware.com>2017-05-11 23:06:54 -0700
commita268af50857f0a4d139f26c66d22debbfae7a674 (patch)
tree1926c8d0f97d00e518149c57dbf63e1ecfb85862 /src/large.c
parentb3b033eefd7892f0bed7fc30f431016660b44918 (diff)
downloadplatform_external_jemalloc_new-a268af50857f0a4d139f26c66d22debbfae7a674.tar.gz
platform_external_jemalloc_new-a268af50857f0a4d139f26c66d22debbfae7a674.tar.bz2
platform_external_jemalloc_new-a268af50857f0a4d139f26c66d22debbfae7a674.zip
Stop depending on JEMALLOC_N() for function interception during testing.
Instead, always define function pointers for interceptable functions, but mark them const unless testing, so that the compiler can optimize out the pointer dereferences.
Diffstat (limited to 'src/large.c')
-rw-r--r--src/large.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/large.c b/src/large.c
index f657ccbe..ed73dc22 100644
--- a/src/large.c
+++ b/src/large.c
@@ -68,26 +68,14 @@ large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
return extent_addr_get(extent);
}
-#ifdef JEMALLOC_JET
-#undef large_dalloc_junk
-#define large_dalloc_junk JEMALLOC_N(n_large_dalloc_junk)
-#endif
-void
-large_dalloc_junk(void *ptr, size_t size) {
+static void
+large_dalloc_junk_impl(void *ptr, size_t size) {
memset(ptr, JEMALLOC_FREE_JUNK, size);
}
-#ifdef JEMALLOC_JET
-#undef large_dalloc_junk
-#define large_dalloc_junk JEMALLOC_N(large_dalloc_junk)
-large_dalloc_junk_t *large_dalloc_junk = JEMALLOC_N(n_large_dalloc_junk);
-#endif
-
-#ifdef JEMALLOC_JET
-#undef large_dalloc_maybe_junk
-#define large_dalloc_maybe_junk JEMALLOC_N(n_large_dalloc_maybe_junk)
-#endif
-void
-large_dalloc_maybe_junk(void *ptr, size_t size) {
+large_dalloc_junk_t *JET_MUTABLE large_dalloc_junk = large_dalloc_junk_impl;
+
+static void
+large_dalloc_maybe_junk_impl(void *ptr, size_t size) {
if (config_fill && have_dss && unlikely(opt_junk_free)) {
/*
* Only bother junk filling if the extent isn't about to be
@@ -98,12 +86,8 @@ large_dalloc_maybe_junk(void *ptr, size_t size) {
}
}
}
-#ifdef JEMALLOC_JET
-#undef large_dalloc_maybe_junk
-#define large_dalloc_maybe_junk JEMALLOC_N(large_dalloc_maybe_junk)
-large_dalloc_maybe_junk_t *large_dalloc_maybe_junk =
- JEMALLOC_N(n_large_dalloc_maybe_junk);
-#endif
+large_dalloc_maybe_junk_t *JET_MUTABLE large_dalloc_maybe_junk =
+ large_dalloc_maybe_junk_impl;
static bool
large_ralloc_no_move_shrink(tsdn_t *tsdn, extent_t *extent, size_t usize) {