2009-12-29 16:09:15 +08:00
|
|
|
#ifndef JEMALLOC_H_
|
|
|
|
#define JEMALLOC_H_
|
2009-06-26 09:06:48 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
Add {,r,s,d}allocm().
Add allocm(), rallocm(), sallocm(), and dallocm(), which are a
functional superset of malloc(), calloc(), posix_memalign(),
malloc_usable_size(), and free().
2010-09-18 06:46:18 +08:00
|
|
|
#include <strings.h>
|
|
|
|
|
2010-03-03 05:01:16 +08:00
|
|
|
#define JEMALLOC_VERSION "@jemalloc_version@"
|
|
|
|
#define JEMALLOC_VERSION_MAJOR @jemalloc_version_major@
|
|
|
|
#define JEMALLOC_VERSION_MINOR @jemalloc_version_minor@
|
|
|
|
#define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
|
|
|
|
#define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
|
|
|
|
#define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
|
|
|
|
|
2010-01-17 17:49:20 +08:00
|
|
|
#include "jemalloc_defs@install_suffix@.h"
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2012-03-03 09:47:37 +08:00
|
|
|
#ifdef JEMALLOC_EXPERIMENTAL
|
2011-01-27 00:24:24 +08:00
|
|
|
#define ALLOCM_LG_ALIGN(la) (la)
|
2012-04-03 05:09:07 +08:00
|
|
|
#define ALLOCM_ALIGN(a) (ffsl(a)-1)
|
Add {,r,s,d}allocm().
Add allocm(), rallocm(), sallocm(), and dallocm(), which are a
functional superset of malloc(), calloc(), posix_memalign(),
malloc_usable_size(), and free().
2010-09-18 06:46:18 +08:00
|
|
|
#define ALLOCM_ZERO ((int)0x40)
|
|
|
|
#define ALLOCM_NO_MOVE ((int)0x80)
|
|
|
|
|
|
|
|
#define ALLOCM_SUCCESS 0
|
|
|
|
#define ALLOCM_ERR_OOM 1
|
|
|
|
#define ALLOCM_ERR_NOT_MOVED 2
|
2012-03-03 09:47:37 +08:00
|
|
|
#endif
|
Add {,r,s,d}allocm().
Add allocm(), rallocm(), sallocm(), and dallocm(), which are a
functional superset of malloc(), calloc(), posix_memalign(),
malloc_usable_size(), and free().
2010-09-18 06:46:18 +08:00
|
|
|
|
2012-03-02 09:19:20 +08:00
|
|
|
/*
|
|
|
|
* The je_ prefix on the following public symbol declarations is an artifact of
|
|
|
|
* namespace management, and should be omitted in application code unless
|
|
|
|
* JEMALLOC_NO_DEMANGLE is defined (see below).
|
|
|
|
*/
|
|
|
|
extern const char *je_malloc_conf;
|
|
|
|
extern void (*je_malloc_message)(void *, const char *);
|
2010-01-04 04:10:42 +08:00
|
|
|
|
2012-03-02 09:19:20 +08:00
|
|
|
void *je_malloc(size_t size) JEMALLOC_ATTR(malloc);
|
|
|
|
void *je_calloc(size_t num, size_t size) JEMALLOC_ATTR(malloc);
|
|
|
|
int je_posix_memalign(void **memptr, size_t alignment, size_t size)
|
2010-01-04 03:59:20 +08:00
|
|
|
JEMALLOC_ATTR(nonnull(1));
|
2012-03-14 03:55:21 +08:00
|
|
|
void *je_aligned_alloc(size_t alignment, size_t size) JEMALLOC_ATTR(malloc);
|
2012-03-02 09:19:20 +08:00
|
|
|
void *je_realloc(void *ptr, size_t size);
|
|
|
|
void je_free(void *ptr);
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2012-03-02 09:19:20 +08:00
|
|
|
size_t je_malloc_usable_size(const void *ptr);
|
|
|
|
void je_malloc_stats_print(void (*write_cb)(void *, const char *),
|
|
|
|
void *je_cbopaque, const char *opts);
|
|
|
|
int je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
|
|
|
|
size_t newlen);
|
|
|
|
int je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp);
|
|
|
|
int je_mallctlbymib(const size_t *mib, size_t miblen, void *oldp,
|
2010-01-28 05:10:55 +08:00
|
|
|
size_t *oldlenp, void *newp, size_t newlen);
|
2009-06-26 09:06:48 +08:00
|
|
|
|
2012-03-03 09:47:37 +08:00
|
|
|
#ifdef JEMALLOC_EXPERIMENTAL
|
2012-03-02 09:19:20 +08:00
|
|
|
int je_allocm(void **ptr, size_t *rsize, size_t size, int flags)
|
2010-09-18 08:35:42 +08:00
|
|
|
JEMALLOC_ATTR(nonnull(1));
|
2012-03-02 09:19:20 +08:00
|
|
|
int je_rallocm(void **ptr, size_t *rsize, size_t size, size_t extra,
|
|
|
|
int flags) JEMALLOC_ATTR(nonnull(1));
|
|
|
|
int je_sallocm(const void *ptr, size_t *rsize, int flags)
|
2010-09-18 08:35:42 +08:00
|
|
|
JEMALLOC_ATTR(nonnull(1));
|
2012-03-02 09:19:20 +08:00
|
|
|
int je_dallocm(void *ptr, int flags) JEMALLOC_ATTR(nonnull(1));
|
|
|
|
int je_nallocm(size_t *rsize, size_t size, int flags);
|
2012-03-03 09:47:37 +08:00
|
|
|
#endif
|
2012-03-02 09:19:20 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* By default application code must explicitly refer to mangled symbol names,
|
|
|
|
* so that it is possible to use jemalloc in conjunction with another allocator
|
|
|
|
* in the same application. Define JEMALLOC_MANGLE in order to cause automatic
|
|
|
|
* name mangling that matches the API prefixing that happened as a result of
|
|
|
|
* --with-mangling and/or --with-jemalloc-prefix configuration settings.
|
|
|
|
*/
|
|
|
|
#ifdef JEMALLOC_MANGLE
|
|
|
|
#ifndef JEMALLOC_NO_DEMANGLE
|
|
|
|
#define JEMALLOC_NO_DEMANGLE
|
|
|
|
#endif
|
|
|
|
#define malloc_conf je_malloc_conf
|
|
|
|
#define malloc_message je_malloc_message
|
|
|
|
#define malloc je_malloc
|
|
|
|
#define calloc je_calloc
|
|
|
|
#define posix_memalign je_posix_memalign
|
2012-03-14 03:55:21 +08:00
|
|
|
#define aligned_alloc je_aligned_alloc
|
2012-03-02 09:19:20 +08:00
|
|
|
#define realloc je_realloc
|
|
|
|
#define free je_free
|
|
|
|
#define malloc_usable_size je_malloc_usable_size
|
|
|
|
#define malloc_stats_print je_malloc_stats_print
|
|
|
|
#define mallctl je_mallctl
|
|
|
|
#define mallctlnametomib je_mallctlnametomib
|
|
|
|
#define mallctlbymib je_mallctlbymib
|
|
|
|
#define memalign je_memalign
|
|
|
|
#define valloc je_valloc
|
2012-03-03 09:47:37 +08:00
|
|
|
#ifdef JEMALLOC_EXPERIMENTAL
|
2012-03-02 09:19:20 +08:00
|
|
|
#define allocm je_allocm
|
|
|
|
#define rallocm je_rallocm
|
|
|
|
#define sallocm je_sallocm
|
2012-03-02 09:53:16 +08:00
|
|
|
#define dallocm je_dallocm
|
|
|
|
#define nallocm je_nallocm
|
2012-03-02 09:19:20 +08:00
|
|
|
#endif
|
2012-03-03 09:47:37 +08:00
|
|
|
#endif
|
2012-03-02 09:19:20 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The je_* macros can be used as stable alternative names for the public
|
|
|
|
* jemalloc API if JEMALLOC_NO_DEMANGLE is defined. This is primarily meant
|
|
|
|
* for use in jemalloc itself, but it can be used by application code to
|
|
|
|
* provide isolation from the name mangling specified via --with-mangling
|
|
|
|
* and/or --with-jemalloc-prefix.
|
|
|
|
*/
|
|
|
|
#ifndef JEMALLOC_NO_DEMANGLE
|
|
|
|
#undef je_malloc_conf
|
|
|
|
#undef je_malloc_message
|
|
|
|
#undef je_malloc
|
|
|
|
#undef je_calloc
|
|
|
|
#undef je_posix_memalign
|
2012-03-14 03:55:21 +08:00
|
|
|
#undef je_aligned_alloc
|
2012-03-02 09:19:20 +08:00
|
|
|
#undef je_realloc
|
|
|
|
#undef je_free
|
|
|
|
#undef je_malloc_usable_size
|
|
|
|
#undef je_malloc_stats_print
|
|
|
|
#undef je_mallctl
|
|
|
|
#undef je_mallctlnametomib
|
|
|
|
#undef je_mallctlbymib
|
|
|
|
#undef je_memalign
|
|
|
|
#undef je_valloc
|
2012-03-03 09:47:37 +08:00
|
|
|
#ifdef JEMALLOC_EXPERIMENTAL
|
2012-03-02 09:19:20 +08:00
|
|
|
#undef je_allocm
|
|
|
|
#undef je_rallocm
|
|
|
|
#undef je_sallocm
|
2012-03-02 09:53:16 +08:00
|
|
|
#undef je_dallocm
|
|
|
|
#undef je_nallocm
|
2012-03-02 09:19:20 +08:00
|
|
|
#endif
|
2012-03-03 09:47:37 +08:00
|
|
|
#endif
|
Add {,r,s,d}allocm().
Add allocm(), rallocm(), sallocm(), and dallocm(), which are a
functional superset of malloc(), calloc(), posix_memalign(),
malloc_usable_size(), and free().
2010-09-18 06:46:18 +08:00
|
|
|
|
2009-06-26 09:06:48 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
};
|
|
|
|
#endif
|
2009-12-29 16:09:15 +08:00
|
|
|
#endif /* JEMALLOC_H_ */
|