]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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 | ||
54a0048b | 14 | # define MALLOCX_LG_ALIGN(la) ((int)(la)) |
1a4d82fc | 15 | # if LG_SIZEOF_PTR == 2 |
54a0048b | 16 | # define MALLOCX_ALIGN(a) ((int)(ffs(a)-1)) |
1a4d82fc JJ |
17 | # else |
18 | # define MALLOCX_ALIGN(a) \ | |
54a0048b SL |
19 | ((int)(((a) < (size_t)INT_MAX) ? ffs((int)(a))-1 : \ |
20 | ffs((int)((a)>>32))+31)) | |
1a4d82fc JJ |
21 | # endif |
22 | # define MALLOCX_ZERO ((int)0x40) | |
54a0048b SL |
23 | /* |
24 | * Bias tcache index bits so that 0 encodes "automatic tcache management", and 1 | |
25 | * encodes MALLOCX_TCACHE_NONE. | |
26 | */ | |
27 | # define MALLOCX_TCACHE(tc) ((int)(((tc)+2) << 8)) | |
28 | # define MALLOCX_TCACHE_NONE MALLOCX_TCACHE(-1) | |
29 | /* | |
30 | * Bias arena index bits so that 0 encodes "use an automatically chosen arena". | |
31 | */ | |
32 | # define MALLOCX_ARENA(a) ((int)(((a)+1) << 20)) | |
1a4d82fc | 33 | |
54a0048b SL |
34 | #if defined(__cplusplus) && defined(JEMALLOC_USE_CXX_THROW) |
35 | # define JEMALLOC_CXX_THROW throw() | |
36 | #else | |
37 | # define JEMALLOC_CXX_THROW | |
38 | #endif | |
39 | ||
40 | #if _MSC_VER | |
1a4d82fc | 41 | # define JEMALLOC_ATTR(s) |
54a0048b SL |
42 | # define JEMALLOC_ALIGNED(s) __declspec(align(s)) |
43 | # define JEMALLOC_ALLOC_SIZE(s) | |
44 | # define JEMALLOC_ALLOC_SIZE2(s1, s2) | |
45 | # ifndef JEMALLOC_EXPORT | |
46 | # ifdef DLLEXPORT | |
47 | # define JEMALLOC_EXPORT __declspec(dllexport) | |
48 | # else | |
49 | # define JEMALLOC_EXPORT __declspec(dllimport) | |
50 | # endif | |
51 | # endif | |
52 | # define JEMALLOC_FORMAT_PRINTF(s, i) | |
53 | # define JEMALLOC_NOINLINE __declspec(noinline) | |
54 | # ifdef __cplusplus | |
55 | # define JEMALLOC_NOTHROW __declspec(nothrow) | |
1a4d82fc | 56 | # else |
54a0048b | 57 | # define JEMALLOC_NOTHROW |
1a4d82fc | 58 | # endif |
1a4d82fc | 59 | # define JEMALLOC_SECTION(s) __declspec(allocate(s)) |
54a0048b SL |
60 | # define JEMALLOC_RESTRICT_RETURN __declspec(restrict) |
61 | # if _MSC_VER >= 1900 && !defined(__EDG__) | |
62 | # define JEMALLOC_ALLOCATOR __declspec(allocator) | |
63 | # else | |
64 | # define JEMALLOC_ALLOCATOR | |
65 | # endif | |
66 | #elif defined(JEMALLOC_HAVE_ATTR) | |
67 | # define JEMALLOC_ATTR(s) __attribute__((s)) | |
68 | # define JEMALLOC_ALIGNED(s) JEMALLOC_ATTR(aligned(s)) | |
69 | # ifdef JEMALLOC_HAVE_ATTR_ALLOC_SIZE | |
70 | # define JEMALLOC_ALLOC_SIZE(s) JEMALLOC_ATTR(alloc_size(s)) | |
71 | # define JEMALLOC_ALLOC_SIZE2(s1, s2) JEMALLOC_ATTR(alloc_size(s1, s2)) | |
72 | # else | |
73 | # define JEMALLOC_ALLOC_SIZE(s) | |
74 | # define JEMALLOC_ALLOC_SIZE2(s1, s2) | |
75 | # endif | |
76 | # ifndef JEMALLOC_EXPORT | |
77 | # define JEMALLOC_EXPORT JEMALLOC_ATTR(visibility("default")) | |
78 | # endif | |
79 | # ifdef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF | |
80 | # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(gnu_printf, s, i)) | |
81 | # elif defined(JEMALLOC_HAVE_ATTR_FORMAT_PRINTF) | |
82 | # define JEMALLOC_FORMAT_PRINTF(s, i) JEMALLOC_ATTR(format(printf, s, i)) | |
83 | # else | |
84 | # define JEMALLOC_FORMAT_PRINTF(s, i) | |
85 | # endif | |
86 | # define JEMALLOC_NOINLINE JEMALLOC_ATTR(noinline) | |
87 | # define JEMALLOC_NOTHROW JEMALLOC_ATTR(nothrow) | |
88 | # define JEMALLOC_SECTION(s) JEMALLOC_ATTR(section(s)) | |
89 | # define JEMALLOC_RESTRICT_RETURN | |
90 | # define JEMALLOC_ALLOCATOR | |
1a4d82fc JJ |
91 | #else |
92 | # define JEMALLOC_ATTR(s) | |
7453a54e | 93 | # define JEMALLOC_ALIGNED(s) |
54a0048b SL |
94 | # define JEMALLOC_ALLOC_SIZE(s) |
95 | # define JEMALLOC_ALLOC_SIZE2(s1, s2) | |
96 | # define JEMALLOC_EXPORT | |
97 | # define JEMALLOC_FORMAT_PRINTF(s, i) | |
7453a54e | 98 | # define JEMALLOC_NOINLINE |
54a0048b SL |
99 | # define JEMALLOC_NOTHROW |
100 | # define JEMALLOC_SECTION(s) | |
101 | # define JEMALLOC_RESTRICT_RETURN | |
102 | # define JEMALLOC_ALLOCATOR | |
1a4d82fc | 103 | #endif |