• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include "jemalloc/internal/jemalloc_preamble.h"
2 #include "jemalloc/internal/sz.h"
3 
4 JEMALLOC_ALIGNED(CACHELINE)
5 const size_t sz_pind2sz_tab[NPSIZES+1] = {
6 #define PSZ_yes(lg_grp, ndelta, lg_delta)				\
7 	(((ZU(1)<<lg_grp) + (ZU(ndelta)<<lg_delta))),
8 #define PSZ_no(lg_grp, ndelta, lg_delta)
9 #define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
10 	PSZ_##psz(lg_grp, ndelta, lg_delta)
11 	SIZE_CLASSES
12 #undef PSZ_yes
13 #undef PSZ_no
14 #undef SC
15 	(LARGE_MAXCLASS + PAGE)
16 };
17 
18 JEMALLOC_ALIGNED(CACHELINE)
19 const size_t sz_index2size_tab[NSIZES] = {
20 #define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
21 	((ZU(1)<<lg_grp) + (ZU(ndelta)<<lg_delta)),
22 	SIZE_CLASSES
23 #undef SC
24 };
25 
26 JEMALLOC_ALIGNED(CACHELINE)
27 const uint8_t sz_size2index_tab[] = {
28 #if LG_TINY_MIN == 0
29 /* The div module doesn't support division by 1. */
30 #error "Unsupported LG_TINY_MIN"
31 #define S2B_0(i)	i,
32 #elif LG_TINY_MIN == 1
33 #warning "Dangerous LG_TINY_MIN"
34 #define S2B_1(i)	i,
35 #elif LG_TINY_MIN == 2
36 #warning "Dangerous LG_TINY_MIN"
37 #define S2B_2(i)	i,
38 #elif LG_TINY_MIN == 3
39 #define S2B_3(i)	i,
40 #elif LG_TINY_MIN == 4
41 #define S2B_4(i)	i,
42 #elif LG_TINY_MIN == 5
43 #define S2B_5(i)	i,
44 #elif LG_TINY_MIN == 6
45 #define S2B_6(i)	i,
46 #elif LG_TINY_MIN == 7
47 #define S2B_7(i)	i,
48 #elif LG_TINY_MIN == 8
49 #define S2B_8(i)	i,
50 #elif LG_TINY_MIN == 9
51 #define S2B_9(i)	i,
52 #elif LG_TINY_MIN == 10
53 #define S2B_10(i)	i,
54 #elif LG_TINY_MIN == 11
55 #define S2B_11(i)	i,
56 #else
57 #error "Unsupported LG_TINY_MIN"
58 #endif
59 #if LG_TINY_MIN < 1
60 #define S2B_1(i)	S2B_0(i) S2B_0(i)
61 #endif
62 #if LG_TINY_MIN < 2
63 #define S2B_2(i)	S2B_1(i) S2B_1(i)
64 #endif
65 #if LG_TINY_MIN < 3
66 #define S2B_3(i)	S2B_2(i) S2B_2(i)
67 #endif
68 #if LG_TINY_MIN < 4
69 #define S2B_4(i)	S2B_3(i) S2B_3(i)
70 #endif
71 #if LG_TINY_MIN < 5
72 #define S2B_5(i)	S2B_4(i) S2B_4(i)
73 #endif
74 #if LG_TINY_MIN < 6
75 #define S2B_6(i)	S2B_5(i) S2B_5(i)
76 #endif
77 #if LG_TINY_MIN < 7
78 #define S2B_7(i)	S2B_6(i) S2B_6(i)
79 #endif
80 #if LG_TINY_MIN < 8
81 #define S2B_8(i)	S2B_7(i) S2B_7(i)
82 #endif
83 #if LG_TINY_MIN < 9
84 #define S2B_9(i)	S2B_8(i) S2B_8(i)
85 #endif
86 #if LG_TINY_MIN < 10
87 #define S2B_10(i)	S2B_9(i) S2B_9(i)
88 #endif
89 #if LG_TINY_MIN < 11
90 #define S2B_11(i)	S2B_10(i) S2B_10(i)
91 #endif
92 #define S2B_no(i)
93 #define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
94 	S2B_##lg_delta_lookup(index)
95 	SIZE_CLASSES
96 #undef S2B_3
97 #undef S2B_4
98 #undef S2B_5
99 #undef S2B_6
100 #undef S2B_7
101 #undef S2B_8
102 #undef S2B_9
103 #undef S2B_10
104 #undef S2B_11
105 #undef S2B_no
106 #undef SC
107 };
108