master
h 788 lines 27.5 KB
Raw
1 #ifndef _JUDY_PRIVATE_BRANCH_INCLUDED
2 #define _JUDY_PRIVATE_BRANCH_INCLUDED
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 // @(#) $Revision: 1.2 $ $Source: /home/doug/judy-1.0.5_min/test/../src/JudyCommon/RCS/JudyPrivateBranch.h,v $
23 //
24 // Header file for all Judy sources, for global but private (non-exported)
25 // declarations specific to branch support.
26 //
27 // See also the "Judy Shop Manual" (try judy/doc/int/JudyShopManual.*).
28
29
30 // ****************************************************************************
31 // JUDY POINTER (JP) SUPPORT
32 // ****************************************************************************
33 //
34 // This "rich pointer" object is pivotal to Judy execution.
35 //
36 // JP CONTAINING OTHER THAN IMMEDIATE INDEXES:
37 //
38 // If the JP points to a linear or bitmap leaf, jp_DcdPopO contains the
39 // Population-1 in LSbs and Decode (Dcd) bytes in the MSBs. (In practice the
40 // Decode bits are masked off while accessing the Pop0 bits.)
41 //
42 // The Decode Size, the number of Dcd bytes available, is encoded in jpo_Type.
43 // It can also be thought of as the number of states "skipped" in the SM, where
44 // each state decodes 8 bits = 1 byte.
45 //
46 // TBD: Dont need two structures, except possibly to force jp_Type to highest
47 // address!
48 //
49 // Note: The jpo_u union is not required by HP-UX or Linux but Win32 because
50 // the cl.exe compiler otherwise refuses to pack a bitfield (DcdPopO) with
51 // anything else, even with the -Zp option. This is pretty ugly, but
52 // fortunately portable, and its all hide-able by macros (see below).
53
54 typedef struct J_UDY_POINTER_OTHERS // JPO.
55 {
56 Word_t j_po_Addr; // first word: Pjp_t, Word_t, etc.
57 union {
58 Word_t j_po_Addr1;
59 uint8_t j_po_DcdP0[sizeof(Word_t) - 1];
60 uint8_t j_po_Bytes[sizeof(Word_t)]; // last byte = jp_Type.
61 } jpo_u;
62 } jpo_t;
63
64
65 // JP CONTAINING IMMEDIATE INDEXES:
66 //
67 // j_pi_1Index[] plus j_pi_LIndex[] together hold as many N-byte (1..3-byte
68 // [1..7-byte]) Indexes as will fit in sizeof(jpi_t) less 1 byte for j_pi_Type
69 // (that is, 7..1 [15..1] Indexes).
70 //
71 // For Judy1, j_pi_1Index[] is used and j_pi_LIndex[] is not used.
72 // For JudyL, j_pi_LIndex[] is used and j_pi_1Index[] is not used.
73 //
74 // Note: Actually when Pop1 = 1, jpi_t is not used, and the least bytes of the
75 // single Index are stored in j_po_DcdPopO, for both Judy1 and JudyL, so for
76 // JudyL the j_po_Addr field can hold the target value.
77 //
78 // TBD: Revise this structure to not overload j_po_DcdPopO this way? The
79 // current arrangement works, its just confusing.
80
81 typedef struct _JUDY_POINTER_IMMEDL
82 {
83 Word_t j_pL_Addr;
84 uint8_t j_pL_LIndex[sizeof(Word_t) - 1]; // see above.
85 uint8_t j_pL_Type;
86 } jpL_t;
87
88 typedef struct _JUDY_POINTER_IMMED1
89 {
90 uint8_t j_p1_1Index[(2 * sizeof(Word_t)) - 1];
91 uint8_t j_p1_Type;
92 } jp1_t;
93
94 // UNION OF JP TYPES:
95 //
96 // A branch is an array of cJU_BRANCHUNUMJPS (256) of this object, or an
97 // alternate data type such as: A linear branch which is a list of 2..7 JPs,
98 // or a bitmap branch which contains 8 lists of 0..32 JPs. JPs reside only in
99 // branches of a Judy SM.
100
101 typedef union J_UDY_POINTER // JP.
102 {
103 jpo_t j_po; // other than immediate indexes.
104 jpL_t j_pL; // immediate indexes.
105 jp1_t j_p1; // immediate indexes.
106 } jp_t, *Pjp_t;
107
108 // For coding convenience:
109 //
110 // Note, jp_Type has the same bits in jpo_t jpL_t and jp1_t.
111
112 #define jp_1Index j_p1.j_p1_1Index // for storing Indexes in first word.
113 #define jp_LIndex j_pL.j_pL_LIndex // for storing Indexes in second word.
114 #define jp_Addr j_po.j_po_Addr
115 #define jp_Addr1 j_po.jpo_u.j_po_Addr1
116 //#define jp_DcdPop0 j_po.jpo_u.j_po_DcdPop0
117 #define jp_Addr1 j_po.jpo_u.j_po_Addr1
118 //#define jp_Type j_po.jpo_u.j_po_Bytes[sizeof(Word_t) - 1]
119 #define jp_Type j_p1.j_p1_Type
120 #define jp_DcdP0 j_po.jpo_u.j_po_DcdP0
121
122
123 // ****************************************************************************
124 // JUDY POINTER (JP) -- RELATED MACROS AND CONSTANTS
125 // ****************************************************************************
126
127 // EXTRACT VALUES FROM JP:
128 //
129 // Masks for the bytes in the Dcd and Pop0 parts of jp_DcdPopO:
130 //
131 // cJU_DCDMASK() consists of a mask that excludes the (LSb) Pop0 bytes and
132 // also, just to be safe, the top byte of the word, since jp_DcdPopO is 1 byte
133 // less than a full word.
134 //
135 // Note: These are constant macros (cJU) because cPopBytes should be a
136 // constant. Also note cPopBytes == state in the SM.
137
138 #define cJU_POP0MASK(cPopBytes) JU_LEASTBYTESMASK(cPopBytes)
139
140 #define cJU_DCDMASK(cPopBytes) \
141 ((cJU_ALLONES >> cJU_BITSPERBYTE) & (~cJU_POP0MASK(cPopBytes)))
142
143 // Mask off the high byte from INDEX to it can be compared to DcdPopO:
144
145 #define JU_TRIMTODCDSIZE(INDEX) ((cJU_ALLONES >> cJU_BITSPERBYTE) & (INDEX))
146
147 // Get from jp_DcdPopO the Pop0 for various branch JP Types:
148 //
149 // Note: There are no simple macros for cJU_BRANCH* Types because their
150 // populations must be added up and dont reside in an already-calculated
151 // place.
152
153 #define JU_JPBRANCH_POP0(PJP,cPopBytes) \
154 (JU_JPDCDPOP0(PJP) & cJU_POP0MASK(cPopBytes))
155
156 // METHOD FOR DETERMINING IF OBJECTS HAVE ROOM TO GROW:
157 //
158 // J__U_GROWCK() is a generic method to determine if an object can grow in
159 // place, based on whether the next population size (one more) would use the
160 // same space.
161
162 #define J__U_GROWCK(POP1,MAXPOP1,POPTOWORDS) \
163 (((POP1) != (MAXPOP1)) && (POPTOWORDS[POP1] == POPTOWORDS[(POP1) + 1]))
164
165 #define JU_BRANCHBJPGROWINPLACE(NumJPs) \
166 J__U_GROWCK(NumJPs, cJU_BITSPERSUBEXPB, j__U_BranchBJPPopToWords)
167
168
169 // DETERMINE IF AN INDEX IS (NOT) IN A JPS EXPANSE:
170
171 #define JU_DCDNOTMATCHINDEX(INDEX,PJP,POP0BYTES) \
172 (((INDEX) ^ JU_JPDCDPOP0(PJP)) & cJU_DCDMASK(POP0BYTES))
173
174
175 // NUMBER OF JPs IN AN UNCOMPRESSED BRANCH:
176 //
177 // An uncompressed branch is simply an array of 256 Judy Pointers (JPs). It is
178 // a minimum cacheline fill object. Define it here before its first needed.
179
180 #define cJU_BRANCHUNUMJPS cJU_SUBEXPPERSTATE
181
182
183 // ****************************************************************************
184 // JUDY BRANCH LINEAR (JBL) SUPPORT
185 // ****************************************************************************
186 //
187 // A linear branch is a way of compressing empty expanses (null JPs) out of an
188 // uncompressed 256-way branch, when the number of populated expanses is so
189 // small that even a bitmap branch is excessive.
190 //
191 // The maximum number of JPs in a Judy linear branch:
192 //
193 // Note: This number results in a 1-cacheline sized structure. Previous
194 // versions had a larger struct so a linear branch didnt become a bitmap
195 // branch until the memory consumed was even, but for speed, its better to
196 // switch "sooner" and keep a linear branch fast.
197
198 #define cJU_BRANCHLMAXJPS 7
199
200
201 // LINEAR BRANCH STRUCT:
202 //
203 // 1-byte count, followed by array of byte-sized expanses, followed by JPs.
204
205 typedef struct J__UDY_BRANCH_LINEAR
206 {
207 uint8_t jbl_NumJPs; // num of JPs (Pjp_t), 1..N.
208 uint8_t jbl_Expanse[cJU_BRANCHLMAXJPS]; // 1..7 MSbs of pop exps.
209 jp_t jbl_jp [cJU_BRANCHLMAXJPS]; // JPs for populated exps.
210 } jbl_t, * Pjbl_t;
211
212
213 // ****************************************************************************
214 // JUDY BRANCH BITMAP (JBB) SUPPORT
215 // ****************************************************************************
216 //
217 // A bitmap branch is a way of compressing empty expanses (null JPs) out of
218 // uncompressed 256-way branch. This costs 1 additional cache line fill, but
219 // can save a lot of memory when it matters most, near the leaves, and
220 // typically there will be only one at most in the path to any Index (leaf).
221 //
222 // The bitmap indicates which of the cJU_BRANCHUNUMJPS (256) JPs in the branch
223 // are NOT null, that is, their expanses are populated. The jbb_t also
224 // contains N pointers to "mini" Judy branches ("subexpanses") of up to M JPs
225 // each (see BITMAP_BRANCHMxN, for example, BITMAP_BRANCH32x8), where M x N =
226 // cJU_BRANCHUNUMJPS. These are dynamically allocated and never contain
227 // cJ*_JPNULL* jp_Types. An empty subexpanse is represented by no bit sets in
228 // the corresponding subexpanse bitmap, in which case the corresponding
229 // jbbs_Pjp pointers value is unused.
230 //
231 // Note that the number of valid JPs in each 1-of-N subexpanses is determined
232 // by POPULATION rather than by EXPANSE -- the desired outcome to save memory
233 // when near the leaves. Note that the memory required for 185 JPs is about as
234 // much as an uncompressed 256-way branch, therefore 184 is set as the maximum.
235 // However, it is expected that a conversion to an uncompressed 256-way branch
236 // will normally take place before this limit is reached for other reasons,
237 // such as improving performance when the "wasted" memory is well amortized by
238 // the population under the branch, preserving an acceptable overall
239 // bytes/Index in the Judy array.
240 //
241 // The number of pointers to arrays of JPs in the Judy bitmap branch:
242 //
243 // Note: The numbers below are the same in both 32 and 64 bit systems.
244
245 #define cJU_BRANCHBMAXJPS 184 // maximum JPs for bitmap branches.
246
247 // Convenience wrappers for referencing BranchB bitmaps or JP subarray
248 // pointers:
249 //
250 // Note: JU_JBB_PJP produces a "raw" memory address that must pass through
251 // P_JP before use, except when freeing memory:
252
253 #define JU_JBB_BITMAP(Pjbb, SubExp) ((Pjbb)->jbb_jbbs[SubExp].jbbs_Bitmap)
254 #define JU_JBB_PJP( Pjbb, SubExp) ((Pjbb)->jbb_jbbs[SubExp].jbbs_Pjp)
255
256 #define JU_SUBEXPB(Digit) (((Digit) / cJU_BITSPERSUBEXPB) & (cJU_NUMSUBEXPB-1))
257
258 #define JU_BITMAPTESTB(Pjbb, Index) \
259 (JU_JBB_BITMAP(Pjbb, JU_SUBEXPB(Index)) & JU_BITPOSMASKB(Index))
260
261 #define JU_BITMAPSETB(Pjbb, Index) \
262 (JU_JBB_BITMAP(Pjbb, JU_SUBEXPB(Index)) |= JU_BITPOSMASKB(Index))
263
264 // Note: JU_BITMAPCLEARB is not defined because the code does it a faster way.
265
266 typedef struct J__UDY_BRANCH_BITMAP_SUBEXPANSE
267 {
268 BITMAPB_t jbbs_Bitmap;
269 Pjp_t jbbs_Pjp;
270
271 } jbbs_t;
272
273 typedef struct J__UDY_BRANCH_BITMAP
274 {
275 jbbs_t jbb_jbbs [cJU_NUMSUBEXPB];
276 #ifdef SUBEXPCOUNTS
277 Word_t jbb_subPop1[cJU_NUMSUBEXPB];
278 #endif
279 } jbb_t, * Pjbb_t;
280
281 #define JU_BRANCHJP_NUMJPSTOWORDS(NumJPs) (j__U_BranchBJPPopToWords[NumJPs])
282
283 #ifdef SUBEXPCOUNTS
284 #define cJU_NUMSUBEXPU 16 // number of subexpanse counts.
285 #endif
286
287
288 // ****************************************************************************
289 // JUDY BRANCH UNCOMPRESSED (JBU) SUPPORT
290 // ****************************************************************************
291
292 // Convenience wrapper for referencing BranchU JPs:
293 //
294 // Note: This produces a non-"raw" address already passed through P_JBU().
295
296 #define JU_JBU_PJP(Pjp,Index,Level) \
297 (&((P_JBU((Pjp)->jp_Addr))->jbu_jp[JU_DIGITATSTATE(Index, Level)]))
298 #define JU_JBU_PJP0(Pjp) \
299 (&((P_JBU((Pjp)->jp_Addr))->jbu_jp[0]))
300
301 typedef struct J__UDY_BRANCH_UNCOMPRESSED
302 {
303 jp_t jbu_jp [cJU_BRANCHUNUMJPS]; // JPs for populated exp.
304 #ifdef SUBEXPCOUNTS
305 Word_t jbu_subPop1[cJU_NUMSUBEXPU];
306 #endif
307 } jbu_t, * Pjbu_t;
308
309
310 // ****************************************************************************
311 // OTHER SUPPORT FOR JUDY STATE MACHINES (SMs)
312 // ****************************************************************************
313
314 // OBJECT SIZES IN WORDS:
315 //
316 // Word_ts per various JudyL structures that have constant sizes.
317 // cJU_WORDSPERJP should always be 2; this is fundamental to the Judy
318 // structures.
319
320 #define cJU_WORDSPERJP (sizeof(jp_t) / cJU_BYTESPERWORD)
321 #define cJU_WORDSPERCL (cJU_BYTESPERCL / cJU_BYTESPERWORD)
322
323
324 // OPPORTUNISTIC UNCOMPRESSION:
325 //
326 // Define populations at which a BranchL or BranchB must convert to BranchU.
327 // Earlier conversion is possible with good memory efficiency -- see below.
328
329 #ifndef NO_BRANCHU
330
331 // Max population below BranchL, then convert to BranchU:
332
333 #define JU_BRANCHL_MAX_POP 1000
334
335 // Minimum global population increment before next conversion of a BranchB to a
336 // BranchU:
337 //
338 // This is was done to allow malloc() to coalesce memory before the next big
339 // (~512 words) allocation.
340
341 #define JU_BTOU_POP_INCREMENT 300
342
343 // Min/max population below BranchB, then convert to BranchU:
344
345 #define JU_BRANCHB_MIN_POP 135
346 #define JU_BRANCHB_MAX_POP 750
347
348 #else // NO_BRANCHU
349
350 // These are set up to have conservative conversion schedules to BranchU:
351
352 #define JU_BRANCHL_MAX_POP (-1UL)
353 #define JU_BTOU_POP_INCREMENT 300
354 #define JU_BRANCHB_MIN_POP 1000
355 #define JU_BRANCHB_MAX_POP (-1UL)
356
357 #endif // NO_BRANCHU
358
359
360 // MISCELLANEOUS MACROS:
361
362 // Get N most significant bits from the shifted Index word:
363 //
364 // As Index words are decoded, they are shifted left so only relevant,
365 // undecoded Index bits remain.
366
367 #define JU_BITSFROMSFTIDX(SFTIDX, N) ((SFTIDX) >> (cJU_BITSPERWORD - (N)))
368
369 // TBD: I have my doubts about the necessity of these macros (dlb):
370
371 // Produce 1-digit mask at specified state:
372
373 #define cJU_MASKATSTATE(State) (0xffL << (((State) - 1) * cJU_BITSPERBYTE))
374
375 // Get byte (digit) from Index at the specified state, right justified:
376 //
377 // Note: State must be 1..cJU_ROOTSTATE, and Digits must be 1..(cJU_ROOTSTATE
378 // - 1), but theres no way to assert these within an expression.
379
380 #define JU_DIGITATSTATE(Index,cState) \
381 ((uint8_t)((Index) >> (((cState) - 1) * cJU_BITSPERBYTE)))
382
383 // Similarly, place byte (digit) at correct position for the specified state:
384 //
385 // Note: Cast digit to a Word_t first so there are no complaints or problems
386 // about shifting it more than 32 bits on a 64-bit system, say, when it is a
387 // uint8_t from jbl_Expanse[]. (Believe it or not, the C standard says to
388 // promote an unsigned char to a signed int; -Ac does not do this, but -Ae
389 // does.)
390 //
391 // Also, to make lint happy, cast the whole result again because apparently
392 // shifting a Word_t does not result in a Word_t!
393
394 #define JU_DIGITTOSTATE(Digit,cState) \
395 ((Word_t) (((Word_t) (Digit)) << (((cState) - 1) * cJU_BITSPERBYTE)))
396
397 #endif // ! _JUDY_PRIVATE_BRANCH_INCLUDED
398
399
400 #ifdef TEST_INSDEL
401
402 // ****************************************************************************
403 // TEST CODE FOR INSERT/DELETE MACROS
404 // ****************************************************************************
405 //
406 // To use this, compile a temporary *.c file containing:
407 //
408 // #define DEBUG
409 // #define JUDY_ASSERT
410 // #define TEST_INSDEL
411 // #include "JudyPrivate.h"
412 // #include "JudyPrivateBranch.h"
413 //
414 // Use a command like this: cc -Ae +DD64 -I. -I JudyCommon -o t t.c
415 // For best results, include +DD64 on a 64-bit system.
416 //
417 // This test code exercises some tricky macros, but the output must be studied
418 // manually to verify it. Assume that for even-index testing, whole words
419 // (Word_t) suffices.
420
421 #include <stdio.h>
422
423 #define INDEXES 3 // in each array.
424
425
426 // ****************************************************************************
427 // I N I T
428 //
429 // Set up variables for next test. See usage.
430
431 FUNCTION void Init (
432 int base,
433 PWord_t PeIndex,
434 PWord_t PoIndex,
435 PWord_t Peleaf, // always whole words.
436 #ifndef JU_64BIT
437 uint8_t * Poleaf3)
438 #else
439 uint8_t * Poleaf3,
440 uint8_t * Poleaf5,
441 uint8_t * Poleaf6,
442 uint8_t * Poleaf7)
443 #endif
444 {
445 int offset;
446
447 *PeIndex = 99;
448
449 for (offset = 0; offset <= INDEXES; ++offset)
450 Peleaf[offset] = base + offset;
451
452 for (offset = 0; offset < (INDEXES + 1) * 3; ++offset)
453 Poleaf3[offset] = base + offset;
454
455 #ifndef JU_64BIT
456 *PoIndex = (91 << 24) | (92 << 16) | (93 << 8) | 94;
457 #else
458
459 *PoIndex = (91L << 56) | (92L << 48) | (93L << 40) | (94L << 32)
460 | (95L << 24) | (96L << 16) | (97L << 8) | 98L;
461
462 for (offset = 0; offset < (INDEXES + 1) * 5; ++offset)
463 Poleaf5[offset] = base + offset;
464
465 for (offset = 0; offset < (INDEXES + 1) * 6; ++offset)
466 Poleaf6[offset] = base + offset;
467
468 for (offset = 0; offset < (INDEXES + 1) * 7; ++offset)
469 Poleaf7[offset] = base + offset;
470 #endif
471
472 } // Init()
473
474
475 // ****************************************************************************
476 // P R I N T L E A F
477 //
478 // Print the byte values in a leaf.
479
480 FUNCTION void PrintLeaf (
481 char * Label, // for output.
482 int IOffset, // insertion offset in array.
483 int Indsize, // index size in bytes.
484 uint8_t * PLeaf) // array of Index bytes.
485 {
486 int offset; // in PLeaf.
487 int byte; // in one word.
488
489 (void) printf("%s %u: ", Label, IOffset);
490
491 for (offset = 0; offset <= INDEXES; ++offset)
492 {
493 for (byte = 0; byte < Indsize; ++byte)
494 (void) printf("%2d", PLeaf[(offset * Indsize) + byte]);
495
496 (void) printf(" ");
497 }
498
499 (void) printf("\n");
500
501 } // PrintLeaf()
502
503
504 // ****************************************************************************
505 // M A I N
506 //
507 // Test program.
508
509 FUNCTION main()
510 {
511 Word_t eIndex; // even, to insert.
512 Word_t oIndex; // odd, to insert.
513 Word_t eleaf [ INDEXES + 1]; // even leaf, index size 4.
514 uint8_t oleaf3[(INDEXES + 1) * 3]; // odd leaf, index size 3.
515 #ifdef JU_64BIT
516 uint8_t oleaf5[(INDEXES + 1) * 5]; // odd leaf, index size 5.
517 uint8_t oleaf6[(INDEXES + 1) * 6]; // odd leaf, index size 6.
518 uint8_t oleaf7[(INDEXES + 1) * 7]; // odd leaf, index size 7.
519 #endif
520 Word_t eleaf_2 [ INDEXES + 1]; // same, but second arrays:
521 uint8_t oleaf3_2[(INDEXES + 1) * 3];
522 #ifdef JU_64BIT
523 uint8_t oleaf5_2[(INDEXES + 1) * 5];
524 uint8_t oleaf6_2[(INDEXES + 1) * 6];
525 uint8_t oleaf7_2[(INDEXES + 1) * 7];
526 #endif
527 int ioffset; // index insertion offset.
528
529 #ifndef JU_64BIT
530 #define INIT Init( 0, & eIndex, & oIndex, eleaf, oleaf3)
531 #define INIT2 INIT; Init(50, & eIndex, & oIndex, eleaf_2, oleaf3_2)
532 #else
533 #define INIT Init( 0, & eIndex, & oIndex, eleaf, oleaf3, \
534 oleaf5, oleaf6, oleaf7)
535 #define INIT2 INIT; Init(50, & eIndex, & oIndex, eleaf_2, oleaf3_2, \
536 oleaf5_2, oleaf6_2, oleaf7_2)
537 #endif
538
539 #define WSIZE sizeof (Word_t) // shorthand.
540
541 #ifdef PRINTALL // to turn on "noisy" printouts.
542 #define PRINTLEAF(Label,IOffset,Indsize,PLeaf) \
543 PrintLeaf(Label,IOffset,Indsize,PLeaf)
544 #else
545 #define PRINTLEAF(Label,IOffset,Indsize,PLeaf) \
546 if (ioffset == 0) \
547 PrintLeaf(Label,IOffset,Indsize,PLeaf)
548 #endif
549
550 (void) printf(
551 "In each case, tests operate on an initial array of %d indexes. Even-index\n"
552 "tests set index values to 0,1,2...; odd-index tests set byte values to\n"
553 "0,1,2... Inserted indexes have a value of 99 or else byte values 91,92,...\n",
554 INDEXES);
555
556 (void) puts("\nJU_INSERTINPLACE():");
557
558 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
559 {
560 INIT;
561 PRINTLEAF("Before", ioffset, WSIZE, (uint8_t *) eleaf);
562 JU_INSERTINPLACE(eleaf, INDEXES, ioffset, eIndex);
563 PrintLeaf("After ", ioffset, WSIZE, (uint8_t *) eleaf);
564 }
565
566 (void) puts("\nJU_INSERTINPLACE3():");
567
568 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
569 {
570 INIT;
571 PRINTLEAF("Before", ioffset, 3, oleaf3);
572 JU_INSERTINPLACE3(oleaf3, INDEXES, ioffset, oIndex);
573 PrintLeaf("After ", ioffset, 3, oleaf3);
574 }
575
576 #ifdef JU_64BIT
577 (void) puts("\nJU_INSERTINPLACE5():");
578
579 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
580 {
581 INIT;
582 PRINTLEAF("Before", ioffset, 5, oleaf5);
583 JU_INSERTINPLACE5(oleaf5, INDEXES, ioffset, oIndex);
584 PrintLeaf("After ", ioffset, 5, oleaf5);
585 }
586
587 (void) puts("\nJU_INSERTINPLACE6():");
588
589 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
590 {
591 INIT;
592 PRINTLEAF("Before", ioffset, 6, oleaf6);
593 JU_INSERTINPLACE6(oleaf6, INDEXES, ioffset, oIndex);
594 PrintLeaf("After ", ioffset, 6, oleaf6);
595 }
596
597 (void) puts("\nJU_INSERTINPLACE7():");
598
599 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
600 {
601 INIT;
602 PRINTLEAF("Before", ioffset, 7, oleaf7);
603 JU_INSERTINPLACE7(oleaf7, INDEXES, ioffset, oIndex);
604 PrintLeaf("After ", ioffset, 7, oleaf7);
605 }
606 #endif // JU_64BIT
607
608 (void) puts("\nJU_DELETEINPLACE():");
609
610 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
611 {
612 INIT;
613 PRINTLEAF("Before", ioffset, WSIZE, (uint8_t *) eleaf);
614 JU_DELETEINPLACE(eleaf, INDEXES, ioffset);
615 PrintLeaf("After ", ioffset, WSIZE, (uint8_t *) eleaf);
616 }
617
618 (void) puts("\nJU_DELETEINPLACE_ODD(3):");
619
620 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
621 {
622 INIT;
623 PRINTLEAF("Before", ioffset, 3, oleaf3);
624 JU_DELETEINPLACE_ODD(oleaf3, INDEXES, ioffset, 3);
625 PrintLeaf("After ", ioffset, 3, oleaf3);
626 }
627
628 #ifdef JU_64BIT
629 (void) puts("\nJU_DELETEINPLACE_ODD(5):");
630
631 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
632 {
633 INIT;
634 PRINTLEAF("Before", ioffset, 5, oleaf5);
635 JU_DELETEINPLACE_ODD(oleaf5, INDEXES, ioffset, 5);
636 PrintLeaf("After ", ioffset, 5, oleaf5);
637 }
638
639 (void) puts("\nJU_DELETEINPLACE_ODD(6):");
640
641 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
642 {
643 INIT;
644 PRINTLEAF("Before", ioffset, 6, oleaf6);
645 JU_DELETEINPLACE_ODD(oleaf6, INDEXES, ioffset, 6);
646 PrintLeaf("After ", ioffset, 6, oleaf6);
647 }
648
649 (void) puts("\nJU_DELETEINPLACE_ODD(7):");
650
651 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
652 {
653 INIT;
654 PRINTLEAF("Before", ioffset, 7, oleaf7);
655 JU_DELETEINPLACE_ODD(oleaf7, INDEXES, ioffset, 7);
656 PrintLeaf("After ", ioffset, 7, oleaf7);
657 }
658 #endif // JU_64BIT
659
660 (void) puts("\nJU_INSERTCOPY():");
661
662 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
663 {
664 INIT2;
665 PRINTLEAF("Before, src ", ioffset, WSIZE, (uint8_t *) eleaf);
666 PRINTLEAF("Before, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
667 JU_INSERTCOPY(eleaf_2, eleaf, INDEXES, ioffset, eIndex);
668 PRINTLEAF("After, src ", ioffset, WSIZE, (uint8_t *) eleaf);
669 PrintLeaf("After, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
670 }
671
672 (void) puts("\nJU_INSERTCOPY3():");
673
674 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
675 {
676 INIT2;
677 PRINTLEAF("Before, src ", ioffset, 3, oleaf3);
678 PRINTLEAF("Before, dest", ioffset, 3, oleaf3_2);
679 JU_INSERTCOPY3(oleaf3_2, oleaf3, INDEXES, ioffset, oIndex);
680 PRINTLEAF("After, src ", ioffset, 3, oleaf3);
681 PrintLeaf("After, dest", ioffset, 3, oleaf3_2);
682 }
683
684 #ifdef JU_64BIT
685 (void) puts("\nJU_INSERTCOPY5():");
686
687 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
688 {
689 INIT2;
690 PRINTLEAF("Before, src ", ioffset, 5, oleaf5);
691 PRINTLEAF("Before, dest", ioffset, 5, oleaf5_2);
692 JU_INSERTCOPY5(oleaf5_2, oleaf5, INDEXES, ioffset, oIndex);
693 PRINTLEAF("After, src ", ioffset, 5, oleaf5);
694 PrintLeaf("After, dest", ioffset, 5, oleaf5_2);
695 }
696
697 (void) puts("\nJU_INSERTCOPY6():");
698
699 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
700 {
701 INIT2;
702 PRINTLEAF("Before, src ", ioffset, 6, oleaf6);
703 PRINTLEAF("Before, dest", ioffset, 6, oleaf6_2);
704 JU_INSERTCOPY6(oleaf6_2, oleaf6, INDEXES, ioffset, oIndex);
705 PRINTLEAF("After, src ", ioffset, 6, oleaf6);
706 PrintLeaf("After, dest", ioffset, 6, oleaf6_2);
707 }
708
709 (void) puts("\nJU_INSERTCOPY7():");
710
711 for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
712 {
713 INIT2;
714 PRINTLEAF("Before, src ", ioffset, 7, oleaf7);
715 PRINTLEAF("Before, dest", ioffset, 7, oleaf7_2);
716 JU_INSERTCOPY7(oleaf7_2, oleaf7, INDEXES, ioffset, oIndex);
717 PRINTLEAF("After, src ", ioffset, 7, oleaf7);
718 PrintLeaf("After, dest", ioffset, 7, oleaf7_2);
719 }
720 #endif // JU_64BIT
721
722 (void) puts("\nJU_DELETECOPY():");
723
724 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
725 {
726 INIT2;
727 PRINTLEAF("Before, src ", ioffset, WSIZE, (uint8_t *) eleaf);
728 PRINTLEAF("Before, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
729 JU_DELETECOPY(eleaf_2, eleaf, INDEXES, ioffset, ignore);
730 PRINTLEAF("After, src ", ioffset, WSIZE, (uint8_t *) eleaf);
731 PrintLeaf("After, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
732 }
733
734 (void) puts("\nJU_DELETECOPY_ODD(3):");
735
736 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
737 {
738 INIT2;
739 PRINTLEAF("Before, src ", ioffset, 3, oleaf3);
740 PRINTLEAF("Before, dest", ioffset, 3, oleaf3_2);
741 JU_DELETECOPY_ODD(oleaf3_2, oleaf3, INDEXES, ioffset, 3);
742 PRINTLEAF("After, src ", ioffset, 3, oleaf3);
743 PrintLeaf("After, dest", ioffset, 3, oleaf3_2);
744 }
745
746 #ifdef JU_64BIT
747 (void) puts("\nJU_DELETECOPY_ODD(5):");
748
749 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
750 {
751 INIT2;
752 PRINTLEAF("Before, src ", ioffset, 5, oleaf5);
753 PRINTLEAF("Before, dest", ioffset, 5, oleaf5_2);
754 JU_DELETECOPY_ODD(oleaf5_2, oleaf5, INDEXES, ioffset, 5);
755 PRINTLEAF("After, src ", ioffset, 5, oleaf5);
756 PrintLeaf("After, dest", ioffset, 5, oleaf5_2);
757 }
758
759 (void) puts("\nJU_DELETECOPY_ODD(6):");
760
761 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
762 {
763 INIT2;
764 PRINTLEAF("Before, src ", ioffset, 6, oleaf6);
765 PRINTLEAF("Before, dest", ioffset, 6, oleaf6_2);
766 JU_DELETECOPY_ODD(oleaf6_2, oleaf6, INDEXES, ioffset, 6);
767 PRINTLEAF("After, src ", ioffset, 6, oleaf6);
768 PrintLeaf("After, dest", ioffset, 6, oleaf6_2);
769 }
770
771 (void) puts("\nJU_DELETECOPY_ODD(7):");
772
773 for (ioffset = 0; ioffset < INDEXES; ++ioffset)
774 {
775 INIT2;
776 PRINTLEAF("Before, src ", ioffset, 7, oleaf7);
777 PRINTLEAF("Before, dest", ioffset, 7, oleaf7_2);
778 JU_DELETECOPY_ODD(oleaf7_2, oleaf7, INDEXES, ioffset, 7);
779 PRINTLEAF("After, src ", ioffset, 7, oleaf7);
780 PrintLeaf("After, dest", ioffset, 7, oleaf7_2);
781 }
782 #endif // JU_64BIT
783
784 return(0);
785
786 } // main()
787
788 #endif // TEST_INSDEL