1 /******************************************************************************/
2 #ifdef JEMALLOC_H_TYPES
5 * Size and alignment of memory chunks that are allocated by the OS's virtual
8 #define LG_CHUNK_DEFAULT 21
10 /* Return the chunk address for allocation address a. */
11 #define CHUNK_ADDR2BASE(a) \
12 ((void *)((uintptr_t)(a) & ~chunksize_mask))
14 /* Return the chunk offset of address a. */
15 #define CHUNK_ADDR2OFFSET(a) \
16 ((size_t)((uintptr_t)(a) & chunksize_mask))
18 /* Return the smallest chunk multiple that is >= s. */
19 #define CHUNK_CEILING(s) \
20 (((s) + chunksize_mask) & ~chunksize_mask)
22 #define CHUNK_HOOKS_INITIALIZER { \
32 #endif /* JEMALLOC_H_TYPES */
33 /******************************************************************************/
34 #ifdef JEMALLOC_H_STRUCTS
36 #endif /* JEMALLOC_H_STRUCTS */
37 /******************************************************************************/
38 #ifdef JEMALLOC_H_EXTERNS
40 extern size_t opt_lg_chunk
;
41 extern const char *opt_dss
;
43 extern rtree_t chunks_rtree
;
45 extern size_t chunksize
;
46 extern size_t chunksize_mask
; /* (chunksize - 1). */
47 extern size_t chunk_npages
;
49 extern const chunk_hooks_t chunk_hooks_default
;
51 chunk_hooks_t
chunk_hooks_get(arena_t
*arena
);
52 chunk_hooks_t
chunk_hooks_set(arena_t
*arena
,
53 const chunk_hooks_t
*chunk_hooks
);
55 bool chunk_register(const void *chunk
, const extent_node_t
*node
);
56 void chunk_deregister(const void *chunk
, const extent_node_t
*node
);
57 void *chunk_alloc_base(size_t size
);
58 void *chunk_alloc_cache(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
59 void *new_addr
, size_t size
, size_t alignment
, bool *zero
,
61 void *chunk_alloc_wrapper(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
62 void *new_addr
, size_t size
, size_t alignment
, bool *zero
, bool *commit
);
63 void chunk_dalloc_cache(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
64 void *chunk
, size_t size
, bool committed
);
65 void chunk_dalloc_arena(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
66 void *chunk
, size_t size
, bool zeroed
, bool committed
);
67 void chunk_dalloc_wrapper(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
68 void *chunk
, size_t size
, bool committed
);
69 bool chunk_purge_arena(arena_t
*arena
, void *chunk
, size_t offset
,
71 bool chunk_purge_wrapper(arena_t
*arena
, chunk_hooks_t
*chunk_hooks
,
72 void *chunk
, size_t size
, size_t offset
, size_t length
);
73 bool chunk_boot(void);
74 void chunk_prefork(void);
75 void chunk_postfork_parent(void);
76 void chunk_postfork_child(void);
78 #endif /* JEMALLOC_H_EXTERNS */
79 /******************************************************************************/
80 #ifdef JEMALLOC_H_INLINES
82 #ifndef JEMALLOC_ENABLE_INLINE
83 extent_node_t
*chunk_lookup(const void *chunk
, bool dependent
);
86 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_CHUNK_C_))
87 JEMALLOC_INLINE extent_node_t
*
88 chunk_lookup(const void *ptr
, bool dependent
)
91 return (rtree_get(&chunks_rtree
, (uintptr_t)ptr
, dependent
));
95 #endif /* JEMALLOC_H_INLINES */
96 /******************************************************************************/
98 #include "jemalloc/internal/chunk_dss.h"
99 #include "jemalloc/internal/chunk_mmap.h"