7 /* Defined if __attribute__((...)) syntax is supported. */
8 #define JEMALLOC_HAVE_ATTR
10 /* Defined if alloc_size attribute is supported. */
11 /* #undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE */
13 /* Defined if format(gnu_printf, ...) attribute is supported. */
14 /* #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
16 /* Defined if format(printf, ...) attribute is supported. */
17 #define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
20 * Define overrides for non-standard allocator-related functions if they are
21 * present on the system.
23 /* #undef JEMALLOC_OVERRIDE_MEMALIGN */
24 #define JEMALLOC_OVERRIDE_VALLOC
27 * At least Linux omits the "const" in:
29 * size_t malloc_usable_size(const void *ptr);
31 * Match the operating system's prototype.
33 #define JEMALLOC_USABLE_SIZE_CONST const
36 * If defined, specify throw() for the public function prototypes when compiling
37 * with C++. The only justification for this is to match the prototypes that
40 /* #undef JEMALLOC_USE_CXX_THROW */
44 # define LG_SIZEOF_PTR_WIN 3
46 # define LG_SIZEOF_PTR_WIN 2
50 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
51 #define LG_SIZEOF_PTR 3
54 * Name mangling for public symbols is controlled by --with-mangling and
55 * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by
56 * these macro definitions.
58 #ifndef JEMALLOC_NO_RENAME
59 # define je_aligned_alloc aligned_alloc
60 # define je_calloc calloc
61 # define je_dallocx dallocx
63 # define je_mallctl mallctl
64 # define je_mallctlbymib mallctlbymib
65 # define je_mallctlnametomib mallctlnametomib
66 # define je_malloc malloc
67 # define je_malloc_conf malloc_conf
68 # define je_malloc_message malloc_message
69 # define je_malloc_stats_print malloc_stats_print
70 # define je_malloc_usable_size malloc_usable_size
71 # define je_mallocx mallocx
72 # define je_nallocx nallocx
73 # define je_posix_memalign posix_memalign
74 # define je_rallocx rallocx
75 # define je_realloc realloc
76 # define je_sallocx sallocx
77 # define je_sdallocx sdallocx
78 # define je_xallocx xallocx
79 # define je_valloc valloc
82 #include "jemalloc_FreeBSD.h"
90 #define JEMALLOC_VERSION "5.1.0-0-g61efbda7098de6fe64c362d309824864308c36d4"
91 #define JEMALLOC_VERSION_MAJOR 5
92 #define JEMALLOC_VERSION_MINOR 1
93 #define JEMALLOC_VERSION_BUGFIX 0
94 #define JEMALLOC_VERSION_NREV 0
95 #define JEMALLOC_VERSION_GID "61efbda7098de6fe64c362d309824864308c36d4"
97 #define MALLOCX_LG_ALIGN(la) ((int)(la))
98 #if LG_SIZEOF_PTR == 2
99 # define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1))
101 # define MALLOCX_ALIGN(a) \
102 ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \
103 ffs((int)(((size_t)(a))>>32))+31))
105 #define MALLOCX_ZERO ((int)0x40)
107 * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
108 * encodes MALLOCX_TCACHE_NONE.
110 #define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8))
111 #define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1)
113 * Bias arena index bits so that 0 encodes "use an automatically chosen arena".
115 #define MALLOCX_ARENA(a) ((((int)(a))+1) << 20)
118 * Use as arena index in "arena.<i>.{purge,decay,dss}" and
119 * "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This
120 * definition is intentionally specified in raw decimal format to support
121 * cpp-based string concatenation, e.g.
123 * #define STRINGIFY_HELPER(x) #x
124 * #define STRINGIFY(x) STRINGIFY_HELPER(x)
126 * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
129 #define MALLCTL_ARENAS_ALL 4096
131 * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
134 #define MALLCTL_ARENAS_DESTROYED 4097
136 #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
137 # define JEMALLOC_CXX_THROW throw()
139 # define JEMALLOC_CXX_THROW
142 #if defined(_MSC_VER)
143 # define JEMALLOC_ATTR(s)
144 # define JEMALLOC_ALIGNED(s) __declspec(align(s))
145 # define JEMALLOC_ALLOC_SIZE(s)
146 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
147 # ifndef JEMALLOC_EXPORT
149 # define JEMALLOC_EXPORT __declspec(dllexport)
151 # define JEMALLOC_EXPORT __declspec(dllimport)
154 # define JEMALLOC_FORMAT_PRINTF(s, i)
155 # define JEMALLOC_NOINLINE __declspec(noinline)
157 # define JEMALLOC_NOTHROW __declspec(nothrow)
159 # define JEMALLOC_NOTHROW
161 # define JEMALLOC_SECTION(s) __declspec(allocate(s))
162 # define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
163 # if _MSC_VER >= 1900 && !defined(__EDG__)
164 # define JEMALLOC_ALLOCATOR __declspec(allocator)
166 # define JEMALLOC_ALLOCATOR
168 #elif defined(JEMALLOC_HAVE_ATTR)
169 # define JEMALLOC_ATTR(s) __attribute__((s))
170 # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
171 # ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
172 # define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
173 # define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
175 # define JEMALLOC_ALLOC_SIZE(s)
176 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
178 # ifndef JEMALLOC_EXPORT
179 # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
181 # ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
182 # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
183 # elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
184 # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
186 # define JEMALLOC_FORMAT_PRINTF(s, i)
188 # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
189 # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
190 # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
191 # define JEMALLOC_RESTRICT_RETURN
192 # define JEMALLOC_ALLOCATOR
194 # define JEMALLOC_ATTR(s)
195 # define JEMALLOC_ALIGNED(s)
196 # define JEMALLOC_ALLOC_SIZE(s)
197 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
198 # define JEMALLOC_EXPORT
199 # define JEMALLOC_FORMAT_PRINTF(s, i)
200 # define JEMALLOC_NOINLINE
201 # define JEMALLOC_NOTHROW
202 # define JEMALLOC_SECTION(s)
203 # define JEMALLOC_RESTRICT_RETURN
204 # define JEMALLOC_ALLOCATOR
208 * The je_ prefix on the following public symbol declarations is an artifact
209 * of namespace management, and should be omitted in application code unless
210 * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h).
212 extern JEMALLOC_EXPORT const char *je_malloc_conf;
213 extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque,
216 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
217 void JEMALLOC_NOTHROW *je_malloc(size_t size)
218 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
219 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
220 void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size)
221 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2);
222 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr,
223 size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1));
224 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
225 void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment,
226 size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc)
227 JEMALLOC_ALLOC_SIZE(2);
228 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
229 void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size)
230 JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2);
231 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr)
234 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
235 void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags)
236 JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
237 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
238 void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size,
239 int flags) JEMALLOC_ALLOC_SIZE(2);
240 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size,
241 size_t extra, int flags);
242 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr,
243 int flags) JEMALLOC_ATTR(pure);
244 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags);
245 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size,
247 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags)
250 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name,
251 void *oldp, size_t *oldlenp, void *newp, size_t newlen);
252 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name,
253 size_t *mibp, size_t *miblenp);
254 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib,
255 size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
256 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print(
257 void (*write_cb)(void *, const char *), void *je_cbopaque,
259 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size(
260 JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
262 #ifdef JEMALLOC_OVERRIDE_MEMALIGN
263 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
264 void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size)
265 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc);
268 #ifdef JEMALLOC_OVERRIDE_VALLOC
269 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
270 void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW
271 JEMALLOC_ATTR(malloc);
274 typedef struct extent_hooks_s extent_hooks_t;
278 * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
279 * size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
281 typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
286 * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
287 * bool committed, unsigned arena_ind);
289 typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
294 * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
295 * bool committed, unsigned arena_ind);
297 typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
302 * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
303 * size_t offset, size_t length, unsigned arena_ind);
305 typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
310 * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
311 * size_t offset, size_t length, unsigned arena_ind);
313 typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
318 * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
319 * size_t offset, size_t length, unsigned arena_ind);
321 typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
326 * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
327 * size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
329 typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
334 * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
335 * void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
337 typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
340 struct extent_hooks_s {
341 extent_alloc_t *alloc;
342 extent_dalloc_t *dalloc;
343 extent_destroy_t *destroy;
344 extent_commit_t *commit;
345 extent_decommit_t *decommit;
346 extent_purge_t *purge_lazy;
347 extent_purge_t *purge_forced;
348 extent_split_t *split;
349 extent_merge_t *merge;
353 * By default application code must explicitly refer to mangled symbol names,
354 * so that it is possible to use jemalloc in conjunction with another allocator
355 * in the same application. Define JEMALLOC_MANGLE in order to cause automatic
356 * name mangling that matches the API prefixing that happened as a result of
357 * --with-mangling and/or --with-jemalloc-prefix configuration settings.
359 #ifdef JEMALLOC_MANGLE
360 # ifndef JEMALLOC_NO_DEMANGLE
361 # define JEMALLOC_NO_DEMANGLE
363 # define aligned_alloc je_aligned_alloc
364 # define calloc je_calloc
365 # define dallocx je_dallocx
366 # define free je_free
367 # define mallctl je_mallctl
368 # define mallctlbymib je_mallctlbymib
369 # define mallctlnametomib je_mallctlnametomib
370 # define malloc je_malloc
371 # define malloc_conf je_malloc_conf
372 # define malloc_message je_malloc_message
373 # define malloc_stats_print je_malloc_stats_print
374 # define malloc_usable_size je_malloc_usable_size
375 # define mallocx je_mallocx
376 # define nallocx je_nallocx
377 # define posix_memalign je_posix_memalign
378 # define rallocx je_rallocx
379 # define realloc je_realloc
380 # define sallocx je_sallocx
381 # define sdallocx je_sdallocx
382 # define xallocx je_xallocx
383 # define valloc je_valloc
387 * The je_* macros can be used as stable alternative names for the
388 * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily
389 * meant for use in jemalloc itself, but it can be used by application code to
390 * provide isolation from the name mangling specified via --with-mangling
391 * and/or --with-jemalloc-prefix.
393 #ifndef JEMALLOC_NO_DEMANGLE
394 # undef je_aligned_alloc
399 # undef je_mallctlbymib
400 # undef je_mallctlnametomib
402 # undef je_malloc_conf
403 # undef je_malloc_message
404 # undef je_malloc_stats_print
405 # undef je_malloc_usable_size
408 # undef je_posix_memalign
420 #endif /* JEMALLOC_H_ */