196
200
// (~0UL), to avoid a compiler "overflow in implicit constant conversion"
199
#define JERR (-1) /* functions returning int or Word_t */
200
#define PJERR ((Pvoid_t) (~0UL)) /* mainly for use here, see below */
201
#define PPJERR ((PPvoid_t) (~0UL)) /* functions that return PPvoid_t */
203
#define JERR (-1) /* functions returning int or Word_t */
204
#define PJERR ((Pvoid_t) (~0UL)) /* mainly for use here, see below */
205
#define PPJERR ((PPvoid_t) (~0UL)) /* functions that return PPvoid_t */
203
207
// Convenience macro for when detailed error information (PJError_t) is not
204
208
// desired by the caller; a purposely short name:
206
#define PJE0 ((PJError_t) NULL)
210
#define PJE0 ((PJError_t) NULL)
209
213
// ****************************************************************************
210
214
// JUDY FUNCTIONS:
212
// PJE is a shorthand for use below:
214
#define _PJE PJError_t PJError
216
extern int __Judy1Test( Pvoid_t Pjpm, Word_t Index);
217
extern int Judy1Test( Pcvoid_t PArray, Word_t Index, _PJE);
218
extern int Judy1Set( PPvoid_t PPArray, Word_t Index, _PJE);
219
extern int Judy1SetArray( PPvoid_t PPArray, Word_t Count,
220
const Word_t * const PIndex,
222
extern int Judy1Unset( PPvoid_t PPArray, Word_t Index, _PJE);
223
extern Word_t Judy1Count( Pcvoid_t PArray, Word_t Index1,
224
Word_t Index2, _PJE);
225
extern int Judy1ByCount( Pcvoid_t PArray, Word_t Count,
226
Word_t * PIndex, _PJE);
227
extern Word_t Judy1FreeArray( PPvoid_t PPArray, _PJE);
228
extern Word_t Judy1MemUsed( Pcvoid_t PArray);
229
extern Word_t Judy1MemActive( Pcvoid_t PArray);
230
extern int Judy1First( Pcvoid_t PArray, Word_t * PIndex, _PJE);
231
extern int Judy1Next( Pcvoid_t PArray, Word_t * PIndex, _PJE);
232
extern int __Judy1Next( Pvoid_t Pjpm, Word_t * PIndex);
233
extern int Judy1Last( Pcvoid_t PArray, Word_t * PIndex, _PJE);
234
extern int Judy1Prev( Pcvoid_t PArray, Word_t * PIndex, _PJE);
235
extern int Judy1FirstEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
236
extern int Judy1NextEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
237
extern int Judy1LastEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
238
extern int Judy1PrevEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
240
extern PPvoid_t __JudyLGet( Pvoid_t Pjpm, Word_t Index);
241
extern PPvoid_t JudyLGet( Pcvoid_t PArray, Word_t Index, _PJE);
242
extern PPvoid_t JudyLIns( PPvoid_t PPArray, Word_t Index, _PJE);
243
extern int JudyLInsArray( PPvoid_t PPArray, Word_t Count,
244
const Word_t * const PIndex,
245
const Word_t * const PValue,
247
extern int JudyLDel( PPvoid_t PPArray, Word_t Index, _PJE);
248
extern Word_t JudyLCount( Pcvoid_t PArray, Word_t Index1,
249
Word_t Index2, _PJE);
250
extern PPvoid_t JudyLByCount( Pcvoid_t PArray, Word_t Count,
251
Word_t * PIndex, _PJE);
252
extern Word_t JudyLFreeArray( PPvoid_t PPArray, _PJE);
253
extern Word_t JudyLMemUsed( Pcvoid_t PArray);
254
extern Word_t JudyLMemActive( Pcvoid_t PArray);
255
extern PPvoid_t JudyLFirst( Pcvoid_t PArray, Word_t * PIndex, _PJE);
256
extern PPvoid_t JudyLNext( Pcvoid_t PArray, Word_t * PIndex, _PJE);
257
extern PPvoid_t __JudyLNext( Pvoid_t Pjpm, Word_t * PIndex);
258
extern PPvoid_t JudyLLast( Pcvoid_t PArray, Word_t * PIndex, _PJE);
259
extern PPvoid_t JudyLPrev( Pcvoid_t PArray, Word_t * PIndex, _PJE);
260
extern int JudyLFirstEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
261
extern int JudyLNextEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
262
extern int JudyLLastEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
263
extern int JudyLPrevEmpty( Pcvoid_t PArray, Word_t * PIndex, _PJE);
265
extern PPvoid_t JudySLGet( Pcvoid_t PArray, const char * Index, _PJE);
266
extern PPvoid_t JudySLIns( PPvoid_t PPArray, const char * Index, _PJE);
267
extern int JudySLDel( PPvoid_t PPArray, const char * Index, _PJE);
268
extern Word_t JudySLFreeArray( PPvoid_t PPArray, _PJE);
269
extern PPvoid_t JudySLFirst( Pcvoid_t PArray, char * Index, _PJE);
270
extern PPvoid_t JudySLNext( Pcvoid_t PArray, char * Index, _PJE);
271
extern PPvoid_t JudySLLast( Pcvoid_t PArray, char * Index, _PJE);
272
extern PPvoid_t JudySLPrev( Pcvoid_t PArray, char * Index, _PJE);
216
// P_JE is a shorthand for use below:
218
#define P_JE PJError_t PJError
220
// ****************************************************************************
223
extern int j__udy1Test( Pvoid_t Pjpm, Word_t Index);
224
extern int Judy1Test( Pcvoid_t PArray, Word_t Index, P_JE);
225
extern int Judy1Set( PPvoid_t PPArray, Word_t Index, P_JE);
226
extern int Judy1SetArray( PPvoid_t PPArray, Word_t Count,
227
const Word_t * const PIndex,
229
extern int Judy1Unset( PPvoid_t PPArray, Word_t Index, P_JE);
230
extern Word_t Judy1Count( Pcvoid_t PArray, Word_t Index1,
231
Word_t Index2, P_JE);
232
extern int Judy1ByCount( Pcvoid_t PArray, Word_t Count,
233
Word_t * PIndex, P_JE);
234
extern Word_t Judy1FreeArray( PPvoid_t PPArray, P_JE);
235
extern Word_t Judy1MemUsed( Pcvoid_t PArray);
236
extern Word_t Judy1MemActive( Pcvoid_t PArray);
237
extern int Judy1First( Pcvoid_t PArray, Word_t * PIndex, P_JE);
238
extern int Judy1Next( Pcvoid_t PArray, Word_t * PIndex, P_JE);
239
extern int j__udy1Next( Pvoid_t Pjpm, Word_t * PIndex);
240
extern int Judy1Last( Pcvoid_t PArray, Word_t * PIndex, P_JE);
241
extern int Judy1Prev( Pcvoid_t PArray, Word_t * PIndex, P_JE);
242
extern int Judy1FirstEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
243
extern int Judy1NextEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
244
extern int Judy1LastEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
245
extern int Judy1PrevEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
247
extern PPvoid_t j__udyLGet( Pvoid_t Pjpm, Word_t Index);
248
extern PPvoid_t JudyLGet( Pcvoid_t PArray, Word_t Index, P_JE);
249
extern PPvoid_t JudyLIns( PPvoid_t PPArray, Word_t Index, P_JE);
250
extern int JudyLInsArray( PPvoid_t PPArray, Word_t Count,
251
const Word_t * const PIndex,
252
const Word_t * const PValue,
254
// ****************************************************************************
257
extern int JudyLDel( PPvoid_t PPArray, Word_t Index, P_JE);
258
extern Word_t JudyLCount( Pcvoid_t PArray, Word_t Index1,
259
Word_t Index2, P_JE);
260
extern PPvoid_t JudyLByCount( Pcvoid_t PArray, Word_t Count,
261
Word_t * PIndex, P_JE);
262
extern Word_t JudyLFreeArray( PPvoid_t PPArray, P_JE);
263
extern Word_t JudyLMemUsed( Pcvoid_t PArray);
264
extern Word_t JudyLMemActive( Pcvoid_t PArray);
265
extern PPvoid_t JudyLFirst( Pcvoid_t PArray, Word_t * PIndex, P_JE);
266
extern PPvoid_t JudyLNext( Pcvoid_t PArray, Word_t * PIndex, P_JE);
267
extern PPvoid_t j__udyLNext( Pvoid_t Pjpm, Word_t * PIndex);
268
extern PPvoid_t JudyLLast( Pcvoid_t PArray, Word_t * PIndex, P_JE);
269
extern PPvoid_t JudyLPrev( Pcvoid_t PArray, Word_t * PIndex, P_JE);
270
extern int JudyLFirstEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
271
extern int JudyLNextEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
272
extern int JudyLLastEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
273
extern int JudyLPrevEmpty( Pcvoid_t PArray, Word_t * PIndex, P_JE);
275
// ****************************************************************************
278
extern PPvoid_t JudySLGet( Pcvoid_t, const uint8_t * Index, P_JE);
279
extern PPvoid_t JudySLIns( PPvoid_t, const uint8_t * Index, P_JE);
280
extern int JudySLDel( PPvoid_t, const uint8_t * Index, P_JE);
281
extern Word_t JudySLFreeArray( PPvoid_t, P_JE);
282
extern PPvoid_t JudySLFirst( Pcvoid_t, uint8_t * Index, P_JE);
283
extern PPvoid_t JudySLNext( Pcvoid_t, uint8_t * Index, P_JE);
284
extern PPvoid_t JudySLLast( Pcvoid_t, uint8_t * Index, P_JE);
285
extern PPvoid_t JudySLPrev( Pcvoid_t, uint8_t * Index, P_JE);
287
// ****************************************************************************
288
// JUDYHSL FUNCTIONS:
290
extern PPvoid_t JudyHSGet( Pcvoid_t, void *, Word_t);
291
extern PPvoid_t JudyHSIns( PPvoid_t, void *, Word_t, P_JE);
292
extern int JudyHSDel( PPvoid_t, void *, Word_t, P_JE);
293
extern Word_t JudyHSFreeArray( PPvoid_t, P_JE);
274
295
extern const char *Judy1MallocSizes;
275
296
extern const char *JudyLMallocSizes;
278
// JUDYL ARRAY POINTER LOW BITS PROTECTED FOR USE BY APPLICATIONS:
280
// The JLAP_INVALID pattern never appears in a JudyL array pointer. Hence
281
// applications that build trees of JudyL arrays can use this pattern to
282
// distinguish a JudyL array value that is a pointer to another JudyL array
283
// from one that is a pointer to some other, application-defined object.
285
// Note: J1LAP_NEXTTYPE is used to build a mask, but must agree with the
286
// J1*/JL* values below.
288
// Note: Use old-style comments here because some tools insist on it for
289
// macros referenced in other macros.
291
#define J1LAP_NEXTTYPE 0x8 /* first enum value beyond J*AP types */
293
#define JLAP_MASK (J1LAP_NEXTTYPE-1) /* mask pointer for JLAP_INVALID */
294
#define JLAP_INVALID 0x4 /* not a JLAP */
297
// JUDY ARRAY POINTER LOW BITS = TYPES:
299
// Note: Judy libraries can be constructed with JLAPLEAF_POPU* unused, but
300
// external callers cannot tell if this is the case, so in this header file
301
// they are still defined and supported.
304
JLAPNULL = 0x0, /* must be == 0 */
305
J1APNULL = 0x0, /* must be == 0 */
306
JLAPLEAF = 0x1, /* Word_t leafW with Pop0 in word 1 */
307
// JLAPLEAF_POPU2 = 0x2, /* Word_t leafW with Pop1 == 2 */
308
JLAPBRANCH = 0x3, /* pointer to jLpm_t => branch */
309
JLAPINVALID = JLAP_INVALID, /* not a JLAP, assume == 4 */
310
// JLAPLEAF_POPU1 = 0x5, /* Word_t leafW with Pop1 == 1 */
311
J1APLEAF = 0x6, /* Word_t leafW with Pop0 in word 1 */
312
J1APBRANCH = 0x7 /* pointer to j1pm_t => branch */
298
// ****************************************************************************
299
// JUDY memory interface to malloc() FUNCTIONS:
301
extern Word_t JudyMalloc(Word_t); // words reqd => words allocd.
302
extern Word_t JudyMallocVirtual(Word_t); // words reqd => words allocd.
303
extern void JudyFree(Pvoid_t, Word_t); // free, size in words.
304
extern void JudyFreeVirtual(Pvoid_t, Word_t); // free, size in words.
306
#define JLAP_INVALID 0x1 /* flag to mark pointer "not a Judy array" */
316
308
// ****************************************************************************
317
309
// MACRO EQUIVALENTS FOR JUDY FUNCTIONS:
401
387
// "Judy Set Error":
403
#define _JSE(FuncName,Errno) ((void) 0)
389
#define J_SE(FuncName,Errno) ((void) 0)
405
// Note: In each _J*() case below, the digit is the number of key parameters
406
// to the Judy*() call. Just assign the Func result to the caller's Rc value
391
// Note: In each J_*() case below, the digit is the number of key parameters
392
// to the Judy*() call. Just assign the Func result to the callers Rc value
407
393
// without a cast because none is required, and this keeps the API simpler.
408
// However, a family of different _J*() macros is needed to support the
394
// However, a family of different J_*() macros is needed to support the
409
395
// different numbers of key parameters (0,1,2) and the Func return type.
411
397
// In the names below, "I" = integer result; "P" = pointer result. Note, the
412
// Funcs for _J*P() return PPvoid_t, but cast this to a Pvoid_t for flexible,
398
// Funcs for J_*P() return PPvoid_t, but cast this to a Pvoid_t for flexible,
413
399
// error-free assignment, and then compare to PJERR.
415
#define _J0I(Rc,PArray,Func,FuncName) \
416
{ (Rc) = Func(PArray, PJE0); }
418
#define _J1I(Rc,PArray,Index,Func,FuncName) \
419
{ (Rc) = Func(PArray, Index, PJE0); }
421
#define _J1P(PV,PArray,Index,Func,FuncName) \
422
{ (PV) = (Pvoid_t) Func(PArray, Index, PJE0); }
424
#define _J2I(Rc,PArray,Index,Arg2,Func,FuncName) \
425
{ (Rc) = Func(PArray, Index, Arg2, PJE0); }
427
#define _J2C(Rc,PArray,Index1,Index2,Func,FuncName) \
428
{ (Rc) = Func(PArray, Index1, Index2, PJE0); }
430
#define _J2P(PV,PArray,Index,Arg2,Func,FuncName) \
431
{ (PV) = (Pvoid_t) Func(PArray, Index, Arg2, PJE0); }
401
#define J_0I(Rc,PArray,Func,FuncName) \
402
{ (Rc) = Func(PArray, PJE0); }
404
#define J_1I(Rc,PArray,Index,Func,FuncName) \
405
{ (Rc) = Func(PArray, Index, PJE0); }
407
#define J_1P(PV,PArray,Index,Func,FuncName) \
408
{ (PV) = (Pvoid_t) Func(PArray, Index, PJE0); }
410
#define J_2I(Rc,PArray,Index,Arg2,Func,FuncName) \
411
{ (Rc) = Func(PArray, Index, Arg2, PJE0); }
413
#define J_2C(Rc,PArray,Index1,Index2,Func,FuncName) \
414
{ (Rc) = Func(PArray, Index1, Index2, PJE0); }
416
#define J_2P(PV,PArray,Index,Arg2,Func,FuncName) \
417
{ (PV) = (Pvoid_t) Func(PArray, Index, Arg2, PJE0); }
433
419
// Variations for Judy*Set/InsArray functions:
435
#define _J2AI(Rc,PArray,Count,PIndex,Func,FuncName) \
436
{ (Rc) = Func(PArray, Count, PIndex, PJE0); }
437
#define _J3AI(Rc,PArray,Count,PIndex,PValue,Func,FuncName) \
438
{ (Rc) = Func(PArray, Count, PIndex, PValue, PJE0); }
421
#define J_2AI(Rc,PArray,Count,PIndex,Func,FuncName) \
422
{ (Rc) = Func(PArray, Count, PIndex, PJE0); }
423
#define J_3AI(Rc,PArray,Count,PIndex,PValue,Func,FuncName) \
424
{ (Rc) = Func(PArray, Count, PIndex, PValue, PJE0); }
440
426
#else /* ================ ! JUDYERROR_NOTEST ============================= */
442
#define _JE(FuncName,PJE) \
443
JUDYERROR(__FILE__, __LINE__, FuncName, JU_ERRNO(PJE), JU_ERRID(PJE))
445
#define _JSE(FuncName,Errno) \
448
JU_ERRNO(&_JError) = (Errno); \
449
JU_ERRID(&_JError) = __LINE__; \
450
_JE(FuncName, &_JError); \
453
// Note: In each _J*() case below, the digit is the number of key parameters
454
// to the Judy*() call. Just assign the Func result to the caller's Rc value
428
#define J_E(FuncName,PJE) \
429
JUDYERROR(__FILE__, __LINE__, FuncName, JU_ERRNO(PJE), JU_ERRID(PJE))
431
#define J_SE(FuncName,Errno) \
434
JU_ERRNO(&J_Error) = (Errno); \
435
JU_ERRID(&J_Error) = __LINE__; \
436
J_E(FuncName, &J_Error); \
439
// Note: In each J_*() case below, the digit is the number of key parameters
440
// to the Judy*() call. Just assign the Func result to the callers Rc value
455
441
// without a cast because none is required, and this keeps the API simpler.
456
// However, a family of different _J*() macros is needed to support the
442
// However, a family of different J_*() macros is needed to support the
457
443
// different numbers of key parameters (0,1,2) and the Func return type.
459
445
// In the names below, "I" = integer result; "P" = pointer result. Note, the
460
// Funcs for _J*P() return PPvoid_t, but cast this to a Pvoid_t for flexible,
446
// Funcs for J_*P() return PPvoid_t, but cast this to a Pvoid_t for flexible,
461
447
// error-free assignment, and then compare to PJERR.
463
#define _J0I(Rc,PArray,Func,FuncName) \
466
if (((Rc) = Func(PArray, &_JError)) == JERR) \
467
_JE(FuncName, &_JError); \
470
#define _J1I(Rc,PArray,Index,Func,FuncName) \
473
if (((Rc) = Func(PArray, Index, &_JError)) == JERR) \
474
_JE(FuncName, &_JError); \
477
#define _J1P(Rc,PArray,Index,Func,FuncName) \
480
if (((Rc) = (Pvoid_t) Func(PArray, Index, &_JError)) == PJERR) \
481
_JE(FuncName, &_JError); \
484
#define _J2I(Rc,PArray,Index,Arg2,Func,FuncName) \
487
if (((Rc) = Func(PArray, Index, Arg2, &_JError)) == JERR) \
488
_JE(FuncName, &_JError); \
449
#define J_0I(Rc,PArray,Func,FuncName) \
452
if (((Rc) = Func(PArray, &J_Error)) == JERR) \
453
J_E(FuncName, &J_Error); \
456
#define J_1I(Rc,PArray,Index,Func,FuncName) \
459
if (((Rc) = Func(PArray, Index, &J_Error)) == JERR) \
460
J_E(FuncName, &J_Error); \
463
#define J_1P(Rc,PArray,Index,Func,FuncName) \
466
if (((Rc) = (Pvoid_t) Func(PArray, Index, &J_Error)) == PJERR) \
467
J_E(FuncName, &J_Error); \
470
#define J_2I(Rc,PArray,Index,Arg2,Func,FuncName) \
473
if (((Rc) = Func(PArray, Index, Arg2, &J_Error)) == JERR) \
474
J_E(FuncName, &J_Error); \
491
477
// Variation for Judy*Count functions, which return 0, not JERR, for error (and
492
478
// also for other non-error cases):
494
480
// Note: JU_ERRNO_NFMAX should only apply to 32-bit Judy1, but this header
495
// file lacks the necessary ifdef's to make it go away otherwise, so always
481
// file lacks the necessary ifdefs to make it go away otherwise, so always
496
482
// check against it.
498
#define _J2C(Rc,PArray,Index1,Index2,Func,FuncName) \
501
if ((((Rc) = Func(PArray, Index1, Index2, &_JError)) == 0) \
502
&& (JU_ERRNO(&_JError) > JU_ERRNO_NFMAX)) \
504
_JE(FuncName, &_JError); \
484
#define J_2C(Rc,PArray,Index1,Index2,Func,FuncName) \
487
if ((((Rc) = Func(PArray, Index1, Index2, &J_Error)) == 0) \
488
&& (JU_ERRNO(&J_Error) > JU_ERRNO_NFMAX)) \
490
J_E(FuncName, &J_Error); \
508
#define _J2P(PV,PArray,Index,Arg2,Func,FuncName) \
511
if (((PV) = (Pvoid_t) Func(PArray, Index, Arg2, &_JError)) \
512
== PJERR) _JE(FuncName, &_JError); \
494
#define J_2P(PV,PArray,Index,Arg2,Func,FuncName) \
497
if (((PV) = (Pvoid_t) Func(PArray, Index, Arg2, &J_Error)) \
498
== PJERR) J_E(FuncName, &J_Error); \
515
501
// Variations for Judy*Set/InsArray functions:
517
#define _J2AI(Rc,PArray,Count,PIndex,Func,FuncName) \
520
if (((Rc) = Func(PArray, Count, PIndex, &_JError)) == JERR) \
521
_JE(FuncName, &_JError); \
503
#define J_2AI(Rc,PArray,Count,PIndex,Func,FuncName) \
506
if (((Rc) = Func(PArray, Count, PIndex, &J_Error)) == JERR) \
507
J_E(FuncName, &J_Error); \
524
#define _J3AI(Rc,PArray,Count,PIndex,PValue,Func,FuncName) \
527
if (((Rc) = Func(PArray, Count, PIndex, PValue, &_JError)) \
528
== JERR) _JE(FuncName, &_JError); \
510
#define J_3AI(Rc,PArray,Count,PIndex,PValue,Func,FuncName) \
513
if (((Rc) = Func(PArray, Count, PIndex, PValue, &J_Error)) \
514
== JERR) J_E(FuncName, &J_Error); \
531
517
#endif /* ================ ! JUDYERROR_NOTEST ============================= */
533
519
// Some of the macros are special cases that use inlined shortcuts for speed
534
520
// with root-level leaves:
536
#define J1T(Rc,PArray,Index) \
538
Word_t _jpt = ((Word_t) (PArray)) & JLAP_MASK; \
539
PWord_t _PL = (PWord_t) (((Word_t) (PArray)) ^ _jpt); \
542
if (_jpt == J1APLEAF) \
544
Word_t _pop1 = _PL[0] + 1; \
545
if ((Index) <= _PL[_pop1]) \
549
if (*(++_PL) >= (Index)) \
551
if (*_PL == (Index)) (Rc) = 1; \
557
else if (_jpt == J1APBRANCH) \
559
/* note: no error possible here: */ \
560
(Rc) = __Judy1Test((Pvoid_t) _PL, (Index)); \
562
else if (PArray != (Pvoid_t) NULL) \
565
_JSE("Judy1Test", JU_ERRNO_NOTJUDY1); \
569
#define J1S( Rc, PArray, Index) \
570
_J1I(Rc, (&(PArray)), Index, Judy1Set, "Judy1Set")
571
#define J1SA(Rc, PArray, Count, PIndex) \
572
_J2AI(Rc,(&(PArray)), Count, PIndex, Judy1SetArray, "Judy1SetArray")
573
#define J1U( Rc, PArray, Index) \
574
_J1I(Rc, (&(PArray)), Index, Judy1Unset, "Judy1Unset")
575
#define J1F( Rc, PArray, Index) \
576
_J1I(Rc, PArray, &(Index), Judy1First, "Judy1First")
577
#define J1N( Rc, PArray, Index) \
578
_J1I(Rc, PArray, &(Index), Judy1Next, "Judy1Next")
579
#define J1L( Rc, PArray, Index) \
580
_J1I(Rc, PArray, &(Index), Judy1Last, "Judy1Last")
581
#define J1P( Rc, PArray, Index) \
582
_J1I(Rc, PArray, &(Index), Judy1Prev, "Judy1Prev")
583
#define J1FE(Rc, PArray, Index) \
584
_J1I(Rc, PArray, &(Index), Judy1FirstEmpty, "Judy1FirstEmpty")
585
#define J1NE(Rc, PArray, Index) \
586
_J1I(Rc, PArray, &(Index), Judy1NextEmpty, "Judy1NextEmpty")
587
#define J1LE(Rc, PArray, Index) \
588
_J1I(Rc, PArray, &(Index), Judy1LastEmpty, "Judy1LastEmpty")
589
#define J1PE(Rc, PArray, Index) \
590
_J1I(Rc, PArray, &(Index), Judy1PrevEmpty, "Judy1PrevEmpty")
591
#define J1C( Rc, PArray, Index1, Index2) \
592
_J2C(Rc, PArray, Index1, Index2, Judy1Count, "Judy1Count")
593
#define J1BC(Rc, PArray, Count, Index) \
594
_J2I(Rc, PArray, Count, &(Index), Judy1ByCount, "Judy1ByCount")
595
#define J1FA(Rc, PArray) \
596
_J0I(Rc, (&(PArray)), Judy1FreeArray, "Judy1FreeArray")
597
#define J1MU(Rc, PArray) \
598
(Rc) = Judy1MemUsed(PArray)
600
#define JLG(PV,PArray,Index) \
602
Word_t _jpt = ((Word_t) (PArray)) & JLAP_MASK; \
603
PWord_t _PL = (PWord_t) (((Word_t) (PArray)) ^ _jpt); \
604
extern const unsigned char __jL_LeafWOffset[]; \
606
(PV) = (Pvoid_t) NULL; \
608
if (_jpt == JLAPLEAF) \
610
Word_t _pop1 = _PL[0] + 1; \
611
if ((Index) <= _PL[_pop1]) \
615
if (*(++_PL) >= (Index)) \
617
if (*_PL == (Index)) \
619
(PV) = (Pvoid_t)(_PL+__jL_LeafWOffset[_pop1]-1);\
626
else if (_jpt == JLAPBRANCH) \
628
(PV) = (Pvoid_t) __JudyLGet((Pvoid_t) _PL, (Index)); \
630
else if (PArray != (Pvoid_t) NULL) \
633
_JSE("JudyLGet", JU_ERRNO_NOTJUDYL); \
637
#define JLI( PV, PArray, Index) \
638
_J1P(PV, (&(PArray)), Index, JudyLIns, "JudyLIns")
639
#define JLIA(Rc, PArray, Count, PIndex, PValue) \
640
_J3AI(Rc,(&(PArray)), Count, PIndex, PValue, JudyLInsArray, \
642
#define JLD( Rc, PArray, Index) \
643
_J1I(Rc, (&(PArray)), Index, JudyLDel, "JudyLDel")
644
#define JLF( PV, PArray, Index) \
645
_J1P(PV, PArray, &(Index), JudyLFirst, "JudyLFirst")
647
#define JLN(PV,PArray,Index) \
649
Word_t _jpt = ((Word_t) (PArray)) & JLAP_MASK; \
650
PWord_t _PL = (PWord_t) (((Word_t) (PArray)) ^ _jpt); \
651
extern const unsigned char __jL_LeafWOffset[]; \
653
(PV) = (Pvoid_t) NULL; \
655
if (_jpt == JLAPLEAF) \
657
Word_t _pop1 = _PL[0] + 1; \
658
if ((Index) < _PL[_pop1]) \
662
if ((Index) < *(++_PL)) \
665
(PV) = (Pvoid_t) (_PL + __jL_LeafWOffset[_pop1] -1);\
671
else if (_jpt == JLAPBRANCH) \
673
(PV) = (Pvoid_t) JudyLNext((Pvoid_t) PArray, &(Index), PJE0); \
675
else if (PArray != (Pvoid_t) NULL) \
678
_JSE("JudyLNext", JU_ERRNO_NOTJUDYL); \
682
#define JLL( PV, PArray, Index) \
683
_J1P(PV, PArray, &(Index), JudyLLast, "JudyLLast")
684
#define JLP( PV, PArray, Index) \
685
_J1P(PV, PArray, &(Index), JudyLPrev, "JudyLPrev")
686
#define JLFE(Rc, PArray, Index) \
687
_J1I(Rc, PArray, &(Index), JudyLFirstEmpty, "JudyLFirstEmpty")
688
#define JLNE(Rc, PArray, Index) \
689
_J1I(Rc, PArray, &(Index), JudyLNextEmpty, "JudyLNextEmpty")
690
#define JLLE(Rc, PArray, Index) \
691
_J1I(Rc, PArray, &(Index), JudyLLastEmpty, "JudyLLastEmpty")
692
#define JLPE(Rc, PArray, Index) \
693
_J1I(Rc, PArray, &(Index), JudyLPrevEmpty, "JudyLPrevEmpty")
694
#define JLC( Rc, PArray, Index1, Index2) \
695
_J2C(Rc, PArray, Index1, Index2, JudyLCount, "JudyLCount")
696
#define JLBC(PV, PArray, Count, Index) \
697
_J2P(PV, PArray, Count, &(Index), JudyLByCount, "JudyLByCount")
698
#define JLFA(Rc, PArray) \
699
_J0I(Rc, (&(PArray)), JudyLFreeArray, "JudyLFreeArray")
700
#define JLMU(Rc, PArray) \
701
(Rc) = JudyLMemUsed(PArray)
703
#define JSLG( PV, PArray, Index) \
704
_J1P( PV, PArray, Index, JudySLGet, "JudySLGet")
705
#define JSLI( PV, PArray, Index) \
706
_J1P( PV, (&(PArray)), Index, JudySLIns, "JudySLIns")
707
#define JSLD( Rc, PArray, Index) \
708
_J1I( Rc, (&(PArray)), Index, JudySLDel, "JudySLDel")
709
#define JSLF( PV, PArray, Index) \
710
_J1P( PV, PArray, Index, JudySLFirst, "JudySLFirst")
711
#define JSLN( PV, PArray, Index) \
712
_J1P( PV, PArray, Index, JudySLNext, "JudySLNext")
713
#define JSLL( PV, PArray, Index) \
714
_J1P( PV, PArray, Index, JudySLLast, "JudySLLast")
715
#define JSLP( PV, PArray, Index) \
716
_J1P( PV, PArray, Index, JudySLPrev, "JudySLPrev")
717
#define JSLFA(Rc, PArray) \
718
_J0I( Rc, (&(PArray)), JudySLFreeArray, "JudySLFreeArray")
522
// This is a slower version with current processors, but in the future...
524
#define J1T(Rc,PArray,Index) \
526
PWord_t P_L = (PWord_t)(PArray); \
528
if (P_L) /* cannot be a NULL pointer */ \
530
if (P_L[0] < 31) /* is a LeafL */ \
532
Word_t _pop1 = P_L[0] + 1; \
533
PWord_t P_LE = P_L + _pop1; \
540
_index = P_L[_pop1]; \
541
if ((Index) > _index) P_L += _pop1 + 1; \
543
while (P_L <= P_LE) \
547
if (_index >= (Index)) break; \
550
if (_index == (Index)) (Rc) = 1; \
554
(Rc) = j__udy1Test((Pvoid_t)P_L, (Index)); \
560
#define J1T(Rc,PArray,Index) \
562
PWord_t P_L = (PWord_t)(PArray); \
564
if (P_L) /* cannot be a NULL pointer */ \
566
if (P_L[0] < 31) /* is a LeafL */ \
568
Word_t _pop1 = P_L[0] + 1; \
569
Word_t _EIndex = P_L[_pop1]; \
572
if ((Index) > P_L[_pop1/2]) P_L += _pop1/2; \
574
if ((Index) <= _EIndex) \
576
while((Index) > *(++P_L)); \
577
if (*P_L == (Index)) (Rc) = 1; \
582
(Rc) = j__udy1Test((Pvoid_t)P_L, Index); \
587
#define J1S( Rc, PArray, Index) \
588
J_1I(Rc, (&(PArray)), Index, Judy1Set, "Judy1Set")
589
#define J1SA(Rc, PArray, Count, PIndex) \
590
J_2AI(Rc,(&(PArray)), Count, PIndex, Judy1SetArray, "Judy1SetArray")
591
#define J1U( Rc, PArray, Index) \
592
J_1I(Rc, (&(PArray)), Index, Judy1Unset, "Judy1Unset")
593
#define J1F( Rc, PArray, Index) \
594
J_1I(Rc, PArray, &(Index), Judy1First, "Judy1First")
595
#define J1N( Rc, PArray, Index) \
596
J_1I(Rc, PArray, &(Index), Judy1Next, "Judy1Next")
597
#define J1L( Rc, PArray, Index) \
598
J_1I(Rc, PArray, &(Index), Judy1Last, "Judy1Last")
599
#define J1P( Rc, PArray, Index) \
600
J_1I(Rc, PArray, &(Index), Judy1Prev, "Judy1Prev")
601
#define J1FE(Rc, PArray, Index) \
602
J_1I(Rc, PArray, &(Index), Judy1FirstEmpty, "Judy1FirstEmpty")
603
#define J1NE(Rc, PArray, Index) \
604
J_1I(Rc, PArray, &(Index), Judy1NextEmpty, "Judy1NextEmpty")
605
#define J1LE(Rc, PArray, Index) \
606
J_1I(Rc, PArray, &(Index), Judy1LastEmpty, "Judy1LastEmpty")
607
#define J1PE(Rc, PArray, Index) \
608
J_1I(Rc, PArray, &(Index), Judy1PrevEmpty, "Judy1PrevEmpty")
609
#define J1C( Rc, PArray, Index1, Index2) \
610
J_2C(Rc, PArray, Index1, Index2, Judy1Count, "Judy1Count")
611
#define J1BC(Rc, PArray, Count, Index) \
612
J_2I(Rc, PArray, Count, &(Index), Judy1ByCount, "Judy1ByCount")
613
#define J1FA(Rc, PArray) \
614
J_0I(Rc, (&(PArray)), Judy1FreeArray, "Judy1FreeArray")
615
#define J1MU(Rc, PArray) \
616
(Rc) = Judy1MemUsed(PArray)
618
#define JLG(PV,PArray,Index) \
620
extern const uint8_t j__L_LeafWOffset[]; \
621
PWord_t P_L = (PWord_t)(PArray); \
622
(PV) = (Pvoid_t) NULL; \
623
if (P_L) /* cannot be a NULL pointer */ \
625
if (P_L[0] < 31) /* is a LeafL */ \
627
Word_t _pop1 = P_L[0] + 1; \
628
Word_t _EIndex = P_L[_pop1]; \
629
Word_t _off = j__L_LeafWOffset[_pop1] - 1; \
632
if ((Index) > P_L[_pop1/2]) P_L += _pop1/2; \
634
if ((Index) <= _EIndex) \
636
while((Index) > *(++P_L)); \
637
if (*P_L == (Index)) (PV) = (Pvoid_t)(P_L+_off);\
642
(PV) = (Pvoid_t)j__udyLGet((Pvoid_t)P_L, Index); \
647
#define JLI( PV, PArray, Index) \
648
J_1P(PV, (&(PArray)), Index, JudyLIns, "JudyLIns")
650
#define JLIA(Rc, PArray, Count, PIndex, PValue) \
651
J_3AI(Rc,(&(PArray)), Count, PIndex, PValue, JudyLInsArray, \
653
#define JLD( Rc, PArray, Index) \
654
J_1I(Rc, (&(PArray)), Index, JudyLDel, "JudyLDel")
656
#define JLF( PV, PArray, Index) \
657
J_1P(PV, PArray, &(Index), JudyLFirst, "JudyLFirst")
659
#define JLN(PV,PArray,Index) \
661
extern const uint8_t j__L_LeafWOffset[]; \
662
PWord_t P_L = (PWord_t) (PArray); \
664
(PV) = (Pvoid_t) NULL; \
666
if (P_L) /* cannot be a NULL pointer */ \
668
if (P_L[0] < 31) /* is a LeafL */ \
670
Word_t _pop1 = P_L[0] + 1; \
671
Word_t _off = j__L_LeafWOffset[_pop1] -1; \
672
if ((Index) < P_L[_pop1]) \
676
if ((Index) < *(++P_L)) \
679
(PV) = (Pvoid_t) (P_L + _off); \
687
(PV) = (Pvoid_t)JudyLNext((Pvoid_t) PArray, &(Index), PJE0); \
692
#define JLL( PV, PArray, Index) \
693
J_1P(PV, PArray, &(Index), JudyLLast, "JudyLLast")
694
#define JLP( PV, PArray, Index) \
695
J_1P(PV, PArray, &(Index), JudyLPrev, "JudyLPrev")
696
#define JLFE(Rc, PArray, Index) \
697
J_1I(Rc, PArray, &(Index), JudyLFirstEmpty, "JudyLFirstEmpty")
698
#define JLNE(Rc, PArray, Index) \
699
J_1I(Rc, PArray, &(Index), JudyLNextEmpty, "JudyLNextEmpty")
700
#define JLLE(Rc, PArray, Index) \
701
J_1I(Rc, PArray, &(Index), JudyLLastEmpty, "JudyLLastEmpty")
702
#define JLPE(Rc, PArray, Index) \
703
J_1I(Rc, PArray, &(Index), JudyLPrevEmpty, "JudyLPrevEmpty")
704
#define JLC( Rc, PArray, Index1, Index2) \
705
J_2C(Rc, PArray, Index1, Index2, JudyLCount, "JudyLCount")
706
#define JLBC(PV, PArray, Count, Index) \
707
J_2P(PV, PArray, Count, &(Index), JudyLByCount, "JudyLByCount")
708
#define JLFA(Rc, PArray) \
709
J_0I(Rc, (&(PArray)), JudyLFreeArray, "JudyLFreeArray")
710
#define JLMU(Rc, PArray) \
711
(Rc) = JudyLMemUsed(PArray)
713
#define JHSI(PV, PArray, PIndex, Count) \
714
J_2P(PV, (&(PArray)), PIndex, Count, JudyHSIns, "JudyHSIns")
715
#define JHSG(PV, PArray, PIndex, Count) \
716
(PV) = (Pvoid_t) JudyHSGet(PArray, PIndex, Count)
717
#define JHSD(Rc, PArray, PIndex, Count) \
718
J_2I(Rc, (&(PArray)), PIndex, Count, JudyHSDel, "JudyHSDel")
719
#define JHSFA(Rc, PArray) \
720
J_0I(Rc, (&(PArray)), JudyHSFreeArray, "JudyHSFreeArray")
722
#define JSLG( PV, PArray, Index) \
723
J_1P( PV, PArray, Index, JudySLGet, "JudySLGet")
724
#define JSLI( PV, PArray, Index) \
725
J_1P( PV, (&(PArray)), Index, JudySLIns, "JudySLIns")
726
#define JSLD( Rc, PArray, Index) \
727
J_1I( Rc, (&(PArray)), Index, JudySLDel, "JudySLDel")
728
#define JSLF( PV, PArray, Index) \
729
J_1P( PV, PArray, Index, JudySLFirst, "JudySLFirst")
730
#define JSLN( PV, PArray, Index) \
731
J_1P( PV, PArray, Index, JudySLNext, "JudySLNext")
732
#define JSLL( PV, PArray, Index) \
733
J_1P( PV, PArray, Index, JudySLLast, "JudySLLast")
734
#define JSLP( PV, PArray, Index) \
735
J_1P( PV, PArray, Index, JudySLPrev, "JudySLPrev")
736
#define JSLFA(Rc, PArray) \
737
J_0I( Rc, (&(PArray)), JudySLFreeArray, "JudySLFreeArray")
720
739
#ifdef __cplusplus