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