Home | History | Annotate | Line # | Download | only in jemalloc
      1  1.1  christos #include <stdlib.h>
      2  1.1  christos #include <stdbool.h>
      3  1.1  christos #include <stdint.h>
      4  1.1  christos #include <limits.h>
      5  1.1  christos #include <strings.h>
      6  1.1  christos 
      7  1.1  christos #define JEMALLOC_VERSION "@jemalloc_version@"
      8  1.1  christos #define JEMALLOC_VERSION_MAJOR @jemalloc_version_major@
      9  1.1  christos #define JEMALLOC_VERSION_MINOR @jemalloc_version_minor@
     10  1.1  christos #define JEMALLOC_VERSION_BUGFIX @jemalloc_version_bugfix@
     11  1.1  christos #define JEMALLOC_VERSION_NREV @jemalloc_version_nrev@
     12  1.1  christos #define JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
     13  1.1  christos 
     14  1.1  christos #define MALLOCX_LG_ALIGN(la)	((int)(la))
     15  1.1  christos #if LG_SIZEOF_PTR == 2
     16  1.1  christos #  define MALLOCX_ALIGN(a)	((int)(ffs((int)(a))-1))
     17  1.1  christos #else
     18  1.1  christos #  define MALLOCX_ALIGN(a)						\
     19  1.1  christos      ((int)(((size_t)(a) < (size_t)INT_MAX) ? ffs((int)(a))-1 :	\
     20  1.1  christos      ffs((int)(((size_t)(a))>>32))+31))
     21  1.1  christos #endif
     22  1.1  christos #define MALLOCX_ZERO	((int)0x40)
     23  1.1  christos /*
     24  1.1  christos  * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1
     25  1.1  christos  * encodes MALLOCX_TCACHE_NONE.
     26  1.1  christos  */
     27  1.1  christos #define MALLOCX_TCACHE(tc)	((int)(((tc)+2) << 8))
     28  1.1  christos #define MALLOCX_TCACHE_NONE	MALLOCX_TCACHE(-1)
     29  1.1  christos /*
     30  1.1  christos  * Bias arena index bits so that 0 encodes "use an automatically chosen arena".
     31  1.1  christos  */
     32  1.1  christos #define MALLOCX_ARENA(a)	((((int)(a))+1) << 20)
     33  1.1  christos 
     34  1.1  christos /*
     35  1.1  christos  * Use as arena index in "arena.<i>.{purge,decay,dss}" and
     36  1.1  christos  * "stats.arenas.<i>.*" mallctl interfaces to select all arenas.  This
     37  1.1  christos  * definition is intentionally specified in raw decimal format to support
     38  1.1  christos  * cpp-based string concatenation, e.g.
     39  1.1  christos  *
     40  1.1  christos  *   #define STRINGIFY_HELPER(x) #x
     41  1.1  christos  *   #define STRINGIFY(x) STRINGIFY_HELPER(x)
     42  1.1  christos  *
     43  1.1  christos  *   mallctl("arena." STRINGIFY(MALLCTL_ARENAS_ALL) ".purge", NULL, NULL, NULL,
     44  1.1  christos  *       0);
     45  1.1  christos  */
     46  1.1  christos #define MALLCTL_ARENAS_ALL	4096
     47  1.1  christos /*
     48  1.1  christos  * Use as arena index in "stats.arenas.<i>.*" mallctl interfaces to select
     49  1.1  christos  * destroyed arenas.
     50  1.1  christos  */
     51  1.1  christos #define MALLCTL_ARENAS_DESTROYED	4097
     52  1.1  christos 
     53  1.1  christos #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW)
     54  1.1  christos #  define JEMALLOC_CXX_THROW throw()
     55  1.1  christos #else
     56  1.1  christos #  define JEMALLOC_CXX_THROW
     57  1.1  christos #endif
     58  1.1  christos 
     59  1.1  christos #if defined(_MSC_VER)
     60  1.1  christos #  define JEMALLOC_ATTR(s)
     61  1.1  christos #  define JEMALLOC_ALIGNED(s) __declspec(align(s))
     62  1.1  christos #  define JEMALLOC_ALLOC_SIZE(s)
     63  1.1  christos #  define JEMALLOC_ALLOC_SIZE2(s1, s2)
     64  1.1  christos #  ifndef JEMALLOC_EXPORT
     65  1.1  christos #    ifdef DLLEXPORT
     66  1.1  christos #      define JEMALLOC_EXPORT __declspec(dllexport)
     67  1.1  christos #    else
     68  1.1  christos #      define JEMALLOC_EXPORT __declspec(dllimport)
     69  1.1  christos #    endif
     70  1.1  christos #  endif
     71  1.1  christos #  define JEMALLOC_FORMAT_PRINTF(s, i)
     72  1.1  christos #  define JEMALLOC_NOINLINE __declspec(noinline)
     73  1.1  christos #  ifdef __cplusplus
     74  1.1  christos #    define JEMALLOC_NOTHROW __declspec(nothrow)
     75  1.1  christos #  else
     76  1.1  christos #    define JEMALLOC_NOTHROW
     77  1.1  christos #  endif
     78  1.1  christos #  define JEMALLOC_SECTION(s) __declspec(allocate(s))
     79  1.1  christos #  define JEMALLOC_RESTRICT_RETURN __declspec(restrict)
     80  1.1  christos #  if _MSC_VER >= 1900 && !defined(__EDG__)
     81  1.1  christos #    define JEMALLOC_ALLOCATOR __declspec(allocator)
     82  1.1  christos #  else
     83  1.1  christos #    define JEMALLOC_ALLOCATOR
     84  1.1  christos #  endif
     85  1.1  christos #elif defined(JEMALLOC_HAVE_ATTR)
     86  1.1  christos #  define JEMALLOC_ATTR(s) __attribute__((s))
     87  1.1  christos #  define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s))
     88  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE
     89  1.1  christos #    define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s))
     90  1.1  christos #    define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2))
     91  1.1  christos #  else
     92  1.1  christos #    define JEMALLOC_ALLOC_SIZE(s)
     93  1.1  christos #    define JEMALLOC_ALLOC_SIZE2(s1, s2)
     94  1.1  christos #  endif
     95  1.1  christos #  ifndef JEMALLOC_EXPORT
     96  1.1  christos #    define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default"))
     97  1.1  christos #  endif
     98  1.1  christos #  ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF
     99  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i))
    100  1.1  christos #  elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF)
    101  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i))
    102  1.1  christos #  else
    103  1.1  christos #    define JEMALLOC_FORMAT_PRINTF(s, i)
    104  1.1  christos #  endif
    105  1.1  christos #  define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline)
    106  1.1  christos #  define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow)
    107  1.1  christos #  define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s))
    108  1.1  christos #  define JEMALLOC_RESTRICT_RETURN
    109  1.1  christos #  define JEMALLOC_ALLOCATOR
    110  1.1  christos #else
    111  1.1  christos #  define JEMALLOC_ATTR(s)
    112  1.1  christos #  define JEMALLOC_ALIGNED(s)
    113  1.1  christos #  define JEMALLOC_ALLOC_SIZE(s)
    114  1.1  christos #  define JEMALLOC_ALLOC_SIZE2(s1, s2)
    115  1.1  christos #  define JEMALLOC_EXPORT
    116  1.1  christos #  define JEMALLOC_FORMAT_PRINTF(s, i)
    117  1.1  christos #  define JEMALLOC_NOINLINE
    118  1.1  christos #  define JEMALLOC_NOTHROW
    119  1.1  christos #  define JEMALLOC_SECTION(s)
    120  1.1  christos #  define JEMALLOC_RESTRICT_RETURN
    121  1.1  christos #  define JEMALLOC_ALLOCATOR
    122  1.1  christos #endif
    123