mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-07 20:54:25 +03:00
parent
f408643a4c
commit
c0cc5db871
110 changed files with 706 additions and 707 deletions
20
src/arena.c
20
src/arena.c
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_ARENA_C_
|
||||
#define JEMALLOC_ARENA_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -8,10 +8,10 @@ ssize_t opt_decay_time = DECAY_TIME_DEFAULT;
|
|||
static ssize_t decay_time_default;
|
||||
|
||||
const arena_bin_info_t arena_bin_info[NBINS] = {
|
||||
#define BIN_INFO_bin_yes(reg_size, slab_size, nregs) \
|
||||
#define BIN_INFO_bin_yes(reg_size, slab_size, nregs) \
|
||||
{reg_size, slab_size, nregs, BITMAP_INFO_INITIALIZER(nregs)},
|
||||
#define BIN_INFO_bin_no(reg_size, slab_size, nregs)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, \
|
||||
#define BIN_INFO_bin_no(reg_size, slab_size, nregs)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, \
|
||||
lg_delta_lookup) \
|
||||
BIN_INFO_bin_##bin((1U<<lg_grp) + (ndelta<<lg_delta), \
|
||||
(pgs << LG_PAGE), (pgs << LG_PAGE) / ((1U<<lg_grp) + \
|
||||
|
|
@ -142,13 +142,13 @@ arena_slab_regind(extent_t *slab, szind_t binind, const void *ptr) {
|
|||
/* Avoid doing division with a variable divisor. */
|
||||
diff = (size_t)((uintptr_t)ptr - (uintptr_t)extent_addr_get(slab));
|
||||
switch (binind) {
|
||||
#define REGIND_bin_yes(index, reg_size) \
|
||||
#define REGIND_bin_yes(index, reg_size) \
|
||||
case index: \
|
||||
regind = diff / (reg_size); \
|
||||
assert(diff == regind * (reg_size)); \
|
||||
break;
|
||||
#define REGIND_bin_no(index, reg_size)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, \
|
||||
#define REGIND_bin_no(index, reg_size)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, \
|
||||
lg_delta_lookup) \
|
||||
REGIND_bin_##bin(index, (1U<<lg_grp) + (ndelta<<lg_delta))
|
||||
SIZE_CLASSES
|
||||
|
|
@ -389,7 +389,7 @@ arena_decay_deadline_reached(const arena_t *arena, const nstime_t *time) {
|
|||
static size_t
|
||||
arena_decay_backlog_npages_limit(const arena_t *arena) {
|
||||
static const uint64_t h_steps[] = {
|
||||
#define STEP(step, h, x, y) \
|
||||
#define STEP(step, h, x, y) \
|
||||
h,
|
||||
SMOOTHSTEP
|
||||
#undef STEP
|
||||
|
|
@ -1138,7 +1138,7 @@ arena_alloc_junk_small(void *ptr, const arena_bin_info_t *bin_info, bool zero) {
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef arena_dalloc_junk_small
|
||||
#define arena_dalloc_junk_small JEMALLOC_N(n_arena_dalloc_junk_small)
|
||||
#define arena_dalloc_junk_small JEMALLOC_N(n_arena_dalloc_junk_small)
|
||||
#endif
|
||||
void
|
||||
arena_dalloc_junk_small(void *ptr, const arena_bin_info_t *bin_info) {
|
||||
|
|
@ -1146,7 +1146,7 @@ arena_dalloc_junk_small(void *ptr, const arena_bin_info_t *bin_info) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef arena_dalloc_junk_small
|
||||
#define arena_dalloc_junk_small JEMALLOC_N(arena_dalloc_junk_small)
|
||||
#define arena_dalloc_junk_small JEMALLOC_N(arena_dalloc_junk_small)
|
||||
arena_dalloc_junk_small_t *arena_dalloc_junk_small =
|
||||
JEMALLOC_N(n_arena_dalloc_junk_small);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_ATOMIC_C_
|
||||
#define JEMALLOC_ATOMIC_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_BASE_C_
|
||||
#define JEMALLOC_BASE_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_BITMAP_C_
|
||||
#define JEMALLOC_BITMAP_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
* respectively.
|
||||
*
|
||||
******************************************************************************/
|
||||
#define JEMALLOC_CKH_C_
|
||||
#define JEMALLOC_CKH_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
42
src/ctl.c
42
src/ctl.c
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_CTL_C_
|
||||
#define JEMALLOC_CTL_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -36,11 +36,11 @@ ctl_indexed_node(const ctl_node_t *node) {
|
|||
/******************************************************************************/
|
||||
/* Function prototypes for non-inline static functions. */
|
||||
|
||||
#define CTL_PROTO(n) \
|
||||
#define CTL_PROTO(n) \
|
||||
static int n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, \
|
||||
void *oldp, size_t *oldlenp, void *newp, size_t newlen);
|
||||
|
||||
#define INDEX_PROTO(n) \
|
||||
#define INDEX_PROTO(n) \
|
||||
static const ctl_named_node_t *n##_index(tsdn_t *tsdn, \
|
||||
const size_t *mib, size_t miblen, size_t i);
|
||||
|
||||
|
|
@ -173,20 +173,20 @@ CTL_PROTO(stats_retained)
|
|||
/* mallctl tree. */
|
||||
|
||||
/* Maximum tree depth. */
|
||||
#define CTL_MAX_DEPTH 6
|
||||
#define CTL_MAX_DEPTH 6
|
||||
|
||||
#define NAME(n) {true}, n
|
||||
#define CHILD(t, c) \
|
||||
#define NAME(n) {true}, n
|
||||
#define CHILD(t, c) \
|
||||
sizeof(c##_node) / sizeof(ctl_##t##_node_t), \
|
||||
(ctl_node_t *)c##_node, \
|
||||
NULL
|
||||
#define CTL(c) 0, NULL, c##_ctl
|
||||
#define CTL(c) 0, NULL, c##_ctl
|
||||
|
||||
/*
|
||||
* Only handles internal indexed nodes, since there are currently no external
|
||||
* ones.
|
||||
*/
|
||||
#define INDEX(i) {false}, i##_index
|
||||
#define INDEX(i) {false}, i##_index
|
||||
|
||||
static const ctl_named_node_t thread_tcache_node[] = {
|
||||
{NAME("enabled"), CTL(thread_tcache_enabled)},
|
||||
|
|
@ -1045,21 +1045,21 @@ ctl_postfork_child(tsdn_t *tsdn) {
|
|||
/******************************************************************************/
|
||||
/* *_ctl() functions. */
|
||||
|
||||
#define READONLY() do { \
|
||||
#define READONLY() do { \
|
||||
if (newp != NULL || newlen != 0) { \
|
||||
ret = EPERM; \
|
||||
goto label_return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITEONLY() do { \
|
||||
#define WRITEONLY() do { \
|
||||
if (oldp != NULL || oldlenp != NULL) { \
|
||||
ret = EPERM; \
|
||||
goto label_return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define READ_XOR_WRITE() do { \
|
||||
#define READ_XOR_WRITE() do { \
|
||||
if ((oldp != NULL && oldlenp != NULL) && (newp != NULL || \
|
||||
newlen != 0)) { \
|
||||
ret = EPERM; \
|
||||
|
|
@ -1067,7 +1067,7 @@ ctl_postfork_child(tsdn_t *tsdn) {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define READ(v, t) do { \
|
||||
#define READ(v, t) do { \
|
||||
if (oldp != NULL && oldlenp != NULL) { \
|
||||
if (*oldlenp != sizeof(t)) { \
|
||||
size_t copylen = (sizeof(t) <= *oldlenp) \
|
||||
|
|
@ -1080,7 +1080,7 @@ ctl_postfork_child(tsdn_t *tsdn) {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define WRITE(v, t) do { \
|
||||
#define WRITE(v, t) do { \
|
||||
if (newp != NULL) { \
|
||||
if (newlen != sizeof(t)) { \
|
||||
ret = EINVAL; \
|
||||
|
|
@ -1090,7 +1090,7 @@ ctl_postfork_child(tsdn_t *tsdn) {
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define MIB_UNSIGNED(v, i) do { \
|
||||
#define MIB_UNSIGNED(v, i) do { \
|
||||
if (mib[i] > UINT_MAX) { \
|
||||
ret = EFAULT; \
|
||||
goto label_return; \
|
||||
|
|
@ -1102,7 +1102,7 @@ ctl_postfork_child(tsdn_t *tsdn) {
|
|||
* There's a lot of code duplication in the following macros due to limitations
|
||||
* in how nested cpp macros are expanded.
|
||||
*/
|
||||
#define CTL_RO_CLGEN(c, l, n, v, t) \
|
||||
#define CTL_RO_CLGEN(c, l, n, v, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1127,7 +1127,7 @@ label_return: \
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define CTL_RO_CGEN(c, n, v, t) \
|
||||
#define CTL_RO_CGEN(c, n, v, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1148,7 +1148,7 @@ label_return: \
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define CTL_RO_GEN(n, v, t) \
|
||||
#define CTL_RO_GEN(n, v, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1170,7 +1170,7 @@ label_return: \
|
|||
* ctl_mtx is not acquired, under the assumption that no pertinent data will
|
||||
* mutate during the call.
|
||||
*/
|
||||
#define CTL_RO_NL_CGEN(c, n, v, t) \
|
||||
#define CTL_RO_NL_CGEN(c, n, v, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1189,7 +1189,7 @@ label_return: \
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define CTL_RO_NL_GEN(n, v, t) \
|
||||
#define CTL_RO_NL_GEN(n, v, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1205,7 +1205,7 @@ label_return: \
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define CTL_TSD_RO_NL_CGEN(c, n, m, t) \
|
||||
#define CTL_TSD_RO_NL_CGEN(c, n, m, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
@ -1224,7 +1224,7 @@ label_return: \
|
|||
return ret; \
|
||||
}
|
||||
|
||||
#define CTL_RO_CONFIG_GEN(n, t) \
|
||||
#define CTL_RO_CONFIG_GEN(n, t) \
|
||||
static int \
|
||||
n##_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp, \
|
||||
size_t *oldlenp, void *newp, size_t newlen) { \
|
||||
|
|
|
|||
10
src/extent.c
10
src/extent.c
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_EXTENT_C_
|
||||
#define JEMALLOC_EXTENT_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -118,7 +118,7 @@ extent_hooks_assure_initialized(arena_t *arena,
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef extent_size_quantize_floor
|
||||
#define extent_size_quantize_floor JEMALLOC_N(n_extent_size_quantize_floor)
|
||||
#define extent_size_quantize_floor JEMALLOC_N(n_extent_size_quantize_floor)
|
||||
#endif
|
||||
size_t
|
||||
extent_size_quantize_floor(size_t size) {
|
||||
|
|
@ -147,14 +147,14 @@ extent_size_quantize_floor(size_t size) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef extent_size_quantize_floor
|
||||
#define extent_size_quantize_floor JEMALLOC_N(extent_size_quantize_floor)
|
||||
#define extent_size_quantize_floor JEMALLOC_N(extent_size_quantize_floor)
|
||||
extent_size_quantize_t *extent_size_quantize_floor =
|
||||
JEMALLOC_N(n_extent_size_quantize_floor);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef extent_size_quantize_ceil
|
||||
#define extent_size_quantize_ceil JEMALLOC_N(n_extent_size_quantize_ceil)
|
||||
#define extent_size_quantize_ceil JEMALLOC_N(n_extent_size_quantize_ceil)
|
||||
#endif
|
||||
size_t
|
||||
extent_size_quantize_ceil(size_t size) {
|
||||
|
|
@ -180,7 +180,7 @@ extent_size_quantize_ceil(size_t size) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef extent_size_quantize_ceil
|
||||
#define extent_size_quantize_ceil JEMALLOC_N(extent_size_quantize_ceil)
|
||||
#define extent_size_quantize_ceil JEMALLOC_N(extent_size_quantize_ceil)
|
||||
extent_size_quantize_t *extent_size_quantize_ceil =
|
||||
JEMALLOC_N(n_extent_size_quantize_ceil);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_EXTENT_DSS_C_
|
||||
#define JEMALLOC_EXTENT_DSS_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
/******************************************************************************/
|
||||
/* Data. */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_EXTENT_MMAP_C_
|
||||
#define JEMALLOC_EXTENT_MMAP_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_HASH_C_
|
||||
#define JEMALLOC_HASH_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_C_
|
||||
#define JEMALLOC_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -84,10 +84,10 @@ static uint8_t malloc_slow_flags;
|
|||
|
||||
JEMALLOC_ALIGNED(CACHELINE)
|
||||
const size_t pind2sz_tab[NPSIZES+1] = {
|
||||
#define PSZ_yes(lg_grp, ndelta, lg_delta) \
|
||||
#define PSZ_yes(lg_grp, ndelta, lg_delta) \
|
||||
(((ZU(1)<<lg_grp) + (ZU(ndelta)<<lg_delta))),
|
||||
#define PSZ_no(lg_grp, ndelta, lg_delta)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
#define PSZ_no(lg_grp, ndelta, lg_delta)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
PSZ_##psz(lg_grp, ndelta, lg_delta)
|
||||
SIZE_CLASSES
|
||||
#undef PSZ_yes
|
||||
|
|
@ -98,7 +98,7 @@ const size_t pind2sz_tab[NPSIZES+1] = {
|
|||
|
||||
JEMALLOC_ALIGNED(CACHELINE)
|
||||
const size_t index2size_tab[NSIZES] = {
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
((ZU(1)<<lg_grp) + (ZU(ndelta)<<lg_delta)),
|
||||
SIZE_CLASSES
|
||||
#undef SC
|
||||
|
|
@ -108,69 +108,69 @@ JEMALLOC_ALIGNED(CACHELINE)
|
|||
const uint8_t size2index_tab[] = {
|
||||
#if LG_TINY_MIN == 0
|
||||
#warning "Dangerous LG_TINY_MIN"
|
||||
#define S2B_0(i) i,
|
||||
#define S2B_0(i) i,
|
||||
#elif LG_TINY_MIN == 1
|
||||
#warning "Dangerous LG_TINY_MIN"
|
||||
#define S2B_1(i) i,
|
||||
#define S2B_1(i) i,
|
||||
#elif LG_TINY_MIN == 2
|
||||
#warning "Dangerous LG_TINY_MIN"
|
||||
#define S2B_2(i) i,
|
||||
#define S2B_2(i) i,
|
||||
#elif LG_TINY_MIN == 3
|
||||
#define S2B_3(i) i,
|
||||
#define S2B_3(i) i,
|
||||
#elif LG_TINY_MIN == 4
|
||||
#define S2B_4(i) i,
|
||||
#define S2B_4(i) i,
|
||||
#elif LG_TINY_MIN == 5
|
||||
#define S2B_5(i) i,
|
||||
#define S2B_5(i) i,
|
||||
#elif LG_TINY_MIN == 6
|
||||
#define S2B_6(i) i,
|
||||
#define S2B_6(i) i,
|
||||
#elif LG_TINY_MIN == 7
|
||||
#define S2B_7(i) i,
|
||||
#define S2B_7(i) i,
|
||||
#elif LG_TINY_MIN == 8
|
||||
#define S2B_8(i) i,
|
||||
#define S2B_8(i) i,
|
||||
#elif LG_TINY_MIN == 9
|
||||
#define S2B_9(i) i,
|
||||
#define S2B_9(i) i,
|
||||
#elif LG_TINY_MIN == 10
|
||||
#define S2B_10(i) i,
|
||||
#define S2B_10(i) i,
|
||||
#elif LG_TINY_MIN == 11
|
||||
#define S2B_11(i) i,
|
||||
#define S2B_11(i) i,
|
||||
#else
|
||||
#error "Unsupported LG_TINY_MIN"
|
||||
#endif
|
||||
#if LG_TINY_MIN < 1
|
||||
#define S2B_1(i) S2B_0(i) S2B_0(i)
|
||||
#define S2B_1(i) S2B_0(i) S2B_0(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 2
|
||||
#define S2B_2(i) S2B_1(i) S2B_1(i)
|
||||
#define S2B_2(i) S2B_1(i) S2B_1(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 3
|
||||
#define S2B_3(i) S2B_2(i) S2B_2(i)
|
||||
#define S2B_3(i) S2B_2(i) S2B_2(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 4
|
||||
#define S2B_4(i) S2B_3(i) S2B_3(i)
|
||||
#define S2B_4(i) S2B_3(i) S2B_3(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 5
|
||||
#define S2B_5(i) S2B_4(i) S2B_4(i)
|
||||
#define S2B_5(i) S2B_4(i) S2B_4(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 6
|
||||
#define S2B_6(i) S2B_5(i) S2B_5(i)
|
||||
#define S2B_6(i) S2B_5(i) S2B_5(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 7
|
||||
#define S2B_7(i) S2B_6(i) S2B_6(i)
|
||||
#define S2B_7(i) S2B_6(i) S2B_6(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 8
|
||||
#define S2B_8(i) S2B_7(i) S2B_7(i)
|
||||
#define S2B_8(i) S2B_7(i) S2B_7(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 9
|
||||
#define S2B_9(i) S2B_8(i) S2B_8(i)
|
||||
#define S2B_9(i) S2B_8(i) S2B_8(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 10
|
||||
#define S2B_10(i) S2B_9(i) S2B_9(i)
|
||||
#define S2B_10(i) S2B_9(i) S2B_9(i)
|
||||
#endif
|
||||
#if LG_TINY_MIN < 11
|
||||
#define S2B_11(i) S2B_10(i) S2B_10(i)
|
||||
#define S2B_11(i) S2B_10(i) S2B_10(i)
|
||||
#endif
|
||||
#define S2B_no(i)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
#define S2B_no(i)
|
||||
#define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
|
||||
S2B_##lg_delta_lookup(index)
|
||||
SIZE_CLASSES
|
||||
#undef S2B_3
|
||||
|
|
@ -928,11 +928,11 @@ malloc_conf_init(void) {
|
|||
|
||||
while (*opts != '\0' && !malloc_conf_next(&opts, &k, &klen, &v,
|
||||
&vlen)) {
|
||||
#define CONF_MATCH(n) \
|
||||
#define CONF_MATCH(n) \
|
||||
(sizeof(n)-1 == klen && strncmp(n, k, klen) == 0)
|
||||
#define CONF_MATCH_VALUE(n) \
|
||||
#define CONF_MATCH_VALUE(n) \
|
||||
(sizeof(n)-1 == vlen && strncmp(n, v, vlen) == 0)
|
||||
#define CONF_HANDLE_BOOL(o, n, cont) \
|
||||
#define CONF_HANDLE_BOOL(o, n, cont) \
|
||||
if (CONF_MATCH(n)) { \
|
||||
if (CONF_MATCH_VALUE("true")) { \
|
||||
o = true; \
|
||||
|
|
@ -947,11 +947,11 @@ malloc_conf_init(void) {
|
|||
continue; \
|
||||
} \
|
||||
}
|
||||
#define CONF_MIN_no(um, min) false
|
||||
#define CONF_MIN_yes(um, min) ((um) < (min))
|
||||
#define CONF_MAX_no(um, max) false
|
||||
#define CONF_MAX_yes(um, max) ((um) > (max))
|
||||
#define CONF_HANDLE_T_U(t, o, n, min, max, check_min, check_max, clip) \
|
||||
#define CONF_MIN_no(um, min) false
|
||||
#define CONF_MIN_yes(um, min) ((um) < (min))
|
||||
#define CONF_MAX_no(um, max) false
|
||||
#define CONF_MAX_yes(um, max) ((um) > (max))
|
||||
#define CONF_HANDLE_T_U(t, o, n, min, max, check_min, check_max, clip) \
|
||||
if (CONF_MATCH(n)) { \
|
||||
uintmax_t um; \
|
||||
char *end; \
|
||||
|
|
@ -989,14 +989,14 @@ malloc_conf_init(void) {
|
|||
} \
|
||||
continue; \
|
||||
}
|
||||
#define CONF_HANDLE_UNSIGNED(o, n, min, max, check_min, check_max, \
|
||||
#define CONF_HANDLE_UNSIGNED(o, n, min, max, check_min, check_max, \
|
||||
clip) \
|
||||
CONF_HANDLE_T_U(unsigned, o, n, min, max, \
|
||||
check_min, check_max, clip)
|
||||
#define CONF_HANDLE_SIZE_T(o, n, min, max, check_min, check_max, clip) \
|
||||
#define CONF_HANDLE_SIZE_T(o, n, min, max, check_min, check_max, clip) \
|
||||
CONF_HANDLE_T_U(size_t, o, n, min, max, \
|
||||
check_min, check_max, clip)
|
||||
#define CONF_HANDLE_SSIZE_T(o, n, min, max) \
|
||||
#define CONF_HANDLE_SSIZE_T(o, n, min, max) \
|
||||
if (CONF_MATCH(n)) { \
|
||||
long l; \
|
||||
char *end; \
|
||||
|
|
@ -1018,7 +1018,7 @@ malloc_conf_init(void) {
|
|||
} \
|
||||
continue; \
|
||||
}
|
||||
#define CONF_HANDLE_CHAR_P(o, n, d) \
|
||||
#define CONF_HANDLE_CHAR_P(o, n, d) \
|
||||
if (CONF_MATCH(n)) { \
|
||||
size_t cpylen = (vlen <= \
|
||||
sizeof(o)-1) ? vlen : \
|
||||
|
|
@ -2119,9 +2119,9 @@ je_valloc(size_t size) {
|
|||
* is_malloc(je_malloc) is some macro magic to detect if jemalloc_defs.h has
|
||||
* #define je_malloc malloc
|
||||
*/
|
||||
#define malloc_is_malloc 1
|
||||
#define is_malloc_(a) malloc_is_ ## a
|
||||
#define is_malloc(a) is_malloc_(a)
|
||||
#define malloc_is_malloc 1
|
||||
#define is_malloc_(a) malloc_is_ ## a
|
||||
#define is_malloc(a) is_malloc_(a)
|
||||
|
||||
#if ((is_malloc(je_malloc) == 1) && defined(JEMALLOC_GLIBC_MALLOC_HOOK))
|
||||
/*
|
||||
|
|
@ -2147,9 +2147,9 @@ JEMALLOC_EXPORT void *(*__memalign_hook)(size_t alignment, size_t size) =
|
|||
* be implemented also, so none of glibc's malloc.o functions are added to the
|
||||
* link.
|
||||
*/
|
||||
#define ALIAS(je_fn) __attribute__((alias (#je_fn), used))
|
||||
#define ALIAS(je_fn) __attribute__((alias (#je_fn), used))
|
||||
/* To force macro expansion of je_ prefix before stringification. */
|
||||
#define PREALIAS(je_fn) ALIAS(je_fn)
|
||||
#define PREALIAS(je_fn) ALIAS(je_fn)
|
||||
void *__libc_malloc(size_t size) PREALIAS(je_malloc);
|
||||
void __libc_free(void* ptr) PREALIAS(je_free);
|
||||
void *__libc_realloc(void* ptr, size_t size) PREALIAS(je_realloc);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include <mutex>
|
||||
#include <new>
|
||||
|
||||
#define JEMALLOC_CPP_CPP_
|
||||
#define JEMALLOC_CPP_CPP_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
// All operators in this file are exported.
|
||||
|
|
|
|||
10
src/large.c
10
src/large.c
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_LARGE_C_
|
||||
#define JEMALLOC_LARGE_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -63,7 +63,7 @@ large_palloc(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef large_dalloc_junk
|
||||
#define large_dalloc_junk JEMALLOC_N(n_large_dalloc_junk)
|
||||
#define large_dalloc_junk JEMALLOC_N(n_large_dalloc_junk)
|
||||
#endif
|
||||
void
|
||||
large_dalloc_junk(void *ptr, size_t usize) {
|
||||
|
|
@ -71,13 +71,13 @@ large_dalloc_junk(void *ptr, size_t usize) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef large_dalloc_junk
|
||||
#define large_dalloc_junk JEMALLOC_N(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)
|
||||
#define large_dalloc_maybe_junk JEMALLOC_N(n_large_dalloc_maybe_junk)
|
||||
#endif
|
||||
void
|
||||
large_dalloc_maybe_junk(void *ptr, size_t usize) {
|
||||
|
|
@ -93,7 +93,7 @@ large_dalloc_maybe_junk(void *ptr, size_t usize) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef large_dalloc_maybe_junk
|
||||
#define large_dalloc_maybe_junk JEMALLOC_N(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
|
||||
|
|
|
|||
2
src/mb.c
2
src/mb.c
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_MB_C_
|
||||
#define JEMALLOC_MB_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_MUTEX_C_
|
||||
#define JEMALLOC_MUTEX_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
#if defined(JEMALLOC_LAZY_LOCK) && !defined(_WIN32)
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef _CRT_SPINCOUNT
|
||||
#define _CRT_SPINCOUNT 4000
|
||||
#define _CRT_SPINCOUNT 4000
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
10
src/nstime.c
10
src/nstime.c
|
|
@ -1,6 +1,6 @@
|
|||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
#define BILLION UINT64_C(1000000000)
|
||||
#define BILLION UINT64_C(1000000000)
|
||||
|
||||
void
|
||||
nstime_init(nstime_t *time, uint64_t ns) {
|
||||
|
|
@ -122,7 +122,7 @@ nstime_get(nstime_t *time) {
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef nstime_monotonic
|
||||
#define nstime_monotonic JEMALLOC_N(n_nstime_monotonic)
|
||||
#define nstime_monotonic JEMALLOC_N(n_nstime_monotonic)
|
||||
#endif
|
||||
bool
|
||||
nstime_monotonic(void) {
|
||||
|
|
@ -131,13 +131,13 @@ nstime_monotonic(void) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef nstime_monotonic
|
||||
#define nstime_monotonic JEMALLOC_N(nstime_monotonic)
|
||||
#define nstime_monotonic JEMALLOC_N(nstime_monotonic)
|
||||
nstime_monotonic_t *nstime_monotonic = JEMALLOC_N(n_nstime_monotonic);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef nstime_update
|
||||
#define nstime_update JEMALLOC_N(n_nstime_update)
|
||||
#define nstime_update JEMALLOC_N(n_nstime_update)
|
||||
#endif
|
||||
bool
|
||||
nstime_update(nstime_t *time) {
|
||||
|
|
@ -156,6 +156,6 @@ nstime_update(nstime_t *time) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef nstime_update
|
||||
#define nstime_update JEMALLOC_N(nstime_update)
|
||||
#define nstime_update JEMALLOC_N(nstime_update)
|
||||
nstime_update_t *nstime_update = JEMALLOC_N(n_nstime_update);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_PAGES_C_
|
||||
#define JEMALLOC_PAGES_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
#ifdef JEMALLOC_SYSCTL_VM_OVERCOMMIT
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_PRNG_C_
|
||||
#define JEMALLOC_PRNG_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
18
src/prof.c
18
src/prof.c
|
|
@ -1,9 +1,9 @@
|
|||
#define JEMALLOC_PROF_C_
|
||||
#define JEMALLOC_PROF_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
/******************************************************************************/
|
||||
|
||||
#ifdef JEMALLOC_PROF_LIBUNWIND
|
||||
#define UNW_LOCAL_ONLY
|
||||
#define UNW_LOCAL_ONLY
|
||||
#include <libunwind.h>
|
||||
#endif
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ prof_backtrace(prof_bt_t *bt) {
|
|||
#elif (defined(JEMALLOC_PROF_GCC))
|
||||
void
|
||||
prof_backtrace(prof_bt_t *bt) {
|
||||
#define BT_FRAME(i) \
|
||||
#define BT_FRAME(i) \
|
||||
if ((i) < PROF_BT_MAX) { \
|
||||
void *p; \
|
||||
if (__builtin_frame_address(i) == 0) { \
|
||||
|
|
@ -928,7 +928,7 @@ prof_bt_count(void) {
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_open
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open_impl)
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open_impl)
|
||||
#endif
|
||||
static int
|
||||
prof_dump_open(bool propagate_err, const char *filename) {
|
||||
|
|
@ -947,7 +947,7 @@ prof_dump_open(bool propagate_err, const char *filename) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_open
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open)
|
||||
#define prof_dump_open JEMALLOC_N(prof_dump_open)
|
||||
prof_dump_open_t *prof_dump_open = JEMALLOC_N(prof_dump_open_impl);
|
||||
#endif
|
||||
|
||||
|
|
@ -1305,7 +1305,7 @@ prof_tdata_dump_iter(prof_tdata_tree_t *tdatas, prof_tdata_t *tdata,
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_header
|
||||
#define prof_dump_header JEMALLOC_N(prof_dump_header_impl)
|
||||
#define prof_dump_header JEMALLOC_N(prof_dump_header_impl)
|
||||
#endif
|
||||
static bool
|
||||
prof_dump_header(tsdn_t *tsdn, bool propagate_err, const prof_cnt_t *cnt_all) {
|
||||
|
|
@ -1327,7 +1327,7 @@ prof_dump_header(tsdn_t *tsdn, bool propagate_err, const prof_cnt_t *cnt_all) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef prof_dump_header
|
||||
#define prof_dump_header JEMALLOC_N(prof_dump_header)
|
||||
#define prof_dump_header JEMALLOC_N(prof_dump_header)
|
||||
prof_dump_header_t *prof_dump_header = JEMALLOC_N(prof_dump_header_impl);
|
||||
#endif
|
||||
|
||||
|
|
@ -1696,8 +1696,8 @@ prof_cnt_all(uint64_t *curobjs, uint64_t *curbytes, uint64_t *accumobjs,
|
|||
}
|
||||
#endif
|
||||
|
||||
#define DUMP_FILENAME_BUFSIZE (PATH_MAX + 1)
|
||||
#define VSEQ_INVALID UINT64_C(0xffffffffffffffff)
|
||||
#define DUMP_FILENAME_BUFSIZE (PATH_MAX + 1)
|
||||
#define VSEQ_INVALID UINT64_C(0xffffffffffffffff)
|
||||
static void
|
||||
prof_dump_filename(char *filename, char v, uint64_t vseq) {
|
||||
cassert(config_prof);
|
||||
|
|
|
|||
10
src/rtree.c
10
src/rtree.c
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_RTREE_C_
|
||||
#define JEMALLOC_RTREE_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
static unsigned
|
||||
|
|
@ -65,7 +65,7 @@ rtree_new(rtree_t *rtree, unsigned bits) {
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef rtree_node_alloc
|
||||
#define rtree_node_alloc JEMALLOC_N(rtree_node_alloc_impl)
|
||||
#define rtree_node_alloc JEMALLOC_N(rtree_node_alloc_impl)
|
||||
#endif
|
||||
static rtree_elm_t *
|
||||
rtree_node_alloc(tsdn_t *tsdn, rtree_t *rtree, size_t nelms) {
|
||||
|
|
@ -74,13 +74,13 @@ rtree_node_alloc(tsdn_t *tsdn, rtree_t *rtree, size_t nelms) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef rtree_node_alloc
|
||||
#define rtree_node_alloc JEMALLOC_N(rtree_node_alloc)
|
||||
#define rtree_node_alloc JEMALLOC_N(rtree_node_alloc)
|
||||
rtree_node_alloc_t *rtree_node_alloc = JEMALLOC_N(rtree_node_alloc_impl);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef rtree_node_dalloc
|
||||
#define rtree_node_dalloc JEMALLOC_N(rtree_node_dalloc_impl)
|
||||
#define rtree_node_dalloc JEMALLOC_N(rtree_node_dalloc_impl)
|
||||
#endif
|
||||
UNUSED static void
|
||||
rtree_node_dalloc(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node) {
|
||||
|
|
@ -89,7 +89,7 @@ rtree_node_dalloc(tsdn_t *tsdn, rtree_t *rtree, rtree_elm_t *node) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef rtree_node_dalloc
|
||||
#define rtree_node_dalloc JEMALLOC_N(rtree_node_dalloc)
|
||||
#define rtree_node_dalloc JEMALLOC_N(rtree_node_dalloc)
|
||||
rtree_node_dalloc_t *rtree_node_dalloc = JEMALLOC_N(rtree_node_dalloc_impl);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_SPIN_C_
|
||||
#define JEMALLOC_SPIN_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
22
src/stats.c
22
src/stats.c
|
|
@ -1,12 +1,12 @@
|
|||
#define JEMALLOC_STATS_C_
|
||||
#define JEMALLOC_STATS_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
#define CTL_GET(n, v, t) do { \
|
||||
#define CTL_GET(n, v, t) do { \
|
||||
size_t sz = sizeof(t); \
|
||||
xmallctl(n, (void *)v, &sz, NULL, 0); \
|
||||
} while (0)
|
||||
|
||||
#define CTL_M2_GET(n, i, v, t) do { \
|
||||
#define CTL_M2_GET(n, i, v, t) do { \
|
||||
size_t mib[6]; \
|
||||
size_t miblen = sizeof(mib) / sizeof(size_t); \
|
||||
size_t sz = sizeof(t); \
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
xmallctlbymib(mib, miblen, (void *)v, &sz, NULL, 0); \
|
||||
} while (0)
|
||||
|
||||
#define CTL_M2_M4_GET(n, i, j, v, t) do { \
|
||||
#define CTL_M2_M4_GET(n, i, j, v, t) do { \
|
||||
size_t mib[6]; \
|
||||
size_t miblen = sizeof(mib) / sizeof(size_t); \
|
||||
size_t sz = sizeof(t); \
|
||||
|
|
@ -478,7 +478,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
}
|
||||
|
||||
/* config. */
|
||||
#define CONFIG_WRITE_BOOL_JSON(n, c) \
|
||||
#define CONFIG_WRITE_BOOL_JSON(n, c) \
|
||||
if (json) { \
|
||||
CTL_GET("config."#n, &bv, bool); \
|
||||
malloc_cprintf(write_cb, cbopaque, \
|
||||
|
|
@ -531,7 +531,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
#undef CONFIG_WRITE_BOOL_JSON
|
||||
|
||||
/* opt. */
|
||||
#define OPT_WRITE_BOOL(n, c) \
|
||||
#define OPT_WRITE_BOOL(n, c) \
|
||||
if (je_mallctl("opt."#n, (void *)&bv, &bsz, NULL, 0) == 0) { \
|
||||
if (json) { \
|
||||
malloc_cprintf(write_cb, cbopaque, \
|
||||
|
|
@ -542,7 +542,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
" opt."#n": %s\n", bv ? "true" : "false"); \
|
||||
} \
|
||||
}
|
||||
#define OPT_WRITE_BOOL_MUTABLE(n, m, c) { \
|
||||
#define OPT_WRITE_BOOL_MUTABLE(n, m, c) { \
|
||||
bool bv2; \
|
||||
if (je_mallctl("opt."#n, (void *)&bv, &bsz, NULL, 0) == 0 && \
|
||||
je_mallctl(#m, (void *)&bv2, &bsz, NULL, 0) == 0) { \
|
||||
|
|
@ -557,7 +557,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
} \
|
||||
} \
|
||||
}
|
||||
#define OPT_WRITE_UNSIGNED(n, c) \
|
||||
#define OPT_WRITE_UNSIGNED(n, c) \
|
||||
if (je_mallctl("opt."#n, (void *)&uv, &usz, NULL, 0) == 0) { \
|
||||
if (json) { \
|
||||
malloc_cprintf(write_cb, cbopaque, \
|
||||
|
|
@ -567,7 +567,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
" opt."#n": %u\n", uv); \
|
||||
} \
|
||||
}
|
||||
#define OPT_WRITE_SSIZE_T(n, c) \
|
||||
#define OPT_WRITE_SSIZE_T(n, c) \
|
||||
if (je_mallctl("opt."#n, (void *)&ssv, &sssz, NULL, 0) == 0) { \
|
||||
if (json) { \
|
||||
malloc_cprintf(write_cb, cbopaque, \
|
||||
|
|
@ -577,7 +577,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
" opt."#n": %zd\n", ssv); \
|
||||
} \
|
||||
}
|
||||
#define OPT_WRITE_SSIZE_T_MUTABLE(n, m, c) { \
|
||||
#define OPT_WRITE_SSIZE_T_MUTABLE(n, m, c) { \
|
||||
ssize_t ssv2; \
|
||||
if (je_mallctl("opt."#n, (void *)&ssv, &sssz, NULL, 0) == 0 && \
|
||||
je_mallctl(#m, (void *)&ssv2, &sssz, NULL, 0) == 0) { \
|
||||
|
|
@ -591,7 +591,7 @@ stats_general_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||
} \
|
||||
} \
|
||||
}
|
||||
#define OPT_WRITE_CHAR_P(n, c) \
|
||||
#define OPT_WRITE_CHAR_P(n, c) \
|
||||
if (je_mallctl("opt."#n, (void *)&cpv, &cpsz, NULL, 0) == 0) { \
|
||||
if (json) { \
|
||||
malloc_cprintf(write_cb, cbopaque, \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_TCACHE_C_
|
||||
#define JEMALLOC_TCACHE_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
#define JEMALLOC_TICKER_C_
|
||||
#define JEMALLOC_TICKER_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_TSD_C_
|
||||
#define JEMALLOC_TSD_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
@ -69,10 +69,10 @@ tsd_cleanup(void *arg) {
|
|||
/* Do nothing. */
|
||||
break;
|
||||
case tsd_state_nominal:
|
||||
#define MALLOC_TSD_cleanup_yes(n, t) \
|
||||
#define MALLOC_TSD_cleanup_yes(n, t) \
|
||||
n##_cleanup(tsd);
|
||||
#define MALLOC_TSD_cleanup_no(n, t)
|
||||
#define O(n, t, c) \
|
||||
#define MALLOC_TSD_cleanup_no(n, t)
|
||||
#define O(n, t, c) \
|
||||
MALLOC_TSD_cleanup_##c(n, t)
|
||||
MALLOC_TSD
|
||||
#undef MALLOC_TSD_cleanup_yes
|
||||
|
|
|
|||
24
src/util.c
24
src/util.c
|
|
@ -2,14 +2,14 @@
|
|||
* Define simple versions of assertion macros that won't recurse in case
|
||||
* of assertion failures in malloc_*printf().
|
||||
*/
|
||||
#define assert(e) do { \
|
||||
#define assert(e) do { \
|
||||
if (config_debug && !(e)) { \
|
||||
malloc_write("<jemalloc>: Failed assertion\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define not_reached() do { \
|
||||
#define not_reached() do { \
|
||||
if (config_debug) { \
|
||||
malloc_write("<jemalloc>: Unreachable code reached\n"); \
|
||||
abort(); \
|
||||
|
|
@ -17,28 +17,28 @@
|
|||
unreachable(); \
|
||||
} while (0)
|
||||
|
||||
#define not_implemented() do { \
|
||||
#define not_implemented() do { \
|
||||
if (config_debug) { \
|
||||
malloc_write("<jemalloc>: Not implemented\n"); \
|
||||
abort(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define JEMALLOC_UTIL_C_
|
||||
#define JEMALLOC_UTIL_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/* Function prototypes for non-inline static functions. */
|
||||
|
||||
static void wrtmessage(void *cbopaque, const char *s);
|
||||
#define U2S_BUFSIZE ((1U << (LG_SIZEOF_INTMAX_T + 3)) + 1)
|
||||
#define U2S_BUFSIZE ((1U << (LG_SIZEOF_INTMAX_T + 3)) + 1)
|
||||
static char *u2s(uintmax_t x, unsigned base, bool uppercase, char *s,
|
||||
size_t *slen_p);
|
||||
#define D2S_BUFSIZE (1 + U2S_BUFSIZE)
|
||||
#define D2S_BUFSIZE (1 + U2S_BUFSIZE)
|
||||
static char *d2s(intmax_t x, char sign, char *s, size_t *slen_p);
|
||||
#define O2S_BUFSIZE (1 + U2S_BUFSIZE)
|
||||
#define O2S_BUFSIZE (1 + U2S_BUFSIZE)
|
||||
static char *o2s(uintmax_t x, bool alt_form, char *s, size_t *slen_p);
|
||||
#define X2S_BUFSIZE (2 + U2S_BUFSIZE)
|
||||
#define X2S_BUFSIZE (2 + U2S_BUFSIZE)
|
||||
static char *x2s(uintmax_t x, bool alt_form, bool uppercase, char *s,
|
||||
size_t *slen_p);
|
||||
|
||||
|
|
@ -318,20 +318,20 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||
size_t i;
|
||||
const char *f;
|
||||
|
||||
#define APPEND_C(c) do { \
|
||||
#define APPEND_C(c) do { \
|
||||
if (i < size) { \
|
||||
str[i] = (c); \
|
||||
} \
|
||||
i++; \
|
||||
} while (0)
|
||||
#define APPEND_S(s, slen) do { \
|
||||
#define APPEND_S(s, slen) do { \
|
||||
if (i < size) { \
|
||||
size_t cpylen = (slen <= size - i) ? slen : size - i; \
|
||||
memcpy(&str[i], s, cpylen); \
|
||||
} \
|
||||
i += slen; \
|
||||
} while (0)
|
||||
#define APPEND_PADDED_S(s, slen, width, left_justify) do { \
|
||||
#define APPEND_PADDED_S(s, slen, width, left_justify) do { \
|
||||
/* Left padding. */ \
|
||||
size_t pad_len = (width == -1) ? 0 : ((slen < (size_t)width) ? \
|
||||
(size_t)width - slen : 0); \
|
||||
|
|
@ -351,7 +351,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
|
|||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#define GET_ARG_NUMERIC(val, len) do { \
|
||||
#define GET_ARG_NUMERIC(val, len) do { \
|
||||
switch (len) { \
|
||||
case '?': \
|
||||
val = va_arg(ap, int); \
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#define JEMALLOC_WITNESS_C_
|
||||
#define JEMALLOC_WITNESS_C_
|
||||
#include "jemalloc/internal/jemalloc_internal.h"
|
||||
|
||||
void
|
||||
|
|
@ -12,7 +12,7 @@ witness_init(witness_t *witness, const char *name, witness_rank_t rank,
|
|||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_lock_error
|
||||
#define witness_lock_error JEMALLOC_N(n_witness_lock_error)
|
||||
#define witness_lock_error JEMALLOC_N(n_witness_lock_error)
|
||||
#endif
|
||||
void
|
||||
witness_lock_error(const witness_list_t *witnesses, const witness_t *witness) {
|
||||
|
|
@ -27,13 +27,13 @@ witness_lock_error(const witness_list_t *witnesses, const witness_t *witness) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_lock_error
|
||||
#define witness_lock_error JEMALLOC_N(witness_lock_error)
|
||||
#define witness_lock_error JEMALLOC_N(witness_lock_error)
|
||||
witness_lock_error_t *witness_lock_error = JEMALLOC_N(n_witness_lock_error);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_owner_error
|
||||
#define witness_owner_error JEMALLOC_N(n_witness_owner_error)
|
||||
#define witness_owner_error JEMALLOC_N(n_witness_owner_error)
|
||||
#endif
|
||||
void
|
||||
witness_owner_error(const witness_t *witness) {
|
||||
|
|
@ -43,13 +43,13 @@ witness_owner_error(const witness_t *witness) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_owner_error
|
||||
#define witness_owner_error JEMALLOC_N(witness_owner_error)
|
||||
#define witness_owner_error JEMALLOC_N(witness_owner_error)
|
||||
witness_owner_error_t *witness_owner_error = JEMALLOC_N(n_witness_owner_error);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_not_owner_error
|
||||
#define witness_not_owner_error JEMALLOC_N(n_witness_not_owner_error)
|
||||
#define witness_not_owner_error JEMALLOC_N(n_witness_not_owner_error)
|
||||
#endif
|
||||
void
|
||||
witness_not_owner_error(const witness_t *witness) {
|
||||
|
|
@ -59,14 +59,14 @@ witness_not_owner_error(const witness_t *witness) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_not_owner_error
|
||||
#define witness_not_owner_error JEMALLOC_N(witness_not_owner_error)
|
||||
#define witness_not_owner_error JEMALLOC_N(witness_not_owner_error)
|
||||
witness_not_owner_error_t *witness_not_owner_error =
|
||||
JEMALLOC_N(n_witness_not_owner_error);
|
||||
#endif
|
||||
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_lockless_error
|
||||
#define witness_lockless_error JEMALLOC_N(n_witness_lockless_error)
|
||||
#define witness_lockless_error JEMALLOC_N(n_witness_lockless_error)
|
||||
#endif
|
||||
void
|
||||
witness_lockless_error(const witness_list_t *witnesses) {
|
||||
|
|
@ -81,7 +81,7 @@ witness_lockless_error(const witness_list_t *witnesses) {
|
|||
}
|
||||
#ifdef JEMALLOC_JET
|
||||
#undef witness_lockless_error
|
||||
#define witness_lockless_error JEMALLOC_N(witness_lockless_error)
|
||||
#define witness_lockless_error JEMALLOC_N(witness_lockless_error)
|
||||
witness_lockless_error_t *witness_lockless_error =
|
||||
JEMALLOC_N(n_witness_lockless_error);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue