jemalloc.h revision 234402
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 "1.0.0-266-gb57d3ec571c6551231be62b7bf92c084a8c8291c"
11#define	JEMALLOC_VERSION_MAJOR 1
12#define	JEMALLOC_VERSION_MINOR 0
13#define	JEMALLOC_VERSION_BUGFIX 0
14#define	JEMALLOC_VERSION_NREV 266
15#define	JEMALLOC_VERSION_GID "b57d3ec571c6551231be62b7bf92c084a8c8291c"
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
30#define	ALLOCM_SUCCESS		0
31#define	ALLOCM_ERR_OOM		1
32#define	ALLOCM_ERR_NOT_MOVED	2
33#endif
34
35/*
36 * The je_ prefix on the following public symbol declarations is an artifact of
37 * namespace management, and should be omitted in application code unless
38 * JEMALLOC_NO_DEMANGLE is defined (see below).
39 */
40extern const char	*je_malloc_conf;
41extern void		(*je_malloc_message)(void *, const char *);
42
43void	*je_malloc(size_t size) JEMALLOC_ATTR(malloc);
44void	*je_calloc(size_t num, size_t size) JEMALLOC_ATTR(malloc);
45int	je_posix_memalign(void **memptr, size_t alignment, size_t size)
46    JEMALLOC_ATTR(nonnull(1));
47void	*je_aligned_alloc(size_t alignment, size_t size) JEMALLOC_ATTR(malloc);
48void	*je_realloc(void *ptr, size_t size);
49void	je_free(void *ptr);
50
51size_t	je_malloc_usable_size(const void *ptr);
52void	je_malloc_stats_print(void (*write_cb)(void *, const char *),
53    void *je_cbopaque, const char *opts);
54int	je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
55    size_t newlen);
56int	je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp);
57int	je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
58    size_t *oldlenp, void *newp, size_t newlen);
59
60#ifdef JEMALLOC_EXPERIMENTAL
61int	je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
62    JEMALLOC_ATTR(nonnull(1));
63int	je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
64    int flags) JEMALLOC_ATTR(nonnull(1));
65int	je_sallocm(const void *ptr, size_t *rsize, int flags)
66    JEMALLOC_ATTR(nonnull(1));
67int	je_dallocm(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
68int	je_nallocm(size_t *rsize, size_t size, int flags);
69#endif
70
71/*
72 * By default application code must explicitly refer to mangled symbol names,
73 * so that it is possible to use jemalloc in conjunction with another allocator
74 * in the same application.  Define JEMALLOC_MANGLE in order to cause automatic
75 * name mangling that matches the API prefixing that happened as a result of
76 * --with-mangling and/or --with-jemalloc-prefix configuration settings.
77 */
78#ifdef JEMALLOC_MANGLE
79#ifndef JEMALLOC_NO_DEMANGLE
80#define	JEMALLOC_NO_DEMANGLE
81#endif
82#define	malloc_conf je_malloc_conf
83#define	malloc_message je_malloc_message
84#define	malloc je_malloc
85#define	calloc je_calloc
86#define	posix_memalign je_posix_memalign
87#define	aligned_alloc je_aligned_alloc
88#define	realloc je_realloc
89#define	free je_free
90#define	malloc_usable_size je_malloc_usable_size
91#define	malloc_stats_print je_malloc_stats_print
92#define	mallctl je_mallctl
93#define	mallctlnametomib je_mallctlnametomib
94#define	mallctlbymib je_mallctlbymib
95#define	memalign je_memalign
96#define	valloc je_valloc
97#ifdef JEMALLOC_EXPERIMENTAL
98#define	allocm je_allocm
99#define	rallocm je_rallocm
100#define	sallocm je_sallocm
101#define	dallocm je_dallocm
102#define	nallocm je_nallocm
103#endif
104#endif
105
106/*
107 * The je_* macros can be used as stable alternative names for the public
108 * jemalloc API if JEMALLOC_NO_DEMANGLE is defined.  This is primarily meant
109 * for use in jemalloc itself, but it can be used by application code to
110 * provide isolation from the name mangling specified via --with-mangling
111 * and/or --with-jemalloc-prefix.
112 */
113#ifndef JEMALLOC_NO_DEMANGLE
114#undef je_malloc_conf
115#undef je_malloc_message
116#undef je_malloc
117#undef je_calloc
118#undef je_posix_memalign
119#undef je_aligned_alloc
120#undef je_realloc
121#undef je_free
122#undef je_malloc_usable_size
123#undef je_malloc_stats_print
124#undef je_mallctl
125#undef je_mallctlnametomib
126#undef je_mallctlbymib
127#undef je_memalign
128#undef je_valloc
129#ifdef JEMALLOC_EXPERIMENTAL
130#undef je_allocm
131#undef je_rallocm
132#undef je_sallocm
133#undef je_dallocm
134#undef je_nallocm
135#endif
136#endif
137
138#ifdef __cplusplus
139};
140#endif
141#endif /* JEMALLOC_H_ */
142