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