Home | History | Annotate | Line # | Download | only in jemalloc
      1  1.1  christos #ifndef JEMALLOC_H_
      2  1.1  christos #define JEMALLOC_H_
      3  1.1  christos #pragma GCC system_header
      4  1.1  christos 
      5  1.1  christos /* Defined if __attribute__((...)) syntax is supported. */
      6  1.1  christos #define JEMALLOC_HAVE_ATTR
      7  1.1  christos 
      8  1.1  christos /* Defined if alloc_size attribute is supported. */
      9  1.1  christos #define JEMALLOC_HAVE_ATTR_ALLOC_SIZE
     10  1.1  christos 
     11  1.1  christos /* Defined if format_arg(...) attribute is supported. */
     12  1.1  christos #define JEMALLOC_HAVE_ATTR_FORMAT_ARG
     13  1.1  christos 
     14  1.1  christos /* Defined if format(gnu_printf, ...) attribute is supported. */
     15  1.1  christos #ifndef __clang__
     16  1.1  christos #define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
     17  1.1  christos #endif
     18  1.1  christos 
     19  1.1  christos /* Defined if format(printf, ...) attribute is supported. */
     20  1.1  christos #define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
     21  1.1  christos 
     22  1.1  christos /* Defined if fallthrough attribute is supported. */
     23  1.1  christos #define JEMALLOC_HAVE_ATTR_FALLTHROUGH
     24  1.1  christos 
     25  1.1  christos /* Defined if cold attribute is supported. */
     26  1.1  christos #define JEMALLOC_HAVE_ATTR_COLD
     27  1.1  christos 
     28  1.1  christos /* Defined if deprecated attribute is supported. */
     29  1.1  christos #define JEMALLOC_HAVE_ATTR_DEPRECATED
     30  1.1  christos 
     31  1.1  christos /*
     32  1.1  christos  * Define overrides for non-standard allocator-related functions if they are
     33  1.1  christos  * present on the system.
     34  1.1  christos  */
     35  1.1  christos /* #undef JEMALLOC_OVERRIDE_MEMALIGN */
     36  1.1  christos #define JEMALLOC_OVERRIDE_VALLOC
     37  1.1  christos /* #undef JEMALLOC_OVERRIDE_PVALLOC */
     38  1.1  christos 
     39  1.1  christos /*
     40  1.1  christos  * At least Linux omits the "const" in:
     41  1.1  christos  *
     42  1.1  christos  *   size_t malloc_usable_size(const void *ptr);
     43  1.1  christos  *
     44  1.1  christos  * Match the operating system's prototype.
     45  1.1  christos  */
     46  1.1  christos #define JEMALLOC_USABLE_SIZE_CONST const
     47  1.1  christos 
     48  1.1  christos /*
     49  1.1  christos  * If defined, specify throw() for the public function prototypes when compiling
     50  1.1  christos  * with C++.  The only justification for this is to match the prototypes that
     51  1.1  christos  * glibc defines.
     52  1.1  christos  */
     53  1.1  christos /* #undef JEMALLOC_USE_CXX_THROW */
     54  1.1  christos 
     55  1.1  christos /*
     56  1.1  christos  * If undefined, disables reading configuration from environment variable or file
     57  1.1  christos  */
     58  1.1  christos #define JEMALLOC_CONFIG_ENV
     59  1.1  christos #define JEMALLOC_CONFIG_FILE
     60  1.1  christos 
     61  1.1  christos #ifdef _MSC_VER
     62  1.1  christos #  ifdef _WIN64
     63  1.1  christos #    define LG_SIZEOF_PTR_WIN 3
     64  1.1  christos #  else
     65  1.1  christos #    define LG_SIZEOF_PTR_WIN 2
     66  1.1  christos #  endif
     67  1.1  christos #endif
     68  1.1  christos 
     69  1.1  christos /* sizeof(void *) == 2^LG_SIZEOF_PTR. */
     70  1.1  christos #ifdef _LP64
     71  1.1  christos #define LG_SIZEOF_PTR 3
     72  1.1  christos #else
     73  1.1  christos #define LG_SIZEOF_PTR 2
     74  1.1  christos #endif
     75  1.1  christos 
     76  1.1  christos /*
     77  1.1  christos  * Name mangling for public symbols is controlled by --with-mangling and
     78  1.1  christos  * --with-jemalloc-prefix.  With default settings the je_ prefix is stripped by
     79  1.1  christos  * these macro definitions.
     80  1.1  christos  */
     81  1.1  christos #ifndef JEMALLOC_NO_RENAME
     82  1.1  christos #  define je_aligned_alloc aligned_alloc
     83  1.1  christos #  define je_calloc calloc
     84  1.1  christos #  define je_free free
     85  1.1  christos #  define je_malloc malloc
     86  1.1  christos #  define je_posix_memalign posix_memalign
     87  1.1  christos #  define je_realloc realloc
     88  1.1  christos #  define je_valloc valloc
     89  1.1  christos 
     90  1.1  christos # ifndef JEMALLOC_PROTECT_NOSTD
     91  1.1  christos #  define je_dallocx dallocx
     92  1.1  christos #  define je_free_sized free_sized
     93  1.1  christos #  define je_free_aligned_sized free_aligned_sized
     94  1.1  christos #  define je_mallctl mallctl
     95  1.1  christos #  define je_mallctlbymib mallctlbymib
     96  1.1  christos #  define je_mallctlnametomib mallctlnametomib
     97  1.1  christos #  define je_malloc_conf malloc_conf
     98  1.1  christos #  define je_malloc_conf_get	malloc_conf_get
     99  1.1  christos #  define je_malloc_conf_set	malloc_conf_set
    100  1.1  christos #  define je_malloc_conf_2_conf_harder malloc_conf_2_conf_harder
    101  1.1  christos #  define je_malloc_message malloc_message
    102  1.1  christos #  define je_malloc_message_get	malloc_message_get
    103  1.1  christos #  define je_malloc_message_set	malloc_message_set
    104  1.1  christos #  define je_malloc_stats_print malloc_stats_print
    105  1.1  christos #  define je_malloc_usable_size malloc_usable_size
    106  1.1  christos #  define je_mallocx mallocx
    107  1.1  christos #  define je_smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8 smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8
    108  1.1  christos #  define je_nallocx nallocx
    109  1.1  christos #  define je_rallocx rallocx
    110  1.1  christos #  define je_sallocx sallocx
    111  1.1  christos #  define je_sdallocx sdallocx
    112  1.1  christos #  define je_xallocx xallocx
    113  1.1  christos #else
    114  1.1  christos #  define je_dallocx		__je_dallocx
    115  1.1  christos #  define je_free_sized 	__je_free_sized
    116  1.1  christos #  define je_free_aligned_sized __je_free_aligned_sized
    117  1.1  christos #  define je_mallctl		__je_mallctl
    118  1.1  christos #  define je_mallctlbymib	__je_mallctlbymib
    119  1.1  christos #  define je_mallctlnametomib	__je_mallctlnametomib
    120  1.1  christos #  define je_malloc_conf	__je_malloc_conf
    121  1.1  christos #  define je_malloc_conf_get	__je_malloc_conf_get
    122  1.1  christos #  define je_malloc_conf_set	__je_malloc_conf_set
    123  1.1  christos #  define je_malloc_conf_2_conf_harder __je_malloc_conf_2_conf_harder
    124  1.1  christos #  define je_malloc_message	__je_malloc_message
    125  1.1  christos #  define je_malloc_message_get	__je_malloc_message_get
    126  1.1  christos #  define je_malloc_message_set	__je_malloc_message_set
    127  1.1  christos #  define je_malloc_stats_print	__je_malloc_stats_print
    128  1.1  christos #  define je_malloc_usable_size	__je_malloc_usable_size
    129  1.1  christos #  define je_mallocx		__je_mallocx
    130  1.1  christos #  define je_smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8 __je_smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8
    131  1.1  christos #  define je_nallocx		__je_nallocx
    132  1.1  christos #  define je_rallocx		__je_rallocx
    133  1.1  christos #  define je_sallocx		__je_sallocx
    134  1.1  christos #  define je_sdallocx		__je_sdallocx
    135  1.1  christos #  define je_xallocx		__je_xallocx
    136  1.1  christos #endif
    137  1.1  christos #endif
    138  1.1  christos 
    139  1.1  christos #include <stdlib.h>
    140  1.1  christos #include <stdbool.h>
    141  1.1  christos #include <stdint.h>
    142  1.1  christos #include <limits.h>
    143  1.1  christos #include <strings.h>
    144  1.1  christos 
    145  1.1  christos #define JEMALLOC_VERSION "5.3.1-0-g81034ce1f1373e37dc865038e1bc8eeecf559ce8"
    146  1.1  christos #define JEMALLOC_VERSION_MAJOR 5
    147  1.1  christos #define JEMALLOC_VERSION_MINOR 3
    148  1.1  christos #define JEMALLOC_VERSION_BUGFIX 1
    149  1.1  christos #define JEMALLOC_VERSION_NREV 0
    150  1.1  christos #define JEMALLOC_VERSION_GID "81034ce1f1373e37dc865038e1bc8eeecf559ce8"
    151  1.1  christos #define JEMALLOC_VERSION_GID_IDENT 81034ce1f1373e37dc865038e1bc8eeecf559ce8
    152  1.1  christos 
    153  1.1  christos #define MALLOCX_LG_ALIGN(la)	((int)(la))
    154  1.1  christos #if LG_SIZEOF_PTR == 2
    155  1.1  christos #  define MALLOCX_ALIGN(a)	((int)(ffs((int)(a))-1))
    156  1.1  christos #else
    157  1.1  christos #  define MALLOCX_ALIGN(a)						\
    158  1.1  christos      ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 :	\
    159  1.1  christos      ffs((int)(((size_t)(a))>>32))+31))
    160  1.1  christos #endif
    161  1.1  christos #define MALLOCX_ZERO	((int)0x40)
    162  1.1  christos /*
    163  1.1  christos  * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
    164  1.1  christos  * encodes MALLOCX_TCACHE_NONE.
    165  1.1  christos  */
    166  1.1  christos #define MALLOCX_TCACHE(tc)	((int)(((tc)+2) << 8))
    167  1.1  christos #define MALLOCX_TCACHE_NONE	MALLOCX_TCACHE(-1)
    168  1.1  christos /*
    169  1.1  christos  * Bias arena index bits so that 0 encodes "use an automatically chosen arena".
    170  1.1  christos  */
    171  1.1  christos #define MALLOCX_ARENA(a)	((((int)(a))+1) << 20)
    172  1.1  christos 
    173  1.1  christos /*
    174  1.1  christos  * Use as arena index in "arena.<i>.{purge,decay,dss}" and
    175  1.1  christos  * "stats.arenas.<i>.*" mallctl interfaces to select all arenas.  This
    176  1.1  christos  * definition is intentionally specified in raw decimal format to support
    177  1.1  christos  * cpp-based string concatenation, e.g.
    178  1.1  christos  *
    179  1.1  christos  *   #define STRINGIFY_HELPER(x) #x
    180  1.1  christos  *   #define STRINGIFY(x) STRINGIFY_HELPER(x)
    181  1.1  christos  *
    182  1.1  christos  *   mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
    183  1.1  christos  *       0);
    184  1.1  christos  */
    185  1.1  christos #define MALLCTL_ARENAS_ALL	4096
    186  1.1  christos /*
    187  1.1  christos  * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
    188  1.1  christos  * destroyed arenas.
    189  1.1  christos  */
    190  1.1  christos #define MALLCTL_ARENAS_DESTROYED	4097
    191  1.1  christos 
    192  1.1  christos #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
    193  1.1  christos #  define JEMALLOC_CXX_THROW noexcept (true)
    194  1.1  christos #else
    195  1.1  christos #  define JEMALLOC_CXX_THROW
    196  1.1  christos #endif
    197  1.1  christos 
    198  1.1  christos #if defined(_MSC_VER)
    199  1.1  christos #  define JEMALLOC_ATTR(s)
    200  1.1  christos #  define JEMALLOC_ALIGNED(s) __declspec(align(s))
    201  1.1  christos #  define JEMALLOC_ALLOC_SIZE(s)
    202  1.1  christos #  define JEMALLOC_ALLOC_SIZE2(s1, s2)
    203  1.1  christos #  ifndef JEMALLOC_EXPORT
    204  1.1  christos #    ifdef DLLEXPORT
    205  1.1  christos #      define JEMALLOC_EXPORT __declspec(dllexport)
    206  1.1  christos #    else
    207  1.1  christos #      define JEMALLOC_EXPORT __declspec(dllimport)
    208  1.1  christos #    endif
    209  1.1  christos #  endif
    210  1.1  christos #  define JEMALLOC_FORMAT_ARG(i)
    211  1.1  christos #  define JEMALLOC_FORMAT_PRINTF(s, i)
    212  1.1  christos #  define JEMALLOC_FALLTHROUGH
    213  1.1  christos #  define JEMALLOC_NOINLINE __declspec(noinline)
    214  1.1  christos #  ifdef __cplusplus
    215  1.1  christos #    define JEMALLOC_NOTHROW __declspec(nothrow)
    216  1.1  christos #  else
    217  1.1  christos #    define JEMALLOC_NOTHROW
    218  1.1  christos #  endif
    219  1.1  christos #  define JEMALLOC_SECTION(s) __declspec(allocate(s))
    220  1.1  christos #  define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
    221  1.1  christos #  if _MSC_VER >= 1900 && !defined(__EDG__)
    222  1.1  christos #    define JEMALLOC_ALLOCATOR __declspec(allocator)
    223  1.1  christos #  else
    224  1.1  christos #    define JEMALLOC_ALLOCATOR
    225  1.1  christos #  endif
    226  1.1  christos #  define JEMALLOC_COLD
    227  1.1  christos #  define JEMALLOC_WARN_ON_USAGE(warning_message)
    228  1.1  christos #elif defined(JEMALLOC_HAVE_ATTR)
    229  1.1  christos #  define JEMALLOC_ATTR(s) __attribute__((s))
    230  1.1  christos #  define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
    231  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
    232  1.1  christos #    define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
    233  1.1  christos #    define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
    234  1.1  christos #  else
    235  1.1  christos #    define JEMALLOC_ALLOC_SIZE(s)
    236  1.1  christos #    define JEMALLOC_ALLOC_SIZE2(s1, s2)
    237  1.1  christos #  endif
    238  1.1  christos #  ifndef JEMALLOC_EXPORT
    239  1.1  christos #    define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
    240  1.1  christos #  endif
    241  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_FORMAT_ARG
    242  1.1  christos #    define JEMALLOC_FORMAT_ARG(i) JEMALLOC_ATTR(__format_arg__(3))
    243  1.1  christos #  else
    244  1.1  christos #    define JEMALLOC_FORMAT_ARG(i)
    245  1.1  christos #  endif
    246  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
    247  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
    248  1.1  christos #  elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
    249  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
    250  1.1  christos #  else
    251  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i)
    252  1.1  christos #  endif
    253  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_FALLTHROUGH
    254  1.1  christos #    define JEMALLOC_FALLTHROUGH JEMALLOC_ATTR(fallthrough)
    255  1.1  christos #  else
    256  1.1  christos #    define JEMALLOC_FALLTHROUGH
    257  1.1  christos #  endif
    258  1.1  christos #  define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
    259  1.1  christos #  define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
    260  1.1  christos #  define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
    261  1.1  christos #  define JEMALLOC_RESTRICT_RETURN
    262  1.1  christos #  define JEMALLOC_ALLOCATOR
    263  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_COLD
    264  1.1  christos #    define JEMALLOC_COLD JEMALLOC_ATTR(__cold__)
    265  1.1  christos #  else
    266  1.1  christos #    define JEMALLOC_COLD
    267  1.1  christos #  endif
    268  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_DEPRECATED
    269  1.1  christos #    define JEMALLOC_WARN_ON_USAGE(warning_message) JEMALLOC_ATTR(deprecated(warning_message))
    270  1.1  christos #  else
    271  1.1  christos #    define JEMALLOC_WARN_ON_USAGE(warning_message)
    272  1.1  christos #  endif
    273  1.1  christos #else
    274  1.1  christos #  define JEMALLOC_ATTR(s)
    275  1.1  christos #  define JEMALLOC_ALIGNED(s)
    276  1.1  christos #  define JEMALLOC_ALLOC_SIZE(s)
    277  1.1  christos #  define JEMALLOC_ALLOC_SIZE2(s1, s2)
    278  1.1  christos #  define JEMALLOC_EXPORT
    279  1.1  christos #  define JEMALLOC_FORMAT_PRINTF(s, i)
    280  1.1  christos #  define JEMALLOC_FALLTHROUGH
    281  1.1  christos #  define JEMALLOC_NOINLINE
    282  1.1  christos #  define JEMALLOC_NOTHROW
    283  1.1  christos #  define JEMALLOC_SECTION(s)
    284  1.1  christos #  define JEMALLOC_RESTRICT_RETURN
    285  1.1  christos #  define JEMALLOC_ALLOCATOR
    286  1.1  christos #  define JEMALLOC_COLD
    287  1.1  christos #  define JEMALLOC_WARN_ON_USAGE(warning_message)
    288  1.1  christos #endif
    289  1.1  christos 
    290  1.1  christos #if (defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__linux__) && !defined(__GLIBC__))) && !defined(JEMALLOC_NO_RENAME)
    291  1.1  christos #  define JEMALLOC_SYS_NOTHROW
    292  1.1  christos #else
    293  1.1  christos #  define JEMALLOC_SYS_NOTHROW JEMALLOC_NOTHROW
    294  1.1  christos #endif
    295  1.1  christos 
    296  1.1  christos /*
    297  1.1  christos  * The je_ prefix on the following public symbol declarations is an artifact
    298  1.1  christos  * of namespace management, and should be omitted in application code unless
    299  1.1  christos  * JEMALLOC_NO_DEMANGLE is defined (see jemalloc_mangle.h).
    300  1.1  christos  */
    301  1.1  christos #ifdef __cplusplus
    302  1.1  christos extern "C" {
    303  1.1  christos #endif
    304  1.1  christos 
    305  1.1  christos extern JEMALLOC_EXPORT const char	*je_malloc_conf;
    306  1.1  christos extern JEMALLOC_EXPORT const char	*je_malloc_conf_2_conf_harder;
    307  1.1  christos extern JEMALLOC_EXPORT void		(*je_malloc_message)(void *cbopaque,
    308  1.1  christos     const char *s);
    309  1.1  christos extern JEMALLOC_EXPORT const char	*je_malloc_conf_get(void);
    310  1.1  christos extern JEMALLOC_EXPORT void		je_malloc_conf_set(const char *);
    311  1.1  christos extern JEMALLOC_EXPORT void		(*je_malloc_message_get(void))
    312  1.1  christos     (void *cbopaque, const char *s);
    313  1.1  christos extern JEMALLOC_EXPORT void		je_malloc_message_set(
    314  1.1  christos     void (*)(void *cbopaque, const char *s));
    315  1.1  christos 
    316  1.1  christos 
    317  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    318  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_malloc(size_t size)
    319  1.1  christos     JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
    320  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    321  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_calloc(size_t num, size_t size)
    322  1.1  christos     JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE2(1, 2);
    323  1.1  christos JEMALLOC_EXPORT int JEMALLOC_SYS_NOTHROW je_posix_memalign(
    324  1.1  christos     void **memptr, size_t alignment, size_t size) JEMALLOC_CXX_THROW
    325  1.1  christos     JEMALLOC_ATTR(nonnull(1));
    326  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    327  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_aligned_alloc(size_t alignment,
    328  1.1  christos     size_t size) JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc)
    329  1.1  christos     JEMALLOC_ALLOC_SIZE(2);
    330  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    331  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_realloc(void *ptr, size_t size)
    332  1.1  christos     JEMALLOC_CXX_THROW JEMALLOC_ALLOC_SIZE(2);
    333  1.1  christos JEMALLOC_EXPORT void JEMALLOC_SYS_NOTHROW	je_free(void *ptr)
    334  1.1  christos     JEMALLOC_CXX_THROW;
    335  1.1  christos JEMALLOC_EXPORT void JEMALLOC_NOTHROW	je_free_sized(void *ptr, size_t size);
    336  1.1  christos JEMALLOC_EXPORT void JEMALLOC_NOTHROW	je_free_aligned_sized(
    337  1.1  christos     void *ptr, size_t alignment, size_t size);
    338  1.1  christos 
    339  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    340  1.1  christos     void JEMALLOC_NOTHROW	*je_mallocx(size_t size, int flags)
    341  1.1  christos     JEMALLOC_ATTR(malloc) JEMALLOC_ALLOC_SIZE(1);
    342  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    343  1.1  christos     void JEMALLOC_NOTHROW	*je_rallocx(void *ptr, size_t size,
    344  1.1  christos     int flags) JEMALLOC_ALLOC_SIZE(2);
    345  1.1  christos JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW	je_xallocx(void *ptr, size_t size,
    346  1.1  christos     size_t extra, int flags);
    347  1.1  christos JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW	je_sallocx(const void *ptr,
    348  1.1  christos     int flags) JEMALLOC_ATTR(pure);
    349  1.1  christos JEMALLOC_EXPORT void JEMALLOC_NOTHROW	je_dallocx(void *ptr, int flags);
    350  1.1  christos JEMALLOC_EXPORT void JEMALLOC_NOTHROW	je_sdallocx(void *ptr, size_t size,
    351  1.1  christos     int flags);
    352  1.1  christos JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW	je_nallocx(size_t size, int flags)
    353  1.1  christos     JEMALLOC_ATTR(pure);
    354  1.1  christos 
    355  1.1  christos JEMALLOC_EXPORT int JEMALLOC_NOTHROW	je_mallctl(const char *name,
    356  1.1  christos     void *oldp, size_t *oldlenp, void *newp, size_t newlen);
    357  1.1  christos JEMALLOC_EXPORT int JEMALLOC_NOTHROW	je_mallctlnametomib(const char *name,
    358  1.1  christos     size_t *mibp, size_t *miblenp);
    359  1.1  christos JEMALLOC_EXPORT int JEMALLOC_NOTHROW	je_mallctlbymib(const size_t *mib,
    360  1.1  christos     size_t miblen, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
    361  1.1  christos JEMALLOC_EXPORT void JEMALLOC_NOTHROW	je_malloc_stats_print(
    362  1.1  christos     void (*write_cb)(void *, const char *), void *je_cbopaque,
    363  1.1  christos     const char *opts);
    364  1.1  christos JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW	je_malloc_usable_size(
    365  1.1  christos     JEMALLOC_USABLE_SIZE_CONST void *ptr) JEMALLOC_CXX_THROW;
    366  1.1  christos #ifdef JEMALLOC_HAVE_MALLOC_SIZE
    367  1.1  christos JEMALLOC_EXPORT size_t JEMALLOC_NOTHROW	je_malloc_size(
    368  1.1  christos     const void *ptr);
    369  1.1  christos #endif
    370  1.1  christos 
    371  1.1  christos #ifdef JEMALLOC_OVERRIDE_MEMALIGN
    372  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    373  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_memalign(size_t alignment, size_t size)
    374  1.1  christos     JEMALLOC_CXX_THROW JEMALLOC_ATTR(malloc);
    375  1.1  christos #endif
    376  1.1  christos 
    377  1.1  christos #ifdef JEMALLOC_OVERRIDE_VALLOC
    378  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    379  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_valloc(size_t size) JEMALLOC_CXX_THROW
    380  1.1  christos     JEMALLOC_ATTR(malloc);
    381  1.1  christos #endif
    382  1.1  christos 
    383  1.1  christos #ifdef JEMALLOC_OVERRIDE_PVALLOC
    384  1.1  christos JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
    385  1.1  christos     void JEMALLOC_SYS_NOTHROW	*je_pvalloc(size_t size) JEMALLOC_CXX_THROW
    386  1.1  christos     JEMALLOC_ATTR(malloc);
    387  1.1  christos #endif
    388  1.1  christos 
    389  1.1  christos #ifdef __cplusplus
    390  1.1  christos }
    391  1.1  christos #endif
    392  1.1  christos 
    393  1.1  christos #ifdef __cplusplus
    394  1.1  christos extern "C" {
    395  1.1  christos #endif
    396  1.1  christos 
    397  1.1  christos typedef struct extent_hooks_s extent_hooks_t;
    398  1.1  christos 
    399  1.1  christos /*
    400  1.1  christos  * void *
    401  1.1  christos  * extent_alloc(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
    402  1.1  christos  *     size_t alignment, bool *zero, bool *commit, unsigned arena_ind);
    403  1.1  christos  */
    404  1.1  christos typedef void *(extent_alloc_t)(extent_hooks_t *, void *, size_t, size_t, bool *,
    405  1.1  christos     bool *, unsigned);
    406  1.1  christos 
    407  1.1  christos /*
    408  1.1  christos  * bool
    409  1.1  christos  * extent_dalloc(extent_hooks_t *extent_hooks, void *addr, size_t size,
    410  1.1  christos  *     bool committed, unsigned arena_ind);
    411  1.1  christos  */
    412  1.1  christos typedef bool (extent_dalloc_t)(extent_hooks_t *, void *, size_t, bool,
    413  1.1  christos     unsigned);
    414  1.1  christos 
    415  1.1  christos /*
    416  1.1  christos  * void
    417  1.1  christos  * extent_destroy(extent_hooks_t *extent_hooks, void *addr, size_t size,
    418  1.1  christos  *     bool committed, unsigned arena_ind);
    419  1.1  christos  */
    420  1.1  christos typedef void (extent_destroy_t)(extent_hooks_t *, void *, size_t, bool,
    421  1.1  christos     unsigned);
    422  1.1  christos 
    423  1.1  christos /*
    424  1.1  christos  * bool
    425  1.1  christos  * extent_commit(extent_hooks_t *extent_hooks, void *addr, size_t size,
    426  1.1  christos  *     size_t offset, size_t length, unsigned arena_ind);
    427  1.1  christos  */
    428  1.1  christos typedef bool (extent_commit_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
    429  1.1  christos     unsigned);
    430  1.1  christos 
    431  1.1  christos /*
    432  1.1  christos  * bool
    433  1.1  christos  * extent_decommit(extent_hooks_t *extent_hooks, void *addr, size_t size,
    434  1.1  christos  *     size_t offset, size_t length, unsigned arena_ind);
    435  1.1  christos  */
    436  1.1  christos typedef bool (extent_decommit_t)(extent_hooks_t *, void *, size_t, size_t,
    437  1.1  christos     size_t, unsigned);
    438  1.1  christos 
    439  1.1  christos /*
    440  1.1  christos  * bool
    441  1.1  christos  * extent_purge(extent_hooks_t *extent_hooks, void *addr, size_t size,
    442  1.1  christos  *     size_t offset, size_t length, unsigned arena_ind);
    443  1.1  christos  */
    444  1.1  christos typedef bool (extent_purge_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
    445  1.1  christos     unsigned);
    446  1.1  christos 
    447  1.1  christos /*
    448  1.1  christos  * bool
    449  1.1  christos  * extent_split(extent_hooks_t *extent_hooks, void *addr, size_t size,
    450  1.1  christos  *     size_t size_a, size_t size_b, bool committed, unsigned arena_ind);
    451  1.1  christos  */
    452  1.1  christos typedef bool (extent_split_t)(extent_hooks_t *, void *, size_t, size_t, size_t,
    453  1.1  christos     bool, unsigned);
    454  1.1  christos 
    455  1.1  christos /*
    456  1.1  christos  * bool
    457  1.1  christos  * extent_merge(extent_hooks_t *extent_hooks, void *addr_a, size_t size_a,
    458  1.1  christos  *     void *addr_b, size_t size_b, bool committed, unsigned arena_ind);
    459  1.1  christos  */
    460  1.1  christos typedef bool (extent_merge_t)(extent_hooks_t *, void *, size_t, void *, size_t,
    461  1.1  christos     bool, unsigned);
    462  1.1  christos 
    463  1.1  christos struct extent_hooks_s {
    464  1.1  christos 	extent_alloc_t		*alloc;
    465  1.1  christos 	extent_dalloc_t		*dalloc;
    466  1.1  christos 	extent_destroy_t	*destroy;
    467  1.1  christos 	extent_commit_t		*commit;
    468  1.1  christos 	extent_decommit_t	*decommit;
    469  1.1  christos 	extent_purge_t		*purge_lazy;
    470  1.1  christos 	extent_purge_t		*purge_forced;
    471  1.1  christos 	extent_split_t		*split;
    472  1.1  christos 	extent_merge_t		*merge;
    473  1.1  christos };
    474  1.1  christos 
    475  1.1  christos #ifdef __cplusplus
    476  1.1  christos }
    477  1.1  christos #endif
    478  1.1  christos 
    479  1.1  christos /*
    480  1.1  christos  * By default application code must explicitly refer to mangled symbol names,
    481  1.1  christos  * so that it is possible to use jemalloc in conjunction with another allocator
    482  1.1  christos  * in the same application.  Define JEMALLOC_MANGLE in order to cause automatic
    483  1.1  christos  * name mangling that matches the API prefixing that happened as a result of
    484  1.1  christos  * --with-mangling and/or --with-jemalloc-prefix configuration settings.
    485  1.1  christos  */
    486  1.1  christos #ifdef JEMALLOC_MANGLE
    487  1.1  christos #  ifndef JEMALLOC_NO_DEMANGLE
    488  1.1  christos #    define JEMALLOC_NO_DEMANGLE
    489  1.1  christos #  endif
    490  1.1  christos #  define aligned_alloc je_aligned_alloc
    491  1.1  christos #  define calloc je_calloc
    492  1.1  christos #  define dallocx je_dallocx
    493  1.1  christos #  define free je_free
    494  1.1  christos #  define free_sized je_free_sized
    495  1.1  christos #  define free_aligned_sized je_free_aligned_sized
    496  1.1  christos #  define mallctl je_mallctl
    497  1.1  christos #  define mallctlbymib je_mallctlbymib
    498  1.1  christos #  define mallctlnametomib je_mallctlnametomib
    499  1.1  christos #  define malloc je_malloc
    500  1.1  christos #  define malloc_conf je_malloc_conf
    501  1.1  christos #  define malloc_conf_2_conf_harder je_malloc_conf_2_conf_harder
    502  1.1  christos #  define malloc_message je_malloc_message
    503  1.1  christos #  define malloc_stats_print je_malloc_stats_print
    504  1.1  christos #  define malloc_usable_size je_malloc_usable_size
    505  1.1  christos #  define mallocx je_mallocx
    506  1.1  christos #  define smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8 je_smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8
    507  1.1  christos #  define nallocx je_nallocx
    508  1.1  christos #  define posix_memalign je_posix_memalign
    509  1.1  christos #  define rallocx je_rallocx
    510  1.1  christos #  define realloc je_realloc
    511  1.1  christos #  define sallocx je_sallocx
    512  1.1  christos #  define sdallocx je_sdallocx
    513  1.1  christos #  define xallocx je_xallocx
    514  1.1  christos #  define valloc je_valloc
    515  1.1  christos #endif
    516  1.1  christos 
    517  1.1  christos /*
    518  1.1  christos  * The je_* macros can be used as stable alternative names for the
    519  1.1  christos  * public jemalloc API if JEMALLOC_NO_DEMANGLE is defined.  This is primarily
    520  1.1  christos  * meant for use in jemalloc itself, but it can be used by application code to
    521  1.1  christos  * provide isolation from the name mangling specified via --with-mangling
    522  1.1  christos  * and/or --with-jemalloc-prefix.
    523  1.1  christos  */
    524  1.1  christos #ifndef JEMALLOC_NO_DEMANGLE
    525  1.1  christos #  undef je_aligned_alloc
    526  1.1  christos #  undef je_calloc
    527  1.1  christos #  undef je_dallocx
    528  1.1  christos #  undef je_free
    529  1.1  christos #  undef je_free_sized
    530  1.1  christos #  undef je_free_aligned_sized
    531  1.1  christos #  undef je_mallctl
    532  1.1  christos #  undef je_mallctlbymib
    533  1.1  christos #  undef je_mallctlnametomib
    534  1.1  christos #  undef je_malloc
    535  1.1  christos #  undef je_malloc_conf
    536  1.1  christos #  undef je_malloc_conf_2_conf_harder
    537  1.1  christos #  undef je_malloc_message
    538  1.1  christos #  undef je_malloc_stats_print
    539  1.1  christos #  undef je_malloc_usable_size
    540  1.1  christos #  undef je_mallocx
    541  1.1  christos #  undef je_smallocx_81034ce1f1373e37dc865038e1bc8eeecf559ce8
    542  1.1  christos #  undef je_nallocx
    543  1.1  christos #  undef je_posix_memalign
    544  1.1  christos #  undef je_rallocx
    545  1.1  christos #  undef je_realloc
    546  1.1  christos #  undef je_sallocx
    547  1.1  christos #  undef je_sdallocx
    548  1.1  christos #  undef je_xallocx
    549  1.1  christos #  undef je_valloc
    550  1.1  christos #endif
    551  1.1  christos 
    552  1.1  christos #endif /* JEMALLOC_H_ */
    553