Debian Codegraph @

libs/klib/judy/Judy1.h

raw symbols SCIP
1 #cxx . . $ `<file>/libs/klib/judy/Judy1.h`/ifndef _JUDY1_INCLUDED
2 #define _JUDY1_INCLUDEDcxx . . $ `libs/klib/judy/Judy1.h:2:9`!
3 // _________________
4 //
5 // Copyright (C) 2000 - 2002 Hewlett-Packard Company
6 //
7 // This program is free software; you can redistribute it and/or modify it
8 // under the term of the GNU Lesser General Public License as published by the
9 // Free Software Foundation; either version 2 of the License, or (at your
10 // option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 // for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with this program; if not, write to the Free Software Foundation,
19 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // _________________
21
22 // ****************************************************************************
23 // JUDY1 -- SMALL/LARGE AND/OR CLUSTERED/SPARSE BIT ARRAYS
24 //
25 // -by-
26 //
27 // Douglas L. Baskins
28 // [email protected]
29 //
30 // Judy arrays are designed to be used instead of arrays. The performance
31 // suggests the reason why Judy arrays are thought of as arrays, instead of
32 // trees. They are remarkably memory efficient at all populations.
33 // Implemented as a hybrid digital tree (but really a state machine, see
34 // below), Judy arrays feature fast insert/retrievals, fast near neighbor
35 // searching, and contain a population tree for extremely fast ordinal related
36 // retrievals.
37 //
38 // CONVENTIONS:
39 //
40 // - The comments here refer to 32-bit [64-bit] systems.
41 //
42 // - BranchL, LeafL refer to linear branches and leaves (small populations),
43 // except LeafL does not actually appear as such; rather, Leaf1..3 [Leaf1..7]
44 // is used to represent leaf Index sizes, and LeafW refers to a Leaf with
45 // full (long) word Indexes, which is also a type of linear leaf. Note that
46 // root-level LeafW (Leaf4 [Leaf8]) leaves are also called LEAFW.
47 //
48 // - BranchB, LeafB1 refer to bitmap branches and leaves (intermediate
49 // populations).
50 //
51 // - BranchU refers to uncompressed branches. An uncompressed branch has 256
52 // JPs, some of which could be null. Note: All leaves are compressed (and
53 // sorted), or else an expanse is full (FullPopu), so there is no LeafU
54 // equivalent to BranchU.
55 //
56 // - "Popu" is short for "Population".
57 // - "Pop1" refers to actual population (base 1).
58 // - "Pop0" refers to Pop1 - 1 (base 0), the way populations are stored in data
59 // structures.
60 //
61 // - Branches and Leaves are both named by the number of bytes in their Pop0
62 // field. In the case of Leaves, the same number applies to the Index sizes.
63 //
64 // - The representation of many numbers as hex is a relatively safe and
65 // portable way to get desired bitpatterns as unsigned longs.
66 //
67 // - Some preprocessors cant handle single apostrophe characters within
68 // #ifndef code, so here, use delete all instead.
69
70 #include "JudyPrivate.h"cxx . . $ `<file>/libs/klib/judy/JudyPrivate.h`/ // includes Judy.h in turn.
71 #include "JudyPrivateBranch.h"cxx . . $ `<file>/libs/klib/judy/JudyPrivateBranch.h`/
72
73
74 // ****************************************************************************
75 // JUDY1 ROOT POINTER (JRP) AND JUDY1 POINTER (JP) TYPE FIELDS
76 // ****************************************************************************
77 //
78 // The following enum lists all possible JP Type fields.
79
80 typedef enumcxx . . $ $anonymous_type_29f89e90273ac70c_0# // uint8_t -- but C does not support this type of enum.
81 {
82
83 // JP NULL TYPES:
84 //
85 // There is a series of cJ1_JPNULL* Types because each one pre-records a
86 // different Index Size for when the first Index is inserted in the previously
87 // null JP. They must start >= 8 (three bits).
88 //
89 // Note: These Types must be in sequential order for doing relative
90 // calculations between them.
91
92 cJ1_JPNULL1cxx . . $ cJ1_JPNULL1. = 1,
93 // Index Size 1[1] byte when 1 Index inserted.
94 cJ1_JPNULL2cxx . . $ cJ1_JPNULL2., // Index Size 2[2] bytes when 1 Index inserted.
95 cJ1_JPNULL3cxx . . $ cJ1_JPNULL3., // Index Size 3[3] bytes when 1 Index inserted.
96
97 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
98 #define cJ1_JPNULLMAX cJ1_JPNULL3
99 #else
100 cJ1_JPNULL4cxx . . $ cJ1_JPNULL4., // Index Size 4[4] bytes when 1 Index inserted.
101 cJ1_JPNULL5cxx . . $ cJ1_JPNULL5., // Index Size 5[5] bytes when 1 Index inserted.
102 cJ1_JPNULL6cxx . . $ cJ1_JPNULL6., // Index Size 6[6] bytes when 1 Index inserted.
103 cJ1_JPNULL7cxx . . $ cJ1_JPNULL7., // Index Size 7[7] bytes when 1 Index inserted.
104 #define cJ1_JPNULLMAXcxx . . $ `libs/klib/judy/Judy1.h:104:9`! cJ1_JPNULL7
105 #endif
106
107
108 // JP BRANCH TYPES:
109 //
110 // Note: There are no state-1 branches; only leaves reside at state 1.
111
112 // Linear branches:
113 //
114 // Note: These Types must be in sequential order for doing relative
115 // calculations between them.
116
117 cJ1_JPBRANCH_L2cxx . . $ cJ1_JPBRANCH_L2., // 2[2] bytes Pop0, 1[5] bytes Dcd.
118 cJ1_JPBRANCH_L3cxx . . $ cJ1_JPBRANCH_L3., // 3[3] bytes Pop0, 0[4] bytes Dcd.
119
120 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
121 cJ1_JPBRANCH_L4cxx . . $ cJ1_JPBRANCH_L4., // [4] bytes Pop0, [3] bytes Dcd.
122 cJ1_JPBRANCH_L5cxx . . $ cJ1_JPBRANCH_L5., // [5] bytes Pop0, [2] bytes Dcd.
123 cJ1_JPBRANCH_L6cxx . . $ cJ1_JPBRANCH_L6., // [6] bytes Pop0, [1] byte Dcd.
124 cJ1_JPBRANCH_L7cxx . . $ cJ1_JPBRANCH_L7., // [7] bytes Pop0, [0] bytes Dcd.
125 #endif
126
127 cJ1_JPBRANCH_Lcxx . . $ cJ1_JPBRANCH_L., // note: DcdPopO field not used.
128
129 // Bitmap branches:
130 //
131 // Note: These Types must be in sequential order for doing relative
132 // calculations between them.
133
134 cJ1_JPBRANCH_B2cxx . . $ cJ1_JPBRANCH_B2., // 2[2] bytes Pop0, 1[5] bytes Dcd.
135 cJ1_JPBRANCH_B3cxx . . $ cJ1_JPBRANCH_B3., // 3[3] bytes Pop0, 0[4] bytes Dcd.
136
137 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
138 cJ1_JPBRANCH_B4cxx . . $ cJ1_JPBRANCH_B4., // [4] bytes Pop0, [3] bytes Dcd.
139 cJ1_JPBRANCH_B5cxx . . $ cJ1_JPBRANCH_B5., // [5] bytes Pop0, [2] bytes Dcd.
140 cJ1_JPBRANCH_B6cxx . . $ cJ1_JPBRANCH_B6., // [6] bytes Pop0, [1] byte Dcd.
141 cJ1_JPBRANCH_B7cxx . . $ cJ1_JPBRANCH_B7., // [7] bytes Pop0, [0] bytes Dcd.
142 #endif
143
144 cJ1_JPBRANCH_Bcxx . . $ cJ1_JPBRANCH_B., // note: DcdPopO field not used.
145
146 // Uncompressed branches:
147 //
148 // Note: These Types must be in sequential order for doing relative
149 // calculations between them.
150
151 cJ1_JPBRANCH_U2cxx . . $ cJ1_JPBRANCH_U2., // 2[2] bytes Pop0, 1[5] bytes Dcd.
152 cJ1_JPBRANCH_U3cxx . . $ cJ1_JPBRANCH_U3., // 3[3] bytes Pop0, 0[4] bytes Dcd.
153
154 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
155 cJ1_JPBRANCH_U4cxx . . $ cJ1_JPBRANCH_U4., // [4] bytes Pop0, [3] bytes Dcd.
156 cJ1_JPBRANCH_U5cxx . . $ cJ1_JPBRANCH_U5., // [5] bytes Pop0, [2] bytes Dcd.
157 cJ1_JPBRANCH_U6cxx . . $ cJ1_JPBRANCH_U6., // [6] bytes Pop0, [1] byte Dcd.
158 cJ1_JPBRANCH_U7cxx . . $ cJ1_JPBRANCH_U7., // [7] bytes Pop0, [0] bytes Dcd.
159 #endif
160
161 cJ1_JPBRANCH_Ucxx . . $ cJ1_JPBRANCH_U., // note: DcdPopO field not used.
162
163
164 // JP LEAF TYPES:
165
166 // Linear leaves:
167 //
168 // Note: These Types must be in sequential order for doing relative
169 // calculations between them.
170 //
171 // Note: There is no cJ1_JPLEAF1 for 64-bit for a subtle reason. An immediate
172 // JP can hold 15 1-byte Indexes, and a bitmap leaf would be used for 17
173 // Indexes, so rather than support a linear leaf for only the case of exactly
174 // 16 Indexes, a bitmap leaf is used in that case. See also below regarding
175 // cJ1_LEAF1_MAXPOP1 on 64-bit systems.
176 //
177 // Note: There is no full-word (4-byte [8-byte]) Index leaf under a JP because
178 // non-root-state leaves only occur under branches that decode at least one
179 // byte. Full-word, root-state leaves are under a JRP, not a JP. However, in
180 // the code a "fake" JP can be created temporarily above a root-state leaf.
181
182 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`! // 32-bit only; see above.
183 cJ1_JPLEAF1, // 1 byte Pop0, 2 bytes Dcd.
184 #endif
185
186 cJ1_JPLEAF2cxx . . $ cJ1_JPLEAF2., // 2[2] bytes Pop0, 1[5] bytes Dcd.
187 cJ1_JPLEAF3cxx . . $ cJ1_JPLEAF3., // 3[3] bytes Pop0, 0[4] bytes Dcd.
188
189 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
190 cJ1_JPLEAF4cxx . . $ cJ1_JPLEAF4., // [4] bytes Pop0, [3] bytes Dcd.
191 cJ1_JPLEAF5cxx . . $ cJ1_JPLEAF5., // [5] bytes Pop0, [2] bytes Dcd.
192 cJ1_JPLEAF6cxx . . $ cJ1_JPLEAF6., // [6] bytes Pop0, [1] byte Dcd.
193 cJ1_JPLEAF7cxx . . $ cJ1_JPLEAF7., // [7] bytes Pop0, [0] bytes Dcd.
194 #endif
195
196 // Bitmap leaf; Index Size == 1:
197 //
198 // Note: These are currently only supported at state 1. At other states the
199 // bitmap would grow from 256 to 256^2, 256^3, ... bits, which would not be
200 // efficient..
201
202 cJ1_JPLEAF_B1cxx . . $ cJ1_JPLEAF_B1., // 1[1] byte Pop0, 2[6] bytes Dcd.
203
204
205 // Full population; Index Size == 1 virtual leaf:
206 //
207 // Note: These are currently only supported at state 1. At other states they
208 // could be used, but they would be rare and the savings are dubious.
209
210 cJ1_JPFULLPOPU1cxx . . $ cJ1_JPFULLPOPU1., // 1[1] byte Pop0, 2[6] bytes Dcd.
211
212 #ifdef notdef // for future enhancements
213 cJ1_JPFULLPOPU1m1, // Full Population - 1
214 cJ1_JPFULLPOPU1m2, // Full Population - 2
215 cJ1_JPFULLPOPU1m3, // Full Population - 3
216 cJ1_JPFULLPOPU1m4, // Full Population - 4
217 cJ1_JPFULLPOPU1m5, // Full Population - 5
218 cJ1_JPFULLPOPU1m6, // Full Population - 6
219 cJ1_JPFULLPOPU1m7, // Full Population - 7
220
221 #ifdef JU_64BIT
222 cJ1_JPFULLPOPU1m8, // Full Population - 8
223 cJ1_JPFULLPOPU1m9, // Full Population - 9
224 cJ1_JPFULLPOPU1m10, // Full Population - 10
225 cJ1_JPFULLPOPU1m11, // Full Population - 11
226 cJ1_JPFULLPOPU1m12, // Full Population - 12
227 cJ1_JPFULLPOPU1m13, // Full Population - 13
228 cJ1_JPFULLPOPU1m14, // Full Population - 14
229 cJ1_JPFULLPOPU1m15, // Full Population - 15
230 #endif
231 #endif // notdef -- for future enhancements
232
233
234 // JP IMMEDIATES; leaves (Indexes) stored inside a JP:
235 //
236 // The second numeric suffix is the Pop1 for each type. As the Index Size
237 // increases, the maximum possible population decreases.
238 //
239 // Note: These Types must be in sequential order in each group (Index Size),
240 // and the groups in correct order too, for doing relative calculations between
241 // them. For example, since these Types enumerate the Pop1 values (unlike
242 // other JP Types where there is a Pop0 value in the JP), the maximum Pop1 for
243 // each Index Size is computable.
244
245 cJ1_JPIMMED_1_01cxx . . $ cJ1_JPIMMED_1_01., // Index Size = 1, Pop1 = 1.
246 cJ1_JPIMMED_2_01cxx . . $ cJ1_JPIMMED_2_01., // Index Size = 2, Pop1 = 1.
247 cJ1_JPIMMED_3_01cxx . . $ cJ1_JPIMMED_3_01., // Index Size = 3, Pop1 = 1.
248 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
249 cJ1_JPIMMED_4_01cxx . . $ cJ1_JPIMMED_4_01., // Index Size = 4, Pop1 = 1.
250 cJ1_JPIMMED_5_01cxx . . $ cJ1_JPIMMED_5_01., // Index Size = 5, Pop1 = 1.
251 cJ1_JPIMMED_6_01cxx . . $ cJ1_JPIMMED_6_01., // Index Size = 6, Pop1 = 1.
252 cJ1_JPIMMED_7_01cxx . . $ cJ1_JPIMMED_7_01., // Index Size = 7, Pop1 = 1.
253 #endif
254
255 cJ1_JPIMMED_1_02cxx . . $ cJ1_JPIMMED_1_02., // Index Size = 1, Pop1 = 2.
256 cJ1_JPIMMED_1_03cxx . . $ cJ1_JPIMMED_1_03., // Index Size = 1, Pop1 = 3.
257 cJ1_JPIMMED_1_04cxx . . $ cJ1_JPIMMED_1_04., // Index Size = 1, Pop1 = 4.
258 cJ1_JPIMMED_1_05cxx . . $ cJ1_JPIMMED_1_05., // Index Size = 1, Pop1 = 5.
259 cJ1_JPIMMED_1_06cxx . . $ cJ1_JPIMMED_1_06., // Index Size = 1, Pop1 = 6.
260 cJ1_JPIMMED_1_07cxx . . $ cJ1_JPIMMED_1_07., // Index Size = 1, Pop1 = 7.
261
262 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
263 cJ1_JPIMMED_1_08cxx . . $ cJ1_JPIMMED_1_08., // Index Size = 1, Pop1 = 8.
264 cJ1_JPIMMED_1_09cxx . . $ cJ1_JPIMMED_1_09., // Index Size = 1, Pop1 = 9.
265 cJ1_JPIMMED_1_10cxx . . $ cJ1_JPIMMED_1_10., // Index Size = 1, Pop1 = 10.
266 cJ1_JPIMMED_1_11cxx . . $ cJ1_JPIMMED_1_11., // Index Size = 1, Pop1 = 11.
267 cJ1_JPIMMED_1_12cxx . . $ cJ1_JPIMMED_1_12., // Index Size = 1, Pop1 = 12.
268 cJ1_JPIMMED_1_13cxx . . $ cJ1_JPIMMED_1_13., // Index Size = 1, Pop1 = 13.
269 cJ1_JPIMMED_1_14cxx . . $ cJ1_JPIMMED_1_14., // Index Size = 1, Pop1 = 14.
270 cJ1_JPIMMED_1_15cxx . . $ cJ1_JPIMMED_1_15., // Index Size = 1, Pop1 = 15.
271 #endif
272
273 cJ1_JPIMMED_2_02cxx . . $ cJ1_JPIMMED_2_02., // Index Size = 2, Pop1 = 2.
274 cJ1_JPIMMED_2_03cxx . . $ cJ1_JPIMMED_2_03., // Index Size = 2, Pop1 = 3.
275
276 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
277 cJ1_JPIMMED_2_04cxx . . $ cJ1_JPIMMED_2_04., // Index Size = 2, Pop1 = 4.
278 cJ1_JPIMMED_2_05cxx . . $ cJ1_JPIMMED_2_05., // Index Size = 2, Pop1 = 5.
279 cJ1_JPIMMED_2_06cxx . . $ cJ1_JPIMMED_2_06., // Index Size = 2, Pop1 = 6.
280 cJ1_JPIMMED_2_07cxx . . $ cJ1_JPIMMED_2_07., // Index Size = 2, Pop1 = 7.
281 #endif
282
283 cJ1_JPIMMED_3_02cxx . . $ cJ1_JPIMMED_3_02., // Index Size = 3, Pop1 = 2.
284
285 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
286 cJ1_JPIMMED_3_03cxx . . $ cJ1_JPIMMED_3_03., // Index Size = 3, Pop1 = 3.
287 cJ1_JPIMMED_3_04cxx . . $ cJ1_JPIMMED_3_04., // Index Size = 3, Pop1 = 4.
288 cJ1_JPIMMED_3_05cxx . . $ cJ1_JPIMMED_3_05., // Index Size = 3, Pop1 = 5.
289
290 cJ1_JPIMMED_4_02cxx . . $ cJ1_JPIMMED_4_02., // Index Size = 4, Pop1 = 2.
291 cJ1_JPIMMED_4_03cxx . . $ cJ1_JPIMMED_4_03., // Index Size = 4, Pop1 = 3.
292
293 cJ1_JPIMMED_5_02cxx . . $ cJ1_JPIMMED_5_02., // Index Size = 5, Pop1 = 2.
294 cJ1_JPIMMED_5_03cxx . . $ cJ1_JPIMMED_5_03., // Index Size = 3, Pop1 = 3.
295
296 cJ1_JPIMMED_6_02cxx . . $ cJ1_JPIMMED_6_02., // Index Size = 6, Pop1 = 2.
297
298 cJ1_JPIMMED_7_02cxx . . $ cJ1_JPIMMED_7_02., // Index Size = 7, Pop1 = 2.
299 #endif
300
301 // This special Type is merely a sentinel for doing relative calculations.
302 // This value should not be used in switch statements (to avoid allocating code
303 // for it), which is also why it appears at the end of the enum list.
304
305 cJ1_JPIMMED_CAPcxx . . $ cJ1_JPIMMED_CAP.
306
307 } jp1_Type_tcxx . . $ jp1_Type_t#;
308
309
310 // RELATED VALUES:
311 //
312 // Index Size (state) for leaf JP, and JP type based on Index Size (state):
313
314 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`! // 32-bit
315 #define J1_LEAFINDEXSIZE(jpType) ((jpType) - cJ1_JPLEAF1 + 1)
316 #define J1_LEAFTYPE(IndexSize) ((IndexSize) + cJ1_JPLEAF1 - 1)
317 #else
318 #define J1_LEAFINDEXSIZEcxx . . $ `libs/klib/judy/Judy1.h:318:9`!(jpType) ((jpType) - cJ1_JPLEAF2 + 2)
319 #define J1_LEAFTYPEcxx . . $ `libs/klib/judy/Judy1.h:319:9`!(IndexSize) ((IndexSize) + cJ1_JPLEAF2 - 2)
320 #endif
321
322
323 // ****************************************************************************
324 // JUDY1 POINTER (JP) -- RELATED MACROS AND CONSTANTS
325 // ****************************************************************************
326
327 // MAXIMUM POPULATIONS OF LINEAR LEAVES:
328 //
329 // Allow up to 2 cache lines per leaf, with N bytes per index.
330 //
331 // J_1_MAXB is the maximum number of bytes (sort of) to allocate per leaf.
332 // ALLOCSIZES is defined here, not there, for single-point control of these key
333 // definitions. See JudyTables.c for "TERMINATOR".
334
335 #define J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! (sizeof(Word_t) * 32)
336 #define ALLOCSIZEScxx . . $ `libs/klib/judy/Judy1.h:336:9`! { 3, 5, 7, 11, 15, 23, 32, 47, 64, TERMINATOR } // in words.
337 #define cJ1_LEAF1_MAXWORDScxx . . $ `libs/klib/judy/Judy1.h:337:9`! 5 // Leaf1 max alloc size in words.
338
339 // Under JRP (root-state leaves):
340 //
341 // Includes a count (Population) word.
342 //
343 // Under JP (non-root-state leaves), which have no count (Population) words:
344 //
345 // When a 1-byte index leaf grows above cJ1_LEAF1_MAXPOP1 Indexes (bytes),
346 // the memory chunk required grows to a size where a bitmap is just as
347 // efficient, so use a bitmap instead for all greater Populations, on both
348 // 32-bit and 64-bit systems. However, on a 32-bit system this occurs upon
349 // going from 6 to 8 words (24 to 32 bytes) in the memory chunk, but on a
350 // 64-bit system this occurs upon going from 2 to 4 words (16 to 32 bytes). It
351 // would be silly to go from a 15-Index Immediate JP to a 16-Index linear leaf
352 // to a 17-Index bitmap leaf, so just use a bitmap leaf for 16+ Indexes, which
353 // means set cJ1_LEAF1_MAXPOP1 to cJ1_IMMED1_MAXPOP1 (15) to cause the
354 // transition at that point.
355 //
356 // Note: cJ1_LEAF1_MAXPOP1 is not used on 64-bit systems.
357
358 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`! // 32-bit
359
360 #define cJ1_LEAF1_MAXPOP1 (cJ1_LEAF1_MAXWORDS * cJU_BYTESPERWORD)
361 #define cJ1_LEAF2_MAXPOP1 (J_1_MAXB / 2)
362 #define cJ1_LEAF3_MAXPOP1 (J_1_MAXB / 3)
363 #define cJ1_LEAFW_MAXPOP1 ((J_1_MAXB - cJU_BYTESPERWORD) / cJU_BYTESPERWORD)
364
365 #else // 64-bit
366
367 // #define cJ1_LEAF1_MAXPOP1 // no LEAF1 in 64-bit.
368 #define cJ1_LEAF2_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:368:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 2)
369 #define cJ1_LEAF3_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:369:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 3)
370 #define cJ1_LEAF4_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:370:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 4)
371 #define cJ1_LEAF5_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:371:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 5)
372 #define cJ1_LEAF6_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:372:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 6)
373 #define cJ1_LEAF7_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:373:9`! (J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! / 7)
374 #define cJ1_LEAFW_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:374:9`! ((J_1_MAXBcxx . . $ `libs/klib/judy/Judy1.h:335:9`! - cJU_BYTESPERWORDcxx . . $ `libs/klib/judy/JudyPrivate.h:299:9`!) / cJU_BYTESPERWORDcxx . . $ `libs/klib/judy/JudyPrivate.h:299:9`!)
375
376 #endif
377
378
379 // MAXIMUM POPULATIONS OF IMMEDIATE JPs:
380 //
381 // These specify the maximum Population of immediate JPs with various Index
382 // Sizes (== sizes of remaining undecoded Index bits).
383
384 #define cJ1_IMMED1_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:384:9`! ((sizeof(jp_t) - 1) / 1) // 7 [15].
385 #define cJ1_IMMED2_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:385:9`! ((sizeof(jp_t) - 1) / 2) // 3 [7].
386 #define cJ1_IMMED3_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:386:9`! ((sizeof(jp_t) - 1) / 3) // 2 [5].
387
388 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
389 #define cJ1_IMMED4_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:389:9`! ((sizeof(jp_t) - 1) / 4) // [3].
390 #define cJ1_IMMED5_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:390:9`! ((sizeof(jp_t) - 1) / 5) // [3].
391 #define cJ1_IMMED6_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:391:9`! ((sizeof(jp_t) - 1) / 6) // [2].
392 #define cJ1_IMMED7_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:392:9`! ((sizeof(jp_t) - 1) / 7) // [2].
393 #endif
394
395
396 // ****************************************************************************
397 // JUDY1 BITMAP LEAF (J1LB) SUPPORT
398 // ****************************************************************************
399
400 #define J1_JLB_BITMAPcxx . . $ `libs/klib/judy/Judy1.h:400:9`!(Pjlb,Subexp) ((Pjlb)->j1lb_Bitmap[Subexp])
401
402 typedef struct J__UDY1_BITMAP_LEAFcxx . . $ J__UDY1_BITMAP_LEAF#
403 {
404 BITMAPL_tcxx . . $ `libs/klib/judy/JudyPrivate.h:476:9`! j1lb_Bitmapcxx . . $ J__UDY1_BITMAP_LEAF#j1lb_Bitmap.[cJU_NUMSUBEXPLcxx . . $ `libs/klib/judy/JudyPrivate.h:788:9`!];
405
406 } j1lb_tcxx . . $ j1lb_t#, * Pj1lb_tcxx . . $ Pj1lb_t#;
407
408
409 // ****************************************************************************
410 // MEMORY ALLOCATION SUPPORT
411 // ****************************************************************************
412
413 // ARRAY-GLOBAL INFORMATION:
414 //
415 // At the cost of an occasional additional cache fill, this object, which is
416 // pointed at by a JRP and in turn points to a JP_BRANCH*, carries array-global
417 // information about a Judy1 array that has sufficient population to amortize
418 // the cost. The jpm_Pop0 field prevents having to add up the total population
419 // for the array in insert, delete, and count code. The jpm_JP field prevents
420 // having to build a fake JP for entry to a state machine; however, the
421 // jp_DcdPopO field in jpm_JP, being one byte too small, is not used.
422 //
423 // Note: Struct fields are ordered to keep "hot" data in the first 8 words
424 // (see left-margin comments) for machines with 8-word cache lines, and to keep
425 // sub-word fields together for efficient packing.
426
427 typedef struct J_UDY1_POPULATION_AND_MEMORYcxx . . $ J_UDY1_POPULATION_AND_MEMORY#
428 {
429 /* 1 */ Word_tcxx . . $ Word_t# jpm_Pop0cxx . . $ J_UDY1_POPULATION_AND_MEMORY#jpm_Pop0.; // total population-1 in array.
430 /* 2 */ jp_tcxx . . $ jp_t# jpm_JPcxx . . $ J_UDY1_POPULATION_AND_MEMORY#jpm_JP.; // JP to first branch; see above.
431 /* 4 */ Word_tcxx . . $ Word_t# jpm_LastUPop0cxx . . $ J_UDY1_POPULATION_AND_MEMORY#jpm_LastUPop0.; // last jpm_Pop0 when convert to BranchU
432 // Note: Field names match PJError_t for convenience in macros:
433 /* 7 */ char je_Errnocxx . . $ J_UDY1_POPULATION_AND_MEMORY#je_Errno.; // one of the enums in Judy.h.
434 /* 7/8 */ int je_ErrIDcxx . . $ J_UDY1_POPULATION_AND_MEMORY#je_ErrID.; // often an internal source line number.
435 /* 8/9 */ Word_tcxx . . $ Word_t# jpm_TotalMemWordscxx . . $ J_UDY1_POPULATION_AND_MEMORY#jpm_TotalMemWords.; // words allocated in array.
436 } j1pm_tcxx . . $ j1pm_t#, *Pj1pm_tcxx . . $ Pj1pm_t#;
437
438
439 // TABLES FOR DETERMINING IF LEAVES HAVE ROOM TO GROW:
440 //
441 // These tables indicate if a given memory chunk can support growth of a given
442 // object into wasted (rounded-up) memory in the chunk. This violates the
443 // hiddenness of the JudyMalloc code.
444 //
445 // Also define macros to hide the details in the code using these tables.
446
447 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
448 extern const uint8_t j__1_Leaf1PopToWords[cJ1_LEAF1_MAXPOP1 + 1];
449 #endif
450 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf2PopToWordscxx . . $ j__1_Leaf2PopToWords.[cJ1_LEAF2_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:368:9`! + 1];
451 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf3PopToWordscxx . . $ j__1_Leaf3PopToWords.[cJ1_LEAF3_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:369:9`! + 1];
452 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
453 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf4PopToWordscxx . . $ j__1_Leaf4PopToWords.[cJ1_LEAF4_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:370:9`! + 1];
454 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf5PopToWordscxx . . $ j__1_Leaf5PopToWords.[cJ1_LEAF5_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:371:9`! + 1];
455 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf6PopToWordscxx . . $ j__1_Leaf6PopToWords.[cJ1_LEAF6_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:372:9`! + 1];
456 extern const uint8_tcxx . . $ uint8_t# j__1_Leaf7PopToWordscxx . . $ j__1_Leaf7PopToWords.[cJ1_LEAF7_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:373:9`! + 1];
457 #endif
458 extern const uint8_tcxx . . $ uint8_t# j__1_LeafWPopToWordscxx . . $ j__1_LeafWPopToWords.[cJ1_LEAFW_MAXPOP1cxx . . $ `libs/klib/judy/Judy1.h:374:9`! + 1];
459
460 // Check if increase of population will fit in same leaf:
461
462 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
463 #define J1_LEAF1GROWINPLACE(Pop1) \
464 J__U_GROWCK(Pop1, cJ1_LEAF1_MAXPOP1, j__1_Leaf1PopToWords)
465 #endif
466 #define J1_LEAF2GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:466:9`!(Pop1) \
467 J__U_GROWCK(Pop1, cJ1_LEAF2_MAXPOP1, j__1_Leaf2PopToWords)
468 #define J1_LEAF3GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:468:9`!(Pop1) \
469 J__U_GROWCK(Pop1, cJ1_LEAF3_MAXPOP1, j__1_Leaf3PopToWords)
470 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
471 #define J1_LEAF4GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:471:9`!(Pop1) \
472 J__U_GROWCK(Pop1, cJ1_LEAF4_MAXPOP1, j__1_Leaf4PopToWords)
473 #define J1_LEAF5GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:473:9`!(Pop1) \
474 J__U_GROWCK(Pop1, cJ1_LEAF5_MAXPOP1, j__1_Leaf5PopToWords)
475 #define J1_LEAF6GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:475:9`!(Pop1) \
476 J__U_GROWCK(Pop1, cJ1_LEAF6_MAXPOP1, j__1_Leaf6PopToWords)
477 #define J1_LEAF7GROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:477:9`!(Pop1) \
478 J__U_GROWCK(Pop1, cJ1_LEAF7_MAXPOP1, j__1_Leaf7PopToWords)
479 #endif
480 #define J1_LEAFWGROWINPLACEcxx . . $ `libs/klib/judy/Judy1.h:480:9`!(Pop1) \
481 J__U_GROWCK(Pop1, cJ1_LEAFW_MAXPOP1, j__1_LeafWPopToWords)
482
483 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
484 #define J1_LEAF1POPTOWORDS(Pop1) (j__1_Leaf1PopToWords[Pop1])
485 #endif
486 #define J1_LEAF2POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:486:9`!(Pop1) (j__1_Leaf2PopToWords[Pop1])
487 #define J1_LEAF3POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:487:9`!(Pop1) (j__1_Leaf3PopToWords[Pop1])
488 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
489 #define J1_LEAF4POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:489:9`!(Pop1) (j__1_Leaf4PopToWords[Pop1])
490 #define J1_LEAF5POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:490:9`!(Pop1) (j__1_Leaf5PopToWords[Pop1])
491 #define J1_LEAF6POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:491:9`!(Pop1) (j__1_Leaf6PopToWords[Pop1])
492 #define J1_LEAF7POPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:492:9`!(Pop1) (j__1_Leaf7PopToWords[Pop1])
493 #endif
494 #define J1_LEAFWPOPTOWORDScxx . . $ `libs/klib/judy/Judy1.h:494:9`!(Pop1) (j__1_LeafWPopToWords[Pop1])
495
496
497 // FUNCTIONS TO ALLOCATE OBJECTS:
498
499 Pj1pm_tcxx . . $ Pj1pm_t# j__udy1AllocJ1PMcxx . . $ j__udy1AllocJ1PM(94f6c467a5317aa1).(void); // constant size.
500
501 Pjbl_tcxx . . $ Pjbl_t# j__udy1AllocJBLcxx . . $ j__udy1AllocJBL(452cd6e59aee2f24).( Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
502 Pjbb_tcxx . . $ Pjbb_t# j__udy1AllocJBBcxx . . $ j__udy1AllocJBB(8e1e84e3e7e3fe25).( Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
503 Pjp_tcxx . . $ Pjp_t# j__udy1AllocJBBJPcxx . . $ j__udy1AllocJBBJP(e67455abe17b86a0).(Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
504 Pjbu_tcxx . . $ Pjbu_t# j__udy1AllocJBUcxx . . $ j__udy1AllocJBU(34d8230b283667e8).( Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
505
506 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
507 Pjll_t j__udy1AllocJLL1( Word_t, Pj1pm_t);
508 #endif
509 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL2cxx . . $ j__udy1AllocJLL2(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
510 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL3cxx . . $ j__udy1AllocJLL3(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
511
512 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
513 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL4cxx . . $ j__udy1AllocJLL4(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
514 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL5cxx . . $ j__udy1AllocJLL5(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
515 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL6cxx . . $ j__udy1AllocJLL6(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
516 Pjll_tcxx . . $ Pjll_t# j__udy1AllocJLL7cxx . . $ j__udy1AllocJLL7(172d18164f30d505).( Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
517 #endif
518
519 Pjlw_tcxx . . $ Pjlw_t# j__udy1AllocJLWcxx . . $ j__udy1AllocJLW(9087c41a63d875fd).( Word_tcxx . . $ Word_t# ); // no Pj1pm needed.
520 Pj1lb_tcxx . . $ Pj1lb_t# j__udy1AllocJLB1cxx . . $ j__udy1AllocJLB1(7260e33939bb8aa0).( Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
521
522
523 // FUNCTIONS TO FREE OBJECTS:
524
525 void j__udy1FreeJ1PMcxx . . $ j__udy1FreeJ1PM(891c2c3d73926d67).( Pj1pm_tcxx . . $ Pj1pm_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
526
527 void j__udy1FreeJBLcxx . . $ j__udy1FreeJBL(ecbfe484fbab6832).( Pjbl_tcxx . . $ Pjbl_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
528 void j__udy1FreeJBBcxx . . $ j__udy1FreeJBB(7353fb06efaae904).( Pjbb_tcxx . . $ Pjbb_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
529 void j__udy1FreeJBBJPcxx . . $ j__udy1FreeJBBJP(c5c8a48387e2fbbf).(Pjp_tcxx . . $ Pjp_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
530 void j__udy1FreeJBUcxx . . $ j__udy1FreeJBU(b41577349332e61a).( Pjbu_tcxx . . $ Pjbu_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
531
532 #ifndef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
533 void j__udy1FreeJLL1( Pjll_t, Word_t, Pj1pm_t);
534 #endif
535 void j__udy1FreeJLL2cxx . . $ j__udy1FreeJLL2(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
536 void j__udy1FreeJLL3cxx . . $ j__udy1FreeJLL3(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
537
538 #ifdef JU_64BITcxx . . $ `libs/klib/Judy.h:36:9`!
539 void j__udy1FreeJLL4cxx . . $ j__udy1FreeJLL4(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
540 void j__udy1FreeJLL5cxx . . $ j__udy1FreeJLL5(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
541 void j__udy1FreeJLL6cxx . . $ j__udy1FreeJLL6(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
542 void j__udy1FreeJLL7cxx . . $ j__udy1FreeJLL7(423bd6fc3ef5bb59).( Pjll_tcxx . . $ Pjll_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
543 #endif
544
545 void j__udy1FreeJLWcxx . . $ j__udy1FreeJLW(835291b0080c4f98).( Pjlw_tcxx . . $ Pjlw_t#, Word_tcxx . . $ Word_t#, Pj1pm_tcxx . . $ Pj1pm_t#);
546 void j__udy1FreeJLB1cxx . . $ j__udy1FreeJLB1(af69d14c1b24f9ba).( Pj1lb_tcxx . . $ Pj1lb_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // constant size.
547 void j__udy1FreeSMcxx . . $ j__udy1FreeSM(f7eaecffa3d139c0).( Pjp_tcxx . . $ Pjp_t#, Pj1pm_tcxx . . $ Pj1pm_t#); // everything below Pjp.
548
549 #endif // ! _JUDY1_INCLUDED