1#ifndef JEMALLOC_H_
2#define	JEMALLOC_H_
3#ifdef __cplusplus
4extern "C" {
5#endif
6
7#include <limits.h>
8#include <strings.h>
9
10#define	JEMALLOC_VERSION "3.4.0-0-g0ed518e5dab789ad2171bb38977a8927e2a26775"
11#define	JEMALLOC_VERSION_MAJOR 3
12#define	JEMALLOC_VERSION_MINOR 4
13#define	JEMALLOC_VERSION_BUGFIX 0
14#define	JEMALLOC_VERSION_NREV 0
15#define	JEMALLOC_VERSION_GID "0ed518e5dab789ad2171bb38977a8927e2a26775"
16
17#include "jemalloc_defs.h"
18#include "jemalloc_FreeBSD.h"
19
20#ifdef JEMALLOC_EXPERIMENTAL
21#define	ALLOCM_LG_ALIGN(la)	(la)
22#if LG_SIZEOF_PTR == 2
23#define	ALLOCM_ALIGN(a)	(ffs(a)-1)
24#else
25#define	ALLOCM_ALIGN(a)	((a < (size_t)INT_MAX) ? ffs(a)-1 : ffs(a>>32)+31)
26#endif
27#define	ALLOCM_ZERO	((int)0x40)
28#define	ALLOCM_NO_MOVE	((int)0x80)
29/* Bias arena index bits so that 0 encodes "ALLOCM_ARENA() unspecified". */
30#define	ALLOCM_ARENA(a)	((int)(((a)+1) << 8))
31
32#define	ALLOCM_SUCCESS		0
33#define	ALLOCM_ERR_OOM		1
34#define	ALLOCM_ERR_NOT_MOVED	2
35#endif
36
37/*
38 * The je_ prefix on the following public symbol declarations is an artifact of
39 * namespace management, and should be omitted in application code unless
40 * JEMALLOC_NO_DEMANGLE is defined (see below).
41 */
42extern JEMALLOC_EXPORT const char	*je_malloc_conf;
43extern JEMALLOC_EXPORT void		(*je_malloc_message)(void *cbopaque,
44    const char *s);
45
46JEMALLOC_EXPORT void	*je_malloc(size_t size) JEMALLOC_ATTR(malloc);
47JEMALLOC_EXPORT void	*je_calloc(size_t num, size_t size)
48    JEMALLOC_ATTR(malloc);
49JEMALLOC_EXPORT int	je_posix_memalign(void **memptr, size_t alignment,
50    size_t size) JEMALLOC_ATTR(nonnull(1));
51JEMALLOC_EXPORT void	*je_aligned_alloc(size_t alignment, size_t size)
52    JEMALLOC_ATTR(malloc);
53JEMALLOC_EXPORT void	*je_realloc(void *ptr, size_t size);
54JEMALLOC_EXPORT void	je_free(void *ptr);
55
56#ifdef JEMALLOC_OVERRIDE_MEMALIGN
57JEMALLOC_EXPORT void *	je_memalign(size_t alignment, size_t size)
58    JEMALLOC_ATTR(malloc);
59#endif
60
61#ifdef JEMALLOC_OVERRIDE_VALLOC
62JEMALLOC_EXPORT void *	je_valloc(size_t size) JEMALLOC_ATTR(malloc);
63#endif
64
65JEMALLOC_EXPORT size_t	je_malloc_usable_size(
66    JEMALLOC_USABLE_SIZE_CONST void *ptr);
67JEMALLOC_EXPORT void	je_malloc_stats_print(void (*write_cb)(void *,
68    const char *), void *je_cbopaque, const char *opts);
69JEMALLOC_EXPORT int	je_mallctl(const char *name, void *oldp,
70    size_t *oldlenp, void *newp, size_t newlen);
71JEMALLOC_EXPORT int	je_mallctlnametomib(const char *name, size_t *mibp,
72    size_t *miblenp);
73JEMALLOC_EXPORT int	je_mallctlbymib(const size_t *mib, size_t miblen,
74    void *oldp, size_t *oldlenp, void *newp, size_t newlen);
75
76#ifdef JEMALLOC_EXPERIMENTAL
77JEMALLOC_EXPORT int	je_allocm(void **ptr, size_t *rsize, size_t size,
78    int flags) JEMALLOC_ATTR(nonnull(1));
79JEMALLOC_EXPORT int	je_rallocm(void **ptr, size_t *rsize, size_t size,
80    size_t extra, int flags) JEMALLOC_ATTR(nonnull(1));
81JEMALLOC_EXPORT int	je_sallocm(const void *ptr, size_t *rsize, int flags)
82    JEMALLOC_ATTR(nonnull(1));
83JEMALLOC_EXPORT int	je_dallocm(void *ptr, int flags)
84    JEMALLOC_ATTR(nonnull(1));
85JEMALLOC_EXPORT int	je_nallocm(size_t *rsize, size_t size, int flags);
86#endif
87
88/*
89 * By default application code must explicitly refer to mangled symbol names,
90 * so that it is possible to use jemalloc in conjunction with another allocator
91 * in the same application.  Define JEMALLOC_MANGLE in order to cause automatic
92 * name mangling that matches the API prefixing that happened as a result of
93 * --with-mangling and/or --with-jemalloc-prefix configuration settings.
94 */
95#ifdef JEMALLOC_MANGLE
96#ifndef JEMALLOC_NO_DEMANGLE
97#define	JEMALLOC_NO_DEMANGLE
98#endif
99#define	malloc_conf je_malloc_conf
100#define	malloc_message je_malloc_message
101#define	malloc je_malloc
102#define	calloc je_calloc
103#define	posix_memalign je_posix_memalign
104#define	aligned_alloc je_aligned_alloc
105#define	realloc je_realloc
106#define	free je_free
107#define	malloc_usable_size je_malloc_usable_size
108#define	malloc_stats_print je_malloc_stats_print
109#define	mallctl je_mallctl
110#define	mallctlnametomib je_mallctlnametomib
111#define	mallctlbymib je_mallctlbymib
112#define	memalign je_memalign
113#define	valloc je_valloc
114#ifdef JEMALLOC_EXPERIMENTAL
115#define	allocm je_allocm
116#define	rallocm je_rallocm
117#define	sallocm je_sallocm
118#define	dallocm je_dallocm
119#define	nallocm je_nallocm
120#endif
121#endif
122
123/*
124 * The je_* macros can be used as stable alternative names for the public
125 * jemalloc API if JEMALLOC_NO_DEMANGLE is defined.  This is primarily meant
126 * for use in jemalloc itself, but it can be used by application code to
127 * provide isolation from the name mangling specified via --with-mangling
128 * and/or --with-jemalloc-prefix.
129 */
130#ifndef JEMALLOC_NO_DEMANGLE
131#undef je_malloc_conf
132#undef je_malloc_message
133#undef je_malloc
134#undef je_calloc
135#undef je_posix_memalign
136#undef je_aligned_alloc
137#undef je_realloc
138#undef je_free
139#undef je_malloc_usable_size
140#undef je_malloc_stats_print
141#undef je_mallctl
142#undef je_mallctlnametomib
143#undef je_mallctlbymib
144#undef je_memalign
145#undef je_valloc
146#ifdef JEMALLOC_EXPERIMENTAL
147#undef je_allocm
148#undef je_rallocm
149#undef je_sallocm
150#undef je_dallocm
151#undef je_nallocm
152#endif
153#endif
154
155#ifdef __cplusplus
156};
157#endif
158#endif /* JEMALLOC_H_ */
159