xref: /freebsd/contrib/jemalloc/src/sz.c (revision f0cfa1b168014f56c02b83e5f28412cc5f78d117)
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 #warning "Dangerous LG_TINY_MIN"
30 #define S2B_0(i)	i,
31 #elif LG_TINY_MIN == 1
32 #warning "Dangerous LG_TINY_MIN"
33 #define S2B_1(i)	i,
34 #elif LG_TINY_MIN == 2
35 #warning "Dangerous LG_TINY_MIN"
36 #define S2B_2(i)	i,
37 #elif LG_TINY_MIN == 3
38 #define S2B_3(i)	i,
39 #elif LG_TINY_MIN == 4
40 #define S2B_4(i)	i,
41 #elif LG_TINY_MIN == 5
42 #define S2B_5(i)	i,
43 #elif LG_TINY_MIN == 6
44 #define S2B_6(i)	i,
45 #elif LG_TINY_MIN == 7
46 #define S2B_7(i)	i,
47 #elif LG_TINY_MIN == 8
48 #define S2B_8(i)	i,
49 #elif LG_TINY_MIN == 9
50 #define S2B_9(i)	i,
51 #elif LG_TINY_MIN == 10
52 #define S2B_10(i)	i,
53 #elif LG_TINY_MIN == 11
54 #define S2B_11(i)	i,
55 #else
56 #error "Unsupported LG_TINY_MIN"
57 #endif
58 #if LG_TINY_MIN < 1
59 #define S2B_1(i)	S2B_0(i) S2B_0(i)
60 #endif
61 #if LG_TINY_MIN < 2
62 #define S2B_2(i)	S2B_1(i) S2B_1(i)
63 #endif
64 #if LG_TINY_MIN < 3
65 #define S2B_3(i)	S2B_2(i) S2B_2(i)
66 #endif
67 #if LG_TINY_MIN < 4
68 #define S2B_4(i)	S2B_3(i) S2B_3(i)
69 #endif
70 #if LG_TINY_MIN < 5
71 #define S2B_5(i)	S2B_4(i) S2B_4(i)
72 #endif
73 #if LG_TINY_MIN < 6
74 #define S2B_6(i)	S2B_5(i) S2B_5(i)
75 #endif
76 #if LG_TINY_MIN < 7
77 #define S2B_7(i)	S2B_6(i) S2B_6(i)
78 #endif
79 #if LG_TINY_MIN < 8
80 #define S2B_8(i)	S2B_7(i) S2B_7(i)
81 #endif
82 #if LG_TINY_MIN < 9
83 #define S2B_9(i)	S2B_8(i) S2B_8(i)
84 #endif
85 #if LG_TINY_MIN < 10
86 #define S2B_10(i)	S2B_9(i) S2B_9(i)
87 #endif
88 #if LG_TINY_MIN < 11
89 #define S2B_11(i)	S2B_10(i) S2B_10(i)
90 #endif
91 #define S2B_no(i)
92 #define SC(index, lg_grp, lg_delta, ndelta, psz, bin, pgs, lg_delta_lookup) \
93 	S2B_##lg_delta_lookup(index)
94 	SIZE_CLASSES
95 #undef S2B_3
96 #undef S2B_4
97 #undef S2B_5
98 #undef S2B_6
99 #undef S2B_7
100 #undef S2B_8
101 #undef S2B_9
102 #undef S2B_10
103 #undef S2B_11
104 #undef S2B_no
105 #undef SC
106 };
107