7 /* Defined if __attribute__((...)) syntax is supported. */
8 #define JEMALLOC_HAVE_ATTR
10 /* Defined if alloc_size attribute is supported. */
11 #define JEMALLOC_HAVE_ATTR_ALLOC_SIZE
13 /* Defined if format_arg(...) attribute is supported. */
14 #define JEMALLOC_HAVE_ATTR_FORMAT_ARG
16 /* Defined if format(gnu_printf, ...) attribute is supported. */
17 /* #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
19 /* Defined if format(printf, ...) attribute is supported. */
20 #define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
23 * Define overrides for non-standard allocator-related functions if they are
24 * present on the system.
26 /* #undef JEMALLOC_OVERRIDE_MEMALIGN */
27 #define JEMALLOC_OVERRIDE_VALLOC
30 * At least Linux omits the "const" in:
32 * size_t malloc_usable_size(const void *ptr);
34 * Match the operating system's prototype.
36 #define JEMALLOC_USABLE_SIZE_CONST const
39 * If defined, specify throw() for the public function prototypes when compiling
40 * with C++. The only justification for this is to match the prototypes that
43 /* #undef JEMALLOC_USE_CXX_THROW */
47 # define LG_SIZEOF_PTR_WIN 3
49 # define LG_SIZEOF_PTR_WIN 2
53 /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
54 #define LG_SIZEOF_PTR 3
57 * Name mangling for public symbols is controlled by --with-mangling and
58 * --with-jemalloc-prefix. With default settings the je_ prefix is stripped by
59 * these macro definitions.
61 #ifndef JEMALLOC_NO_RENAME
62 # define je_aligned_alloc aligned_alloc
63 # define je_calloc calloc
64 # define je_dallocx dallocx
66 # define je_mallctl mallctl
67 # define je_mallctlbymib mallctlbymib
68 # define je_mallctlnametomib mallctlnametomib
69 # define je_malloc malloc
70 # define je_malloc_conf malloc_conf
71 # define je_malloc_message malloc_message
72 # define je_malloc_stats_print malloc_stats_print
73 # define je_malloc_usable_size malloc_usable_size
74 # define je_mallocx mallocx
75 # define je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
76 # define je_nallocx nallocx
77 # define je_posix_memalign posix_memalign
78 # define je_rallocx rallocx
79 # define je_realloc realloc
80 # define je_sallocx sallocx
81 # define je_sdallocx sdallocx
82 # define je_xallocx xallocx
83 # define je_valloc valloc
86 #include "jemalloc_FreeBSD.h"
94 #define JEMALLOC_VERSION "5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756"
95 #define JEMALLOC_VERSION_MAJOR 5
96 #define JEMALLOC_VERSION_MINOR 2
97 #define JEMALLOC_VERSION_BUGFIX 1
98 #define JEMALLOC_VERSION_NREV 0
99 #define JEMALLOC_VERSION_GID "ea6b3e973b477b8061e0076bb257dbd7f3faa756"
100 #define JEMALLOC_VERSION_GID_IDENT ea6b3e973b477b8061e0076bb257dbd7f3faa756
102 #define MALLOCX_LG_ALIGN(la) ((int)(la))
103 #if LG_SIZEOF_PTR == 2
104 # define MALLOCX_ALIGN(a) ((int)(ffs((int)(a))-1))
106 # define MALLOCX_ALIGN(a) \
107 ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \
108 ffs((int)(((size_t)(a))>>32))+31))
110 #define MALLOCX_ZERO ((int)0x40)
112 * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
113 * encodes MALLOCX_TCACHE_NONE.
115 #define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8))
116 #define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1)
118 * Bias arena index bits so that 0 encodes "use an automatically chosen arena".
120 #define MALLOCX_ARENA(a) ((((int)(a))+1) << 20)
123 * Use as arena index in "arena.<i>.{purge,decay,dss}" and
124 * "stats.arenas.<i>.*" mallctl interfaces to select all arenas. This
125 * definition is intentionally specified in raw decimal format to support
126 * cpp-based string concatenation, e.g.
128 * #define STRINGIFY_HELPER(x) #x
129 * #define STRINGIFY(x) STRINGIFY_HELPER(x)
131 * mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
134 #define MALLCTL_ARENAS_ALL 4096
136 * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
139 #define MALLCTL_ARENAS_DESTROYED 4097
141 #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
142 # define JEMALLOC_CXX_THROW throw()
144 # define JEMALLOC_CXX_THROW
147 #if defined(_MSC_VER)
148 # define JEMALLOC_ATTR(s)
149 # define JEMALLOC_ALIGNED(s) __declspec(align(s))
150 # define JEMALLOC_ALLOC_SIZE(s)
151 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
152 # ifndef JEMALLOC_EXPORT
154 # define JEMALLOC_EXPORT __declspec(dllexport)
156 # define JEMALLOC_EXPORT __declspec(dllimport)
159 # define JEMALLOC_FORMAT_ARG(i)
160 # define JEMALLOC_FORMAT_PRINTF(s, i)
161 # define JEMALLOC_NOINLINE __declspec(noinline)
163 # define JEMALLOC_NOTHROW __declspec(nothrow)
165 # define JEMALLOC_NOTHROW
167 # define JEMALLOC_SECTION(s) __declspec(allocate(s))
168 # define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
169 # if _MSC_VER >= 1900 && !defined(__EDG__)
170 # define JEMALLOC_ALLOCATOR __declspec(allocator)
172 # define JEMALLOC_ALLOCATOR
174 #elif defined(JEMALLOC_HAVE_ATTR)
175 # define JEMALLOC_ATTR(s) __attribute__((s))
176 # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
177 # ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
178 # define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
179 # define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
181 # define JEMALLOC_ALLOC_SIZE(s)
182 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
184 # ifndef JEMALLOC_EXPORT
185 # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
187 # ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
188 # define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
190 # define JEMALLOC_FORMAT_ARG(i)
192 # ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
193 # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
194 # elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
195 # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
197 # define JEMALLOC_FORMAT_PRINTF(s, i)
199 # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
200 # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
201 # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
202 # define JEMALLOC_RESTRICT_RETURN
203 # define JEMALLOC_ALLOCATOR
205 # define JEMALLOC_ATTR(s)
206 # define JEMALLOC_ALIGNED(s)
207 # define JEMALLOC_ALLOC_SIZE(s)
208 # define JEMALLOC_ALLOC_SIZE2(s1, s2)
209 # define JEMALLOC_EXPORT
210 # define JEMALLOC_FORMAT_PRINTF(s, i)
211 # define JEMALLOC_NOINLINE
212 # define JEMALLOC_NOTHROW
213 # define JEMALLOC_SECTION(s)
214 # define JEMALLOC_RESTRICT_RETURN
215 # define JEMALLOC_ALLOCATOR
219 * The je_ prefix on the following public symbol declarations is an artifact
220 * of namespace management, and should be omitted in application code unless
221 * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h).
223 extern JEMALLOC_EXPORT const char *je_malloc_conf;
224 extern JEMALLOC_EXPORT void (*je_malloc_message)(void *cbopaque,
227 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
228 void JEMALLOC_NOTHROW *je_malloc(size_t size)
229 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
230 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
231 void JEMALLOC_NOTHROW *je_calloc(size_t num, size_t size)
232 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2);
233 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_posix_memalign(void **memptr,
234 size_t alignment, size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(nonnull(1));
235 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
236 void JEMALLOC_NOTHROW *je_aligned_alloc(size_t alignment,
237 size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc)
238 JEMALLOC_ALLOC_SIZE(2);
239 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
240 void JEMALLOC_NOTHROW *je_realloc(void *ptr, size_t size)
241 JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2);
242 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_free(void *ptr)
245 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
246 void JEMALLOC_NOTHROW *je_mallocx(size_t size, int flags)
247 JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
248 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
249 void JEMALLOC_NOTHROW *je_rallocx(void *ptr, size_t size,
250 int flags) JEMALLOC_ALLOC_SIZE(2);
251 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_xallocx(void *ptr, size_t size,
252 size_t extra, int flags);
253 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_sallocx(const void *ptr,
254 int flags) JEMALLOC_ATTR(pure);
255 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_dallocx(void *ptr, int flags);
256 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_sdallocx(void *ptr, size_t size,
258 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_nallocx(size_t size, int flags)
261 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctl(const char *name,
262 void *oldp, size_t *oldlenp, void *newp, size_t newlen);
263 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlnametomib(const char *name,
264 size_t *mibp, size_t *miblenp);
265 JEMALLOC_EXPORT int JEMALLOC_NOTHROW je_mallctlbymib(const size_t *mib,
266 size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
267 JEMALLOC_EXPORT void JEMALLOC_NOTHROW je_malloc_stats_print(
268 void (*write_cb)(void *, const char *), void *je_cbopaque,
270 JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW je_malloc_usable_size(
271 JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
273 #ifdef JEMALLOC_OVERRIDE_MEMALIGN
274 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
275 void JEMALLOC_NOTHROW *je_memalign(size_t alignment, size_t size)
276 JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc);
279 #ifdef JEMALLOC_OVERRIDE_VALLOC
280 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
281 void JEMALLOC_NOTHROW *je_valloc(size_t size) JEMALLOC_CXX_THROW
282 JEMALLOC_ATTR(malloc);
285 typedef struct extent_hooks_s extent_hooks_t;
289 * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
290 * size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
292 typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
297 * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
298 * bool committed, unsigned arena_ind);
300 typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
305 * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
306 * bool committed, unsigned arena_ind);
308 typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
313 * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
314 * size_t offset, size_t length, unsigned arena_ind);
316 typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
321 * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
322 * size_t offset, size_t length, unsigned arena_ind);
324 typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
329 * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
330 * size_t offset, size_t length, unsigned arena_ind);
332 typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
337 * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
338 * size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
340 typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
345 * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
346 * void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
348 typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
351 struct extent_hooks_s {
352 extent_alloc_t *alloc;
353 extent_dalloc_t *dalloc;
354 extent_destroy_t *destroy;
355 extent_commit_t *commit;
356 extent_decommit_t *decommit;
357 extent_purge_t *purge_lazy;
358 extent_purge_t *purge_forced;
359 extent_split_t *split;
360 extent_merge_t *merge;
364 * By default application code must explicitly refer to mangled symbol names,
365 * so that it is possible to use jemalloc in conjunction with another allocator
366 * in the same application. Define JEMALLOC_MANGLE in order to cause automatic
367 * name mangling that matches the API prefixing that happened as a result of
368 * --with-mangling and/or --with-jemalloc-prefix configuration settings.
370 #ifdef JEMALLOC_MANGLE
371 # ifndef JEMALLOC_NO_DEMANGLE
372 # define JEMALLOC_NO_DEMANGLE
374 # define aligned_alloc je_aligned_alloc
375 # define calloc je_calloc
376 # define dallocx je_dallocx
377 # define free je_free
378 # define mallctl je_mallctl
379 # define mallctlbymib je_mallctlbymib
380 # define mallctlnametomib je_mallctlnametomib
381 # define malloc je_malloc
382 # define malloc_conf je_malloc_conf
383 # define malloc_message je_malloc_message
384 # define malloc_stats_print je_malloc_stats_print
385 # define malloc_usable_size je_malloc_usable_size
386 # define mallocx je_mallocx
387 # define smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756 je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
388 # define nallocx je_nallocx
389 # define posix_memalign je_posix_memalign
390 # define rallocx je_rallocx
391 # define realloc je_realloc
392 # define sallocx je_sallocx
393 # define sdallocx je_sdallocx
394 # define xallocx je_xallocx
395 # define valloc je_valloc
399 * The je_* macros can be used as stable alternative names for the
400 * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily
401 * meant for use in jemalloc itself, but it can be used by application code to
402 * provide isolation from the name mangling specified via --with-mangling
403 * and/or --with-jemalloc-prefix.
405 #ifndef JEMALLOC_NO_DEMANGLE
406 # undef je_aligned_alloc
411 # undef je_mallctlbymib
412 # undef je_mallctlnametomib
414 # undef je_malloc_conf
415 # undef je_malloc_message
416 # undef je_malloc_stats_print
417 # undef je_malloc_usable_size
419 # undef je_smallocx_ea6b3e973b477b8061e0076bb257dbd7f3faa756
421 # undef je_posix_memalign
433 #endif /* JEMALLOC_H_ */