Added and working! Array module 1.65 is a go for release!

This commit is contained in:
Twilight Suzuka
2006-01-07 04:36:12 +00:00
parent e8a4b46cc5
commit a3572f7206
121 changed files with 80794 additions and 0 deletions

View File

@ -0,0 +1,954 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Judy*ByCount() function for Judy1 and JudyL.
// Compile with one of -DJUDY1 or -DJUDYL.
//
// Compile with -DNOSMARTJBB, -DNOSMARTJBU, and/or -DNOSMARTJLB to build a
// version with cache line optimizations deleted, for testing.
//
// Judy*ByCount() is a conceptual although not literal inverse of Judy*Count().
// Judy*Count() takes a pair of Indexes, and allows finding the ordinal of a
// given Index (that is, its position in the list of valid indexes from the
// beginning) as a degenerate case, because in general the count between two
// Indexes, inclusive, is not always just the difference in their ordinals.
// However, it suffices for Judy*ByCount() to simply be an ordinal-to-Index
// mapper.
//
// Note: Like Judy*Count(), this code must "count sideways" in branches, which
// can result in a lot of cache line fills. However, unlike Judy*Count(), this
// code does not receive a specific Index, hence digit, where to start in each
// branch, so it cant accurately calculate cache line fills required in each
// direction. The best it can do is an approximation based on the total
// population of the expanse (pop1 from Pjp) and the ordinal of the target
// Index (see SETOFFSET()) within the expanse.
//
// Compile with -DSMARTMETRICS to obtain global variables containing smart
// cache line metrics. Note: Dont turn this on simultaneously for this file
// and JudyCount.c because they export the same globals.
// ****************************************************************************
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
// These are imported from JudyCount.c:
//
// TBD: Should this be in common code? Exported from a header file?
#ifdef JUDY1
extern Word_t j__udy1JPPop1(const Pjp_t Pjp);
#define j__udyJPPop1 j__udy1JPPop1
#else
extern Word_t j__udyLJPPop1(const Pjp_t Pjp);
#define j__udyJPPop1 j__udyLJPPop1
#endif
// Avoid duplicate symbols since this file is multi-compiled:
#ifdef SMARTMETRICS
#ifdef JUDY1
Word_t jbb_upward = 0; // counts of directions taken:
Word_t jbb_downward = 0;
Word_t jbu_upward = 0;
Word_t jbu_downward = 0;
Word_t jlb_upward = 0;
Word_t jlb_downward = 0;
#else
extern Word_t jbb_upward;
extern Word_t jbb_downward;
extern Word_t jbu_upward;
extern Word_t jbu_downward;
extern Word_t jlb_upward;
extern Word_t jlb_downward;
#endif
#endif
// ****************************************************************************
// J U D Y 1 B Y C O U N T
// J U D Y L B Y C O U N T
//
// See the manual entry.
#ifdef JUDY1
FUNCTION int Judy1ByCount
#else
FUNCTION PPvoid_t JudyLByCount
#endif
(
Pcvoid_t PArray, // root pointer to first branch/leaf in SM.
Word_t Count, // ordinal of Index to find, 1..MAX.
Word_t * PIndex, // to return found Index.
PJError_t PJError // optional, for returning error info.
)
{
Word_t Count0; // Count, base-0, to match pop0.
Word_t state; // current state in SM.
Word_t pop1; // of current branch or leaf, or of expanse.
Word_t pop1lower; // pop1 of expanses (JPs) below that for Count.
Word_t digit; // current word in branch.
Word_t jpcount; // JPs in a BranchB subexpanse.
long jpnum; // JP number in a branch (base 0).
long subexp; // for stepping through layer 1 (subexpanses).
int offset; // index ordinal within a leaf, base 0.
Pjp_t Pjp; // current JP in branch.
Pjll_t Pjll; // current Judy linear leaf.
// CHECK FOR EMPTY ARRAY OR NULL PINDEX:
if (PArray == (Pvoid_t) NULL) JU_RET_NOTFOUND;
if (PIndex == (PWord_t) NULL)
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPINDEX);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
// Convert Count to Count0; assume special case of Count = 0 maps to ~0, as
// desired, to represent the last index in a full array:
//
// Note: Think of Count0 as a reliable "number of Indexes below the target."
Count0 = Count - 1;
assert((Count || Count0 == ~0)); // ensure CPU is sane about 0 - 1.
pop1lower = 0;
if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW
{
Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf.
if (Count0 > Pjlw[0]) JU_RET_NOTFOUND; // too high.
*PIndex = Pjlw[Count]; // Index, base 1.
JU_RET_FOUND_LEAFW(Pjlw, Pjlw[0] + 1, Count0);
}
else
{
Pjpm_t Pjpm = P_JPM(PArray);
if (Count0 > (Pjpm->jpm_Pop0)) JU_RET_NOTFOUND; // too high.
Pjp = &(Pjpm->jpm_JP);
pop1 = (Pjpm->jpm_Pop0) + 1;
// goto SMByCount;
}
// COMMON CODE:
//
// Prepare to handle a root-level or lower-level branch: Save the current
// state, obtain the total population for the branch in a state-dependent way,
// and then branch to common code for multiple cases.
//
// For root-level branches, the state is always cJU_ROOTSTATE, and the array
// population must already be set in pop1; it is not available in jp_DcdPopO.
//
// Note: The total population is only needed in cases where the common code
// "counts down" instead of up to minimize cache line fills. However, its
// available cheaply, and its better to do it with a constant shift (constant
// state value) instead of a variable shift later "when needed".
#define PREPB_ROOT(Next) \
state = cJU_ROOTSTATE; \
goto Next
// Use PREPB_DCD() to first copy the Dcd bytes to *PIndex if there are any
// (only if state < cJU_ROOTSTATE - 1):
#define PREPB_DCD(Pjp,cState,Next) \
JU_SETDCD(*PIndex, Pjp, cState); \
PREPB((Pjp), cState, Next)
#define PREPB(Pjp,cState,Next) \
state = (cState); \
pop1 = JU_JPBRANCH_POP0(Pjp, (cState)) + 1; \
goto Next
// Calculate whether the ordinal of an Index within a given expanse falls in
// the lower or upper half of the expanses population, taking care with
// unsigned math and boundary conditions:
//
// Note: Assume the ordinal falls within the expanses population, that is,
// 0 < (Count - Pop1lower) <= Pop1exp (assuming infinite math).
//
// Note: If the ordinal is the middle element, it doesnt matter whether
// LOWERHALF() is TRUE or FALSE.
#define LOWERHALF(Count0,Pop1lower,Pop1exp) \
(((Count0) - (Pop1lower)) < ((Pop1exp) / 2))
// Calculate the (signed) offset within a leaf to the desired ordinal (Count -
// Pop1lower; offset is one less), and optionally ensure its in range:
#define SETOFFSET(Offset,Count0,Pop1lower,Pjp) \
(Offset) = (Count0) - (Pop1lower); \
assert((Offset) >= 0); \
assert((Offset) <= JU_JPLEAF_POP0(Pjp))
// Variations for immediate indexes, with and without pop1-specific assertions:
#define SETOFFSET_IMM_CK(Offset,Count0,Pop1lower,cPop1) \
(Offset) = (Count0) - (Pop1lower); \
assert((Offset) >= 0); \
assert((Offset) < (cPop1))
#define SETOFFSET_IMM(Offset,Count0,Pop1lower) \
(Offset) = (Count0) - (Pop1lower)
// STATE MACHINE -- TRAVERSE TREE:
//
// In branches, look for the expanse (digit), if any, where the total pop1
// below or at that expanse would meet or exceed Count, meaning the Index must
// be in this expanse.
SMByCount: // return here for next branch/leaf.
switch (JU_JPTYPE(Pjp))
{
// ----------------------------------------------------------------------------
// LINEAR BRANCH; count populations in JPs in the JBL upwards until finding the
// expanse (digit) containing Count, and "recurse".
//
// Note: There are no null JPs in a JBL; watch out for pop1 == 0.
//
// Note: A JBL should always fit in one cache line => no need to count up
// versus down to save cache line fills.
//
// TBD: The previous is no longer true. Consider enhancing this code to count
// up/down, but it can wait for a later tuning phase. In the meantime, PREPB()
// sets pop1 for the whole array, but that value is not used here. 001215:
// Maybe its true again?
case cJU_JPBRANCH_L2: PREPB_DCD(Pjp, 2, BranchL);
#ifndef JU_64BIT
case cJU_JPBRANCH_L3: PREPB( Pjp, 3, BranchL);
#else
case cJU_JPBRANCH_L3: PREPB_DCD(Pjp, 3, BranchL);
case cJU_JPBRANCH_L4: PREPB_DCD(Pjp, 4, BranchL);
case cJU_JPBRANCH_L5: PREPB_DCD(Pjp, 5, BranchL);
case cJU_JPBRANCH_L6: PREPB_DCD(Pjp, 6, BranchL);
case cJU_JPBRANCH_L7: PREPB( Pjp, 7, BranchL);
#endif
case cJU_JPBRANCH_L: PREPB_ROOT( BranchL);
{
Pjbl_t Pjbl;
// Common code (state-independent) for all cases of linear branches:
BranchL:
Pjbl = P_JBL(Pjp->jp_Addr);
for (jpnum = 0; jpnum < (Pjbl->jbl_NumJPs); ++jpnum)
{
if ((pop1 = j__udyJPPop1((Pjbl->jbl_jp) + jpnum))
== cJU_ALLONES)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
assert(pop1 != 0);
// Warning: pop1lower and pop1 are unsigned, so do not subtract 1 and compare
// >=, but instead use the following expression:
if (pop1lower + pop1 > Count0) // Index is in this expanse.
{
JU_SETDIGIT(*PIndex, Pjbl->jbl_Expanse[jpnum], state);
Pjp = (Pjbl->jbl_jp) + jpnum;
goto SMByCount; // look under this expanse.
}
pop1lower += pop1; // add this JPs pop1.
}
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // should never get here.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
} // case cJU_JPBRANCH_L
// ----------------------------------------------------------------------------
// BITMAP BRANCH; count populations in JPs in the JBB upwards or downwards
// until finding the expanse (digit) containing Count, and "recurse".
//
// Note: There are no null JPs in a JBB; watch out for pop1 == 0.
case cJU_JPBRANCH_B2: PREPB_DCD(Pjp, 2, BranchB);
#ifndef JU_64BIT
case cJU_JPBRANCH_B3: PREPB( Pjp, 3, BranchB);
#else
case cJU_JPBRANCH_B3: PREPB_DCD(Pjp, 3, BranchB);
case cJU_JPBRANCH_B4: PREPB_DCD(Pjp, 4, BranchB);
case cJU_JPBRANCH_B5: PREPB_DCD(Pjp, 5, BranchB);
case cJU_JPBRANCH_B6: PREPB_DCD(Pjp, 6, BranchB);
case cJU_JPBRANCH_B7: PREPB( Pjp, 7, BranchB);
#endif
case cJU_JPBRANCH_B: PREPB_ROOT( BranchB);
{
Pjbb_t Pjbb;
// Common code (state-independent) for all cases of bitmap branches:
BranchB:
Pjbb = P_JBB(Pjp->jp_Addr);
// Shorthand for one subexpanse in a bitmap and for one JP in a bitmap branch:
//
// Note: BMPJP0 exists separately to support assertions.
#define BMPJP0(Subexp) (P_JP(JU_JBB_PJP(Pjbb, Subexp)))
#define BMPJP(Subexp,JPnum) (BMPJP0(Subexp) + (JPnum))
// Common code for descending through a JP:
//
// Determine the digit for the expanse and save it in *PIndex; then "recurse".
#define JBB_FOUNDEXPANSE \
{ \
JU_BITMAPDIGITB(digit, subexp, JU_JBB_BITMAP(Pjbb,subexp), jpnum); \
JU_SETDIGIT(*PIndex, digit, state); \
Pjp = BMPJP(subexp, jpnum); \
goto SMByCount; \
}
#ifndef NOSMARTJBB // enable to turn off smart code for comparison purposes.
// FIGURE OUT WHICH DIRECTION CAUSES FEWER CACHE LINE FILLS; adding the pop1s
// in JPs upwards, or subtracting the pop1s in JPs downwards:
//
// See header comments about limitations of this for Judy*ByCount().
#endif
// COUNT UPWARD, adding each "below" JPs pop1:
#ifndef NOSMARTJBB // enable to turn off smart code for comparison purposes.
if (LOWERHALF(Count0, pop1lower, pop1))
{
#endif
#ifdef SMARTMETRICS
++jbb_upward;
#endif
for (subexp = 0; subexp < cJU_NUMSUBEXPB; ++subexp)
{
if ((jpcount = j__udyCountBitsB(JU_JBB_BITMAP(Pjbb,subexp)))
&& (BMPJP0(subexp) == (Pjp_t) NULL))
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // null ptr.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
// Note: An empty subexpanse (jpcount == 0) is handled "for free":
for (jpnum = 0; jpnum < jpcount; ++jpnum)
{
if ((pop1 = j__udyJPPop1(BMPJP(subexp, jpnum)))
== cJU_ALLONES)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
assert(pop1 != 0);
// Warning: pop1lower and pop1 are unsigned, see earlier comment:
if (pop1lower + pop1 > Count0)
JBB_FOUNDEXPANSE; // Index is in this expanse.
pop1lower += pop1; // add this JPs pop1.
}
}
#ifndef NOSMARTJBB // enable to turn off smart code for comparison purposes.
}
// COUNT DOWNWARD, subtracting each "above" JPs pop1 from the whole expanses
// pop1:
else
{
#ifdef SMARTMETRICS
++jbb_downward;
#endif
pop1lower += pop1; // add whole branch to start.
for (subexp = cJU_NUMSUBEXPB - 1; subexp >= 0; --subexp)
{
if ((jpcount = j__udyCountBitsB(JU_JBB_BITMAP(Pjbb, subexp)))
&& (BMPJP0(subexp) == (Pjp_t) NULL))
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // null ptr.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
// Note: An empty subexpanse (jpcount == 0) is handled "for free":
for (jpnum = jpcount - 1; jpnum >= 0; --jpnum)
{
if ((pop1 = j__udyJPPop1(BMPJP(subexp, jpnum)))
== cJU_ALLONES)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
assert(pop1 != 0);
// Warning: pop1lower and pop1 are unsigned, see earlier comment:
pop1lower -= pop1;
// Beware unsigned math problems:
if ((pop1lower == 0) || (pop1lower - 1 < Count0))
JBB_FOUNDEXPANSE; // Index is in this expanse.
}
}
}
#endif // NOSMARTJBB
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // should never get here.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
} // case cJU_JPBRANCH_B
// ----------------------------------------------------------------------------
// UNCOMPRESSED BRANCH; count populations in JPs in the JBU upwards or
// downwards until finding the expanse (digit) containing Count, and "recurse".
case cJU_JPBRANCH_U2: PREPB_DCD(Pjp, 2, BranchU);
#ifndef JU_64BIT
case cJU_JPBRANCH_U3: PREPB( Pjp, 3, BranchU);
#else
case cJU_JPBRANCH_U3: PREPB_DCD(Pjp, 3, BranchU);
case cJU_JPBRANCH_U4: PREPB_DCD(Pjp, 4, BranchU);
case cJU_JPBRANCH_U5: PREPB_DCD(Pjp, 5, BranchU);
case cJU_JPBRANCH_U6: PREPB_DCD(Pjp, 6, BranchU);
case cJU_JPBRANCH_U7: PREPB( Pjp, 7, BranchU);
#endif
case cJU_JPBRANCH_U: PREPB_ROOT( BranchU);
{
Pjbu_t Pjbu;
// Common code (state-independent) for all cases of uncompressed branches:
BranchU:
Pjbu = P_JBU(Pjp->jp_Addr);
// Common code for descending through a JP:
//
// Save the digit for the expanse in *PIndex, then "recurse".
#define JBU_FOUNDEXPANSE \
{ \
JU_SETDIGIT(*PIndex, jpnum, state); \
Pjp = (Pjbu->jbu_jp) + jpnum; \
goto SMByCount; \
}
#ifndef NOSMARTJBU // enable to turn off smart code for comparison purposes.
// FIGURE OUT WHICH DIRECTION CAUSES FEWER CACHE LINE FILLS; adding the pop1s
// in JPs upwards, or subtracting the pop1s in JPs downwards:
//
// See header comments about limitations of this for Judy*ByCount().
#endif
// COUNT UPWARD, simply adding the pop1 of each JP:
#ifndef NOSMARTJBU // enable to turn off smart code for comparison purposes.
if (LOWERHALF(Count0, pop1lower, pop1))
{
#endif
#ifdef SMARTMETRICS
++jbu_upward;
#endif
for (jpnum = 0; jpnum < cJU_BRANCHUNUMJPS; ++jpnum)
{
// shortcut, save a function call:
if ((Pjbu->jbu_jp[jpnum].jp_Type) <= cJU_JPNULLMAX)
continue;
if ((pop1 = j__udyJPPop1((Pjbu->jbu_jp) + jpnum))
== cJU_ALLONES)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
assert(pop1 != 0);
// Warning: pop1lower and pop1 are unsigned, see earlier comment:
if (pop1lower + pop1 > Count0)
JBU_FOUNDEXPANSE; // Index is in this expanse.
pop1lower += pop1; // add this JPs pop1.
}
#ifndef NOSMARTJBU // enable to turn off smart code for comparison purposes.
}
// COUNT DOWNWARD, subtracting the pop1 of each JP above from the whole
// expanses pop1:
else
{
#ifdef SMARTMETRICS
++jbu_downward;
#endif
pop1lower += pop1; // add whole branch to start.
for (jpnum = cJU_BRANCHUNUMJPS - 1; jpnum >= 0; --jpnum)
{
// shortcut, save a function call:
if ((Pjbu->jbu_jp[jpnum].jp_Type) <= cJU_JPNULLMAX)
continue;
if ((pop1 = j__udyJPPop1(Pjbu->jbu_jp + jpnum))
== cJU_ALLONES)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
assert(pop1 != 0);
// Warning: pop1lower and pop1 are unsigned, see earlier comment:
pop1lower -= pop1;
// Beware unsigned math problems:
if ((pop1lower == 0) || (pop1lower - 1 < Count0))
JBU_FOUNDEXPANSE; // Index is in this expanse.
}
}
#endif // NOSMARTJBU
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // should never get here.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
} // case cJU_JPBRANCH_U
// ----------------------------------------------------------------------------
// LINEAR LEAF:
//
// Return the Index at the proper ordinal (see SETOFFSET()) in the leaf. First
// copy Dcd bytes, if there are any (only if state < cJU_ROOTSTATE - 1), to
// *PIndex.
//
// Note: The preceding branch traversal code MIGHT set pop1 for this expanse
// (linear leaf) as a side-effect, but dont depend on that (for JUDYL, which
// is the only cases that need it anyway).
#define PREPL_DCD(cState) \
JU_SETDCD(*PIndex, Pjp, cState); \
PREPL
#ifdef JUDY1
#define PREPL_SETPOP1 // not needed in any cases.
#else
#define PREPL_SETPOP1 pop1 = JU_JPLEAF_POP0(Pjp) + 1
#endif
#define PREPL \
Pjll = P_JLL(Pjp->jp_Addr); \
PREPL_SETPOP1; \
SETOFFSET(offset, Count0, pop1lower, Pjp)
#if (defined(JUDYL) || (! defined(JU_64BIT)))
case cJU_JPLEAF1:
PREPL_DCD(1);
JU_SETDIGIT1(*PIndex, ((uint8_t *) Pjll)[offset]);
JU_RET_FOUND_LEAF1(Pjll, pop1, offset);
#endif
case cJU_JPLEAF2:
PREPL_DCD(2);
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(2)))
| ((uint16_t *) Pjll)[offset];
JU_RET_FOUND_LEAF2(Pjll, pop1, offset);
#ifndef JU_64BIT
case cJU_JPLEAF3:
{
Word_t lsb;
PREPL;
JU_COPY3_PINDEX_TO_LONG(lsb, ((uint8_t *) Pjll) + (3 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(3))) | lsb;
JU_RET_FOUND_LEAF3(Pjll, pop1, offset);
}
#else
case cJU_JPLEAF3:
{
Word_t lsb;
PREPL_DCD(3);
JU_COPY3_PINDEX_TO_LONG(lsb, ((uint8_t *) Pjll) + (3 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(3))) | lsb;
JU_RET_FOUND_LEAF3(Pjll, pop1, offset);
}
case cJU_JPLEAF4:
PREPL_DCD(4);
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(4)))
| ((uint32_t *) Pjll)[offset];
JU_RET_FOUND_LEAF4(Pjll, pop1, offset);
case cJU_JPLEAF5:
{
Word_t lsb;
PREPL_DCD(5);
JU_COPY5_PINDEX_TO_LONG(lsb, ((uint8_t *) Pjll) + (5 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(5))) | lsb;
JU_RET_FOUND_LEAF5(Pjll, pop1, offset);
}
case cJU_JPLEAF6:
{
Word_t lsb;
PREPL_DCD(6);
JU_COPY6_PINDEX_TO_LONG(lsb, ((uint8_t *) Pjll) + (6 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(6))) | lsb;
JU_RET_FOUND_LEAF6(Pjll, pop1, offset);
}
case cJU_JPLEAF7:
{
Word_t lsb;
PREPL;
JU_COPY7_PINDEX_TO_LONG(lsb, ((uint8_t *) Pjll) + (7 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(7))) | lsb;
JU_RET_FOUND_LEAF7(Pjll, pop1, offset);
}
#endif
// ----------------------------------------------------------------------------
// BITMAP LEAF:
//
// Return the Index at the proper ordinal (see SETOFFSET()) in the leaf by
// counting bits. First copy Dcd bytes (always present since state 1 <
// cJU_ROOTSTATE) to *PIndex.
//
// Note: The preceding branch traversal code MIGHT set pop1 for this expanse
// (bitmap leaf) as a side-effect, but dont depend on that.
case cJU_JPLEAF_B1:
{
Pjlb_t Pjlb;
JU_SETDCD(*PIndex, Pjp, 1);
Pjlb = P_JLB(Pjp->jp_Addr);
pop1 = JU_JPLEAF_POP0(Pjp) + 1;
// COUNT UPWARD, adding the pop1 of each subexpanse:
//
// The entire bitmap should fit in one cache line, but still try to save some
// CPU time by counting the fewest possible number of subexpanses from the
// bitmap.
//
// See header comments about limitations of this for Judy*ByCount().
#ifndef NOSMARTJLB // enable to turn off smart code for comparison purposes.
if (LOWERHALF(Count0, pop1lower, pop1))
{
#endif
#ifdef SMARTMETRICS
++jlb_upward;
#endif
for (subexp = 0; subexp < cJU_NUMSUBEXPL; ++subexp)
{
pop1 = j__udyCountBitsL(JU_JLB_BITMAP(Pjlb, subexp));
// Warning: pop1lower and pop1 are unsigned, see earlier comment:
if (pop1lower + pop1 > Count0)
goto LeafB1; // Index is in this subexpanse.
pop1lower += pop1; // add this subexpanses pop1.
}
#ifndef NOSMARTJLB // enable to turn off smart code for comparison purposes.
}
// COUNT DOWNWARD, subtracting each "above" subexpanses pop1 from the whole
// expanses pop1:
else
{
#ifdef SMARTMETRICS
++jlb_downward;
#endif
pop1lower += pop1; // add whole leaf to start.
for (subexp = cJU_NUMSUBEXPL - 1; subexp >= 0; --subexp)
{
pop1lower -= j__udyCountBitsL(JU_JLB_BITMAP(Pjlb, subexp));
// Beware unsigned math problems:
if ((pop1lower == 0) || (pop1lower - 1 < Count0))
goto LeafB1; // Index is in this subexpanse.
}
}
#endif // NOSMARTJLB
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT); // should never get here.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
// RETURN INDEX FOUND:
//
// Come here with subexp set to the correct subexpanse, and pop1lower set to
// the sum for all lower expanses and subexpanses in the Judy tree. Calculate
// and save in *PIndex the digit corresponding to the ordinal in this
// subexpanse.
LeafB1:
SETOFFSET(offset, Count0, pop1lower, Pjp);
JU_BITMAPDIGITL(digit, subexp, JU_JLB_BITMAP(Pjlb, subexp), offset);
JU_SETDIGIT1(*PIndex, digit);
JU_RET_FOUND_LEAF_B1(Pjlb, subexp, offset);
// == return((PPvoid_t) (P_JV(JL_JLB_PVALUE(Pjlb, subexp)) + offset))
} // case cJU_JPLEAF_B1
#ifdef JUDY1
// ----------------------------------------------------------------------------
// FULL POPULATION:
//
// Copy Dcd bytes (always present since state 1 < cJU_ROOTSTATE) to *PIndex,
// then set the appropriate digit for the ordinal (see SETOFFSET()) in the leaf
// as the LSB in *PIndex.
case cJ1_JPFULLPOPU1:
JU_SETDCD(*PIndex, Pjp, 1);
SETOFFSET(offset, Count0, pop1lower, Pjp);
assert(offset >= 0);
assert(offset <= cJU_JPFULLPOPU1_POP0);
JU_SETDIGIT1(*PIndex, offset);
JU_RET_FOUND_FULLPOPU1;
#endif
// ----------------------------------------------------------------------------
// IMMEDIATE:
//
// Locate the Index with the proper ordinal (see SETOFFSET()) in the Immediate,
// depending on leaf Index Size and pop1. Note: There are no Dcd bytes in an
// Immediate JP, but in a cJU_JPIMMED_*_01 JP, the field holds the least bytes
// of the immediate Index.
#define SET_01(cState) JU_SETDIGITS(*PIndex, JU_JPDCDPOP0(Pjp), cState)
case cJU_JPIMMED_1_01: SET_01(1); goto Imm_01;
case cJU_JPIMMED_2_01: SET_01(2); goto Imm_01;
case cJU_JPIMMED_3_01: SET_01(3); goto Imm_01;
#ifdef JU_64BIT
case cJU_JPIMMED_4_01: SET_01(4); goto Imm_01;
case cJU_JPIMMED_5_01: SET_01(5); goto Imm_01;
case cJU_JPIMMED_6_01: SET_01(6); goto Imm_01;
case cJU_JPIMMED_7_01: SET_01(7); goto Imm_01;
#endif
Imm_01:
DBGCODE(SETOFFSET_IMM_CK(offset, Count0, pop1lower, 1);)
JU_RET_FOUND_IMM_01(Pjp);
// Shorthand for where to find start of Index bytes array:
#ifdef JUDY1
#define PJI (Pjp->jp_1Index)
#else
#define PJI (Pjp->jp_LIndex)
#endif
// Optional code to check the remaining ordinal (see SETOFFSET_IMM()) against
// the Index Size of the Immediate:
#ifndef DEBUG // simple placeholder:
#define IMM(cPop1,Next) \
goto Next
#else // extra pop1-specific checking:
#define IMM(cPop1,Next) \
SETOFFSET_IMM_CK(offset, Count0, pop1lower, cPop1); \
goto Next
#endif
case cJU_JPIMMED_1_02: IMM( 2, Imm1);
case cJU_JPIMMED_1_03: IMM( 3, Imm1);
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_1_04: IMM( 4, Imm1);
case cJU_JPIMMED_1_05: IMM( 5, Imm1);
case cJU_JPIMMED_1_06: IMM( 6, Imm1);
case cJU_JPIMMED_1_07: IMM( 7, Imm1);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_1_08: IMM( 8, Imm1);
case cJ1_JPIMMED_1_09: IMM( 9, Imm1);
case cJ1_JPIMMED_1_10: IMM(10, Imm1);
case cJ1_JPIMMED_1_11: IMM(11, Imm1);
case cJ1_JPIMMED_1_12: IMM(12, Imm1);
case cJ1_JPIMMED_1_13: IMM(13, Imm1);
case cJ1_JPIMMED_1_14: IMM(14, Imm1);
case cJ1_JPIMMED_1_15: IMM(15, Imm1);
#endif
Imm1: SETOFFSET_IMM(offset, Count0, pop1lower);
JU_SETDIGIT1(*PIndex, ((uint8_t *) PJI)[offset]);
JU_RET_FOUND_IMM(Pjp, offset);
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_2_02: IMM(2, Imm2);
case cJU_JPIMMED_2_03: IMM(3, Imm2);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_2_04: IMM(4, Imm2);
case cJ1_JPIMMED_2_05: IMM(5, Imm2);
case cJ1_JPIMMED_2_06: IMM(6, Imm2);
case cJ1_JPIMMED_2_07: IMM(7, Imm2);
#endif
#if (defined(JUDY1) || defined(JU_64BIT))
Imm2: SETOFFSET_IMM(offset, Count0, pop1lower);
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(2)))
| ((uint16_t *) PJI)[offset];
JU_RET_FOUND_IMM(Pjp, offset);
#endif
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_3_02: IMM(2, Imm3);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_3_03: IMM(3, Imm3);
case cJ1_JPIMMED_3_04: IMM(4, Imm3);
case cJ1_JPIMMED_3_05: IMM(5, Imm3);
#endif
#if (defined(JUDY1) || defined(JU_64BIT))
Imm3:
{
Word_t lsb;
SETOFFSET_IMM(offset, Count0, pop1lower);
JU_COPY3_PINDEX_TO_LONG(lsb, ((uint8_t *) PJI) + (3 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(3))) | lsb;
JU_RET_FOUND_IMM(Pjp, offset);
}
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_4_02: IMM(2, Imm4);
case cJ1_JPIMMED_4_03: IMM(3, Imm4);
Imm4: SETOFFSET_IMM(offset, Count0, pop1lower);
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(4)))
| ((uint32_t *) PJI)[offset];
JU_RET_FOUND_IMM(Pjp, offset);
case cJ1_JPIMMED_5_02: IMM(2, Imm5);
case cJ1_JPIMMED_5_03: IMM(3, Imm5);
Imm5:
{
Word_t lsb;
SETOFFSET_IMM(offset, Count0, pop1lower);
JU_COPY5_PINDEX_TO_LONG(lsb, ((uint8_t *) PJI) + (5 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(5))) | lsb;
JU_RET_FOUND_IMM(Pjp, offset);
}
case cJ1_JPIMMED_6_02: IMM(2, Imm6);
Imm6:
{
Word_t lsb;
SETOFFSET_IMM(offset, Count0, pop1lower);
JU_COPY6_PINDEX_TO_LONG(lsb, ((uint8_t *) PJI) + (6 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(6))) | lsb;
JU_RET_FOUND_IMM(Pjp, offset);
}
case cJ1_JPIMMED_7_02: IMM(2, Imm7);
Imm7:
{
Word_t lsb;
SETOFFSET_IMM(offset, Count0, pop1lower);
JU_COPY7_PINDEX_TO_LONG(lsb, ((uint8_t *) PJI) + (7 * offset));
*PIndex = (*PIndex & (~JU_LEASTBYTESMASK(7))) | lsb;
JU_RET_FOUND_IMM(Pjp, offset);
}
#endif // (JUDY1 && JU_64BIT)
// ----------------------------------------------------------------------------
// UNEXPECTED JP TYPES:
default: JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
} // SMByCount switch.
/*NOTREACHED*/
} // Judy1ByCount() / JudyLByCount()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,314 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
// Branch creation functions for Judy1 and JudyL.
// Compile with one of -DJUDY1 or -DJUDYL.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
// ****************************************************************************
// J U D Y C R E A T E B R A N C H L
//
// Build a BranchL from an array of JPs and associated 1 byte digits
// (expanses). Return with Pjp pointing to the BranchL. Caller must
// deallocate passed arrays, if necessary.
//
// We have no idea what kind of BranchL it is, so caller must set the jp_Type.
//
// Return -1 if error (details in Pjpm), otherwise return 1.
FUNCTION int j__udyCreateBranchL(
Pjp_t Pjp, // Build JPs from this place
Pjp_t PJPs, // Array of JPs to put into Bitmap branch
uint8_t Exp[], // Array of expanses to put into bitmap
Word_t ExpCnt, // Number of above JPs and Expanses
Pvoid_t Pjpm)
{
Pjbl_t PjblRaw; // pointer to linear branch.
Pjbl_t Pjbl;
assert(ExpCnt <= cJU_BRANCHLMAXJPS);
PjblRaw = j__udyAllocJBL(Pjpm);
if (PjblRaw == (Pjbl_t) NULL) return(-1);
Pjbl = P_JBL(PjblRaw);
// Build a Linear Branch
Pjbl->jbl_NumJPs = ExpCnt;
// Copy from the Linear branch from splayed leaves
JU_COPYMEM(Pjbl->jbl_Expanse, Exp, ExpCnt);
JU_COPYMEM(Pjbl->jbl_jp, PJPs, ExpCnt);
// Pass back new pointer to the Linear branch in JP
Pjp->jp_Addr = (Word_t) PjblRaw;
return(1);
} // j__udyCreateBranchL()
// ****************************************************************************
// J U D Y C R E A T E B R A N C H B
//
// Build a BranchB from an array of JPs and associated 1 byte digits
// (expanses). Return with Pjp pointing to the BranchB. Caller must
// deallocate passed arrays, if necessary.
//
// We have no idea what kind of BranchB it is, so caller must set the jp_Type.
//
// Return -1 if error (details in Pjpm), otherwise return 1.
FUNCTION int j__udyCreateBranchB(
Pjp_t Pjp, // Build JPs from this place
Pjp_t PJPs, // Array of JPs to put into Bitmap branch
uint8_t Exp[], // Array of expanses to put into bitmap
Word_t ExpCnt, // Number of above JPs and Expanses
Pvoid_t Pjpm)
{
Pjbb_t PjbbRaw; // pointer to bitmap branch.
Pjbb_t Pjbb;
Word_t ii, jj; // Temps
uint8_t CurrSubExp; // Current sub expanse for BM
// This assertion says the number of populated subexpanses is not too large.
// This function is only called when a BranchL overflows to a BranchB or when a
// cascade occurs, meaning a leaf overflows. Either way ExpCnt cant be very
// large, in fact a lot smaller than cJU_BRANCHBMAXJPS. (Otherwise a BranchU
// would be used.) Popping this assertion means something (unspecified) has
// gone very wrong, or else Judys design criteria have changed, although in
// fact there should be no HARM in creating a BranchB with higher actual
// fanout.
assert(ExpCnt <= cJU_BRANCHBMAXJPS);
// Get memory for a Bitmap branch
PjbbRaw = j__udyAllocJBB(Pjpm);
if (PjbbRaw == (Pjbb_t) NULL) return(-1);
Pjbb = P_JBB(PjbbRaw);
// Get 1st "sub" expanse (0..7) of bitmap branch
CurrSubExp = Exp[0] / cJU_BITSPERSUBEXPB;
// Index thru all 1 byte sized expanses:
for (jj = ii = 0; ii <= ExpCnt; ii++)
{
Word_t SubExp; // Cannot be a uint8_t
// Make sure we cover the last one
if (ii == ExpCnt)
{
SubExp = cJU_ALLONES; // Force last one
}
else
{
// Calculate the "sub" expanse of the byte expanse
SubExp = Exp[ii] / cJU_BITSPERSUBEXPB; // Bits 5..7.
// Set the bit that represents the expanse in Exp[]
JU_JBB_BITMAP(Pjbb, SubExp) |= JU_BITPOSMASKB(Exp[ii]);
}
// Check if a new "sub" expanse range needed
if (SubExp != CurrSubExp)
{
// Get number of JPs in this sub expanse
Word_t NumJP = ii - jj;
Pjp_t PjpRaw;
Pjp_t Pjp;
PjpRaw = j__udyAllocJBBJP(NumJP, Pjpm);
Pjp = P_JP(PjpRaw);
if (PjpRaw == (Pjp_t) NULL) // out of memory.
{
// Free any previous allocations:
while(CurrSubExp--)
{
NumJP = j__udyCountBitsB(JU_JBB_BITMAP(Pjbb,
CurrSubExp));
if (NumJP)
{
j__udyFreeJBBJP(JU_JBB_PJP(Pjbb,
CurrSubExp), NumJP, Pjpm);
}
}
j__udyFreeJBB(PjbbRaw, Pjpm);
return(-1);
}
// Place the array of JPs in bitmap branch:
JU_JBB_PJP(Pjbb, CurrSubExp) = PjpRaw;
// Copy the JPs to new leaf:
JU_COPYMEM(Pjp, PJPs + jj, NumJP);
// On to the next bitmap branch "sub" expanse:
jj = ii;
CurrSubExp = SubExp;
}
} // for each 1-byte expanse
// Pass back some of the JP to the new Bitmap branch:
Pjp->jp_Addr = (Word_t) PjbbRaw;
return(1);
} // j__udyCreateBranchB()
// ****************************************************************************
// J U D Y C R E A T E B R A N C H U
//
// Build a BranchU from a BranchB. Return with Pjp pointing to the BranchU.
// Free the BranchB and its JP subarrays.
//
// Return -1 if error (details in Pjpm), otherwise return 1.
FUNCTION int j__udyCreateBranchU(
Pjp_t Pjp,
Pvoid_t Pjpm)
{
jp_t JPNull;
Pjbu_t PjbuRaw;
Pjbu_t Pjbu;
Pjbb_t PjbbRaw;
Pjbb_t Pjbb;
Word_t ii, jj;
BITMAPB_t BitMap;
Pjp_t PDstJP;
#ifdef JU_STAGED_EXP
jbu_t BranchU; // Staged uncompressed branch
#else
// Allocate memory for a BranchU:
PjbuRaw = j__udyAllocJBU(Pjpm);
if (PjbuRaw == (Pjbu_t) NULL) return(-1);
Pjbu = P_JBU(PjbuRaw);
#endif
JU_JPSETADT(&JPNull, 0, 0, JU_JPTYPE(Pjp) - cJU_JPBRANCH_B2 + cJU_JPNULL1);
// Get the pointer to the BranchB:
PjbbRaw = (Pjbb_t) (Pjp->jp_Addr);
Pjbb = P_JBB(PjbbRaw);
// Set the pointer to the Uncompressed branch
#ifdef JU_STAGED_EXP
PDstJP = BranchU.jbu_jp;
#else
PDstJP = Pjbu->jbu_jp;
#endif
for (ii = 0; ii < cJU_NUMSUBEXPB; ii++)
{
Pjp_t PjpA;
Pjp_t PjpB;
PjpB = PjpA = P_JP(JU_JBB_PJP(Pjbb, ii));
// Get the bitmap for this subexpanse
BitMap = JU_JBB_BITMAP(Pjbb, ii);
// NULL empty subexpanses
if (BitMap == 0)
{
// But, fill with NULLs
for (jj = 0; jj < cJU_BITSPERSUBEXPB; jj++)
{
PDstJP[jj] = JPNull;
}
PDstJP += cJU_BITSPERSUBEXPB;
continue;
}
// Check if Uncompressed subexpanse
if (BitMap == cJU_FULLBITMAPB)
{
// Copy subexpanse to the Uncompressed branch intact
JU_COPYMEM(PDstJP, PjpA, cJU_BITSPERSUBEXPB);
// Bump to next subexpanse
PDstJP += cJU_BITSPERSUBEXPB;
// Set length of subexpanse
jj = cJU_BITSPERSUBEXPB;
}
else
{
for (jj = 0; jj < cJU_BITSPERSUBEXPB; jj++)
{
// Copy JP or NULLJP depending on bit
if (BitMap & 1) { *PDstJP = *PjpA++; }
else { *PDstJP = JPNull; }
PDstJP++; // advance to next JP
BitMap >>= 1;
}
jj = PjpA - PjpB;
}
// Free the subexpanse:
j__udyFreeJBBJP(JU_JBB_PJP(Pjbb, ii), jj, Pjpm);
} // for each JP in BranchU
#ifdef JU_STAGED_EXP
// Allocate memory for a BranchU:
PjbuRaw = j__udyAllocJBU(Pjpm);
if (PjbuRaw == (Pjbu_t) NULL) return(-1);
Pjbu = P_JBU(PjbuRaw);
// Copy staged branch to newly allocated branch:
//
// TBD: I think this code is broken.
*Pjbu = BranchU;
#endif // JU_STAGED_EXP
// Finally free the BranchB and put the BranchU in its place:
j__udyFreeJBB(PjbbRaw, Pjpm);
Pjp->jp_Addr = (Word_t) PjbuRaw;
Pjp->jp_Type += cJU_JPBRANCH_U - cJU_JPBRANCH_B;
return(1);
} // j__udyCreateBranchU()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,213 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Judy*First[Empty]() and Judy*Last[Empty]() routines for Judy1 and JudyL.
// Compile with one of -DJUDY1 or -DJUDYL.
//
// These are inclusive versions of Judy*Next[Empty]() and Judy*Prev[Empty]().
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
// ****************************************************************************
// J U D Y 1 F I R S T
// J U D Y L F I R S T
//
// See the manual entry for details.
#ifdef JUDY1
FUNCTION int Judy1First
#else
FUNCTION PPvoid_t JudyLFirst
#endif
(
Pcvoid_t PArray, // Judy array to search.
Word_t * PIndex, // starting point and result.
PJError_t PJError // optional, for returning error info.
)
{
if (PIndex == (PWord_t) NULL) // caller error:
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPINDEX);
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
#ifdef JUDY1
switch (Judy1Test(PArray, *PIndex, PJError))
{
case 1: return(1); // found *PIndex itself.
case 0: return(Judy1Next(PArray, PIndex, PJError));
default: return(JERRI);
}
#else
{
PPvoid_t PValue;
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == PPJERR)
return(PPJERR);
if (PValue != (PPvoid_t) NULL) return(PValue); // found *PIndex.
return(JudyLNext(PArray, PIndex, PJError));
}
#endif
} // Judy1First() / JudyLFirst()
// ****************************************************************************
// J U D Y 1 L A S T
// J U D Y L L A S T
//
// See the manual entry for details.
#ifdef JUDY1
FUNCTION int Judy1Last(
#else
FUNCTION PPvoid_t JudyLLast(
#endif
Pcvoid_t PArray, // Judy array to search.
Word_t * PIndex, // starting point and result.
PJError_t PJError) // optional, for returning error info.
{
if (PIndex == (PWord_t) NULL)
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPINDEX); // caller error.
JUDY1CODE(return(JERRI );)
JUDYLCODE(return(PPJERR);)
}
#ifdef JUDY1
switch (Judy1Test(PArray, *PIndex, PJError))
{
case 1: return(1); // found *PIndex itself.
case 0: return(Judy1Prev(PArray, PIndex, PJError));
default: return(JERRI);
}
#else
{
PPvoid_t PValue;
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == PPJERR)
return(PPJERR);
if (PValue != (PPvoid_t) NULL) return(PValue); // found *PIndex.
return(JudyLPrev(PArray, PIndex, PJError));
}
#endif
} // Judy1Last() / JudyLLast()
// ****************************************************************************
// J U D Y 1 F I R S T E M P T Y
// J U D Y L F I R S T E M P T Y
//
// See the manual entry for details.
#ifdef JUDY1
FUNCTION int Judy1FirstEmpty(
#else
FUNCTION int JudyLFirstEmpty(
#endif
Pcvoid_t PArray, // Judy array to search.
Word_t * PIndex, // starting point and result.
PJError_t PJError) // optional, for returning error info.
{
if (PIndex == (PWord_t) NULL) // caller error:
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPINDEX);
return(JERRI);
}
#ifdef JUDY1
switch (Judy1Test(PArray, *PIndex, PJError))
{
case 0: return(1); // found *PIndex itself.
case 1: return(Judy1NextEmpty(PArray, PIndex, PJError));
default: return(JERRI);
}
#else
{
PPvoid_t PValue;
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == PPJERR)
return(JERRI);
if (PValue == (PPvoid_t) NULL) return(1); // found *PIndex.
return(JudyLNextEmpty(PArray, PIndex, PJError));
}
#endif
} // Judy1FirstEmpty() / JudyLFirstEmpty()
// ****************************************************************************
// J U D Y 1 L A S T E M P T Y
// J U D Y L L A S T E M P T Y
//
// See the manual entry for details.
#ifdef JUDY1
FUNCTION int Judy1LastEmpty(
#else
FUNCTION int JudyLLastEmpty(
#endif
Pcvoid_t PArray, // Judy array to search.
Word_t * PIndex, // starting point and result.
PJError_t PJError) // optional, for returning error info.
{
if (PIndex == (PWord_t) NULL)
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPINDEX); // caller error.
return(JERRI);
}
#ifdef JUDY1
switch (Judy1Test(PArray, *PIndex, PJError))
{
case 0: return(1); // found *PIndex itself.
case 1: return(Judy1PrevEmpty(PArray, PIndex, PJError));
default: return(JERRI);
}
#else
{
PPvoid_t PValue;
if ((PValue = JudyLGet(PArray, *PIndex, PJError)) == PPJERR)
return(JERRI);
if (PValue == (PPvoid_t) NULL) return(1); // found *PIndex.
return(JudyLPrevEmpty(PArray, PIndex, PJError));
}
#endif
} // Judy1LastEmpty() / JudyLLastEmpty()

View File

@ -0,0 +1,363 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Judy1FreeArray() and JudyLFreeArray() functions for Judy1 and JudyL.
// Compile with one of -DJUDY1 or -DJUDYL.
// Return the number of bytes freed from the array.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
DBGCODE(extern void JudyCheckPop(Pvoid_t PArray);)
// ****************************************************************************
// J U D Y 1 F R E E A R R A Y
// J U D Y L F R E E A R R A Y
//
// See the Judy*(3C) manual entry for details.
//
// This code is written recursively, at least at first, because thats much
// simpler. Hope its fast enough.
#ifdef JUDY1
FUNCTION Word_t Judy1FreeArray
#else
FUNCTION Word_t JudyLFreeArray
#endif
(
PPvoid_t PPArray, // array to free.
PJError_t PJError // optional, for returning error info.
)
{
jpm_t jpm; // local to accumulate free statistics.
// CHECK FOR NULL POINTER (error by caller):
if (PPArray == (PPvoid_t) NULL)
{
JU_SET_ERRNO(PJError, JU_ERRNO_NULLPPARRAY);
return(JERR);
}
DBGCODE(JudyCheckPop(*PPArray);)
// Zero jpm.jpm_Pop0 (meaning the array will be empty in a moment) for accurate
// logging in TRACEMI2.
jpm.jpm_Pop0 = 0; // see above.
jpm.jpm_TotalMemWords = 0; // initialize memory freed.
// Empty array:
if (P_JLW(*PPArray) == (Pjlw_t) NULL) return(0);
// PROCESS TOP LEVEL "JRP" BRANCHES AND LEAF:
if (JU_LEAFW_POP0(*PPArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW
{
Pjlw_t Pjlw = P_JLW(*PPArray); // first word of leaf.
j__udyFreeJLW(Pjlw, Pjlw[0] + 1, &jpm);
*PPArray = (Pvoid_t) NULL; // make an empty array.
return (-(jpm.jpm_TotalMemWords * cJU_BYTESPERWORD)); // see above.
}
else
// Rootstate leaves: just free the leaf:
// Common code for returning the amount of memory freed.
//
// Note: In a an ordinary LEAFW, pop0 = *PPArray[0].
//
// Accumulate (negative) words freed, while freeing objects.
// Return the positive bytes freed.
{
Pjpm_t Pjpm = P_JPM(*PPArray);
Word_t TotalMem = Pjpm->jpm_TotalMemWords;
j__udyFreeSM(&(Pjpm->jpm_JP), &jpm); // recurse through tree.
j__udyFreeJPM(Pjpm, &jpm);
// Verify the array was not corrupt. This means that amount of memory freed
// (which is negative) is equal to the initial amount:
if (TotalMem + jpm.jpm_TotalMemWords)
{
JU_SET_ERRNO(PJError, JU_ERRNO_CORRUPT);
return(JERR);
}
*PPArray = (Pvoid_t) NULL; // make an empty array.
return (TotalMem * cJU_BYTESPERWORD);
}
} // Judy1FreeArray() / JudyLFreeArray()
// ****************************************************************************
// __ J U D Y F R E E S M
//
// Given a pointer to a JP, recursively visit and free (depth first) all nodes
// in a Judy array BELOW the JP, but not the JP itself. Accumulate in *Pjpm
// the total words freed (as a negative value). "SM" = State Machine.
//
// Note: Corruption is not detected at this level because during a FreeArray,
// if the code hasnt already core dumped, its better to remain silent, even
// if some memory has not been freed, than to bother the caller about the
// corruption. TBD: Is this true? If not, must list all legitimate JPNULL
// and JPIMMED above first, and revert to returning bool_t (see 4.34).
FUNCTION void j__udyFreeSM(
Pjp_t Pjp, // top of Judy (top-state).
Pjpm_t Pjpm) // to return words freed.
{
Word_t Pop1;
switch (JU_JPTYPE(Pjp))
{
#ifdef JUDY1
// FULL EXPANSE -- nothing to free for this jp_Type.
case cJ1_JPFULLPOPU1:
break;
#endif
// JUDY BRANCH -- free the sub-tree depth first:
// LINEAR BRANCH -- visit each JP in the JBLs list, then free the JBL:
//
// Note: There are no null JPs in a JBL.
case cJU_JPBRANCH_L:
case cJU_JPBRANCH_L2:
case cJU_JPBRANCH_L3:
#ifdef JU_64BIT
case cJU_JPBRANCH_L4:
case cJU_JPBRANCH_L5:
case cJU_JPBRANCH_L6:
case cJU_JPBRANCH_L7:
#endif // JU_64BIT
{
Pjbl_t Pjbl = P_JBL(Pjp->jp_Addr);
Word_t offset;
for (offset = 0; offset < Pjbl->jbl_NumJPs; ++offset)
j__udyFreeSM((Pjbl->jbl_jp) + offset, Pjpm);
j__udyFreeJBL((Pjbl_t) (Pjp->jp_Addr), Pjpm);
break;
}
// BITMAP BRANCH -- visit each JP in the JBBs list based on the bitmap, also
//
// Note: There are no null JPs in a JBB.
case cJU_JPBRANCH_B:
case cJU_JPBRANCH_B2:
case cJU_JPBRANCH_B3:
#ifdef JU_64BIT
case cJU_JPBRANCH_B4:
case cJU_JPBRANCH_B5:
case cJU_JPBRANCH_B6:
case cJU_JPBRANCH_B7:
#endif // JU_64BIT
{
Word_t subexp;
Word_t offset;
Word_t jpcount;
Pjbb_t Pjbb = P_JBB(Pjp->jp_Addr);
for (subexp = 0; subexp < cJU_NUMSUBEXPB; ++subexp)
{
jpcount = j__udyCountBitsB(JU_JBB_BITMAP(Pjbb, subexp));
if (jpcount)
{
for (offset = 0; offset < jpcount; ++offset)
{
j__udyFreeSM(P_JP(JU_JBB_PJP(Pjbb, subexp)) + offset,
Pjpm);
}
j__udyFreeJBBJP(JU_JBB_PJP(Pjbb, subexp), jpcount, Pjpm);
}
}
j__udyFreeJBB((Pjbb_t) (Pjp->jp_Addr), Pjpm);
break;
}
// UNCOMPRESSED BRANCH -- visit each JP in the JBU array, then free the JBU
// itself:
//
// Note: Null JPs are handled during recursion at a lower state.
case cJU_JPBRANCH_U:
case cJU_JPBRANCH_U2:
case cJU_JPBRANCH_U3:
#ifdef JU_64BIT
case cJU_JPBRANCH_U4:
case cJU_JPBRANCH_U5:
case cJU_JPBRANCH_U6:
case cJU_JPBRANCH_U7:
#endif // JU_64BIT
{
Word_t offset;
Pjbu_t Pjbu = P_JBU(Pjp->jp_Addr);
for (offset = 0; offset < cJU_BRANCHUNUMJPS; ++offset)
j__udyFreeSM((Pjbu->jbu_jp) + offset, Pjpm);
j__udyFreeJBU((Pjbu_t) (Pjp->jp_Addr), Pjpm);
break;
}
// -- Cases below here terminate and do not recurse. --
// LINEAR LEAF -- just free the leaf; size is computed from jp_Type:
//
// Note: cJU_JPLEAF1 is a special case, see discussion in ../Judy1/Judy1.h
#if (defined(JUDYL) || (! defined(JU_64BIT)))
case cJU_JPLEAF1:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL1((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
#endif
case cJU_JPLEAF2:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL2((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
case cJU_JPLEAF3:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL3((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
#ifdef JU_64BIT
case cJU_JPLEAF4:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL4((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
case cJU_JPLEAF5:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL5((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
case cJU_JPLEAF6:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL6((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
case cJU_JPLEAF7:
Pop1 = JU_JPLEAF_POP0(Pjp) + 1;
j__udyFreeJLL7((Pjll_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
#endif // JU_64BIT
// BITMAP LEAF -- free sub-expanse arrays of JPs, then free the JBB.
case cJU_JPLEAF_B1:
{
#ifdef JUDYL
Word_t subexp;
Word_t jpcount;
Pjlb_t Pjlb = P_JLB(Pjp->jp_Addr);
// Free the value areas in the bitmap leaf:
for (subexp = 0; subexp < cJU_NUMSUBEXPL; ++subexp)
{
jpcount = j__udyCountBitsL(JU_JLB_BITMAP(Pjlb, subexp));
if (jpcount)
j__udyLFreeJV(JL_JLB_PVALUE(Pjlb, subexp), jpcount, Pjpm);
}
#endif // JUDYL
j__udyFreeJLB1((Pjlb_t) (Pjp->jp_Addr), Pjpm);
break;
} // case cJU_JPLEAF_B1
#ifdef JUDYL
// IMMED*:
//
// For JUDYL, all non JPIMMED_*_01s have a LeafV which must be freed:
case cJU_JPIMMED_1_02:
case cJU_JPIMMED_1_03:
#ifdef JU_64BIT
case cJU_JPIMMED_1_04:
case cJU_JPIMMED_1_05:
case cJU_JPIMMED_1_06:
case cJU_JPIMMED_1_07:
#endif
Pop1 = JU_JPTYPE(Pjp) - cJU_JPIMMED_1_02 + 2;
j__udyLFreeJV((Pjv_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
#ifdef JU_64BIT
case cJU_JPIMMED_2_02:
case cJU_JPIMMED_2_03:
Pop1 = JU_JPTYPE(Pjp) - cJU_JPIMMED_2_02 + 2;
j__udyLFreeJV((Pjv_t) (Pjp->jp_Addr), Pop1, Pjpm);
break;
case cJU_JPIMMED_3_02:
j__udyLFreeJV((Pjv_t) (Pjp->jp_Addr), 2, Pjpm);
break;
#endif // JU_64BIT
#endif // JUDYL
// OTHER JPNULL, JPIMMED, OR UNEXPECTED TYPE -- nothing to free for this type:
//
// Note: Lump together no-op and invalid JP types; see function header
// comments.
default: break;
} // switch (JU_JPTYPE(Pjp))
} // j__udyFreeSM()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
// BranchL insertion functions for Judy1 and JudyL.
// Compile with one of -DJUDY1 or -DJUDYL.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
extern int j__udyCreateBranchL(Pjp_t, Pjp_t, uint8_t *, Word_t, Pvoid_t);
// ****************************************************************************
// __ J U D Y I N S E R T B R A N C H
//
// Insert 2-element BranchL in between Pjp and Pjp->jp_Addr.
//
// Return -1 if out of memory, otherwise return 1.
FUNCTION int j__udyInsertBranch(
Pjp_t Pjp, // JP containing narrow pointer.
Word_t Index, // outlier to Pjp.
Word_t BranchLevel, // of what JP points to, mapped from JP type.
Pjpm_t Pjpm) // for global accounting.
{
jp_t JP2 [2];
jp_t JP;
Pjp_t PjpNull;
Word_t XorExp;
Word_t Inew, Iold;
Word_t DCDMask; // initially for original BranchLevel.
int Ret;
uint8_t Exp2[2];
uint8_t DecodeByteN, DecodeByteO;
// Get the current mask for the DCD digits:
DCDMask = cJU_DCDMASK(BranchLevel);
// Obtain Dcd bits that differ between Index and JP, shifted so the
// digit for BranchLevel is the LSB:
XorExp = ((Index ^ JU_JPDCDPOP0(Pjp)) & (cJU_ALLONES >> cJU_BITSPERBYTE))
>> (BranchLevel * cJU_BITSPERBYTE);
assert(XorExp); // Index must be an outlier.
// Count levels between object under narrow pointer and the level at which
// the outlier diverges from it, which is always at least initial
// BranchLevel + 1, to end up with the level (JP type) at which to insert
// the new intervening BranchL:
do { ++BranchLevel; } while ((XorExp >>= cJU_BITSPERBYTE));
assert((BranchLevel > 1) && (BranchLevel < cJU_ROOTSTATE));
// Get the MSB (highest digit) that differs between the old expanse and
// the new Index to insert:
DecodeByteO = JU_DIGITATSTATE(JU_JPDCDPOP0(Pjp), BranchLevel);
DecodeByteN = JU_DIGITATSTATE(Index, BranchLevel);
assert(DecodeByteO != DecodeByteN);
// Determine sorted order for old expanse and new Index digits:
if (DecodeByteN > DecodeByteO) { Iold = 0; Inew = 1; }
else { Iold = 1; Inew = 0; }
// Copy old JP into staging area for new Branch
JP2 [Iold] = *Pjp;
Exp2[Iold] = DecodeByteO;
Exp2[Inew] = DecodeByteN;
// Create a 2 Expanse Linear branch
//
// Note: Pjp->jp_Addr is set by j__udyCreateBranchL()
Ret = j__udyCreateBranchL(Pjp, JP2, Exp2, 2, Pjpm);
if (Ret == -1) return(-1);
// Get Pjp to the NULL of where to do insert
PjpNull = ((P_JBL(Pjp->jp_Addr))->jbl_jp) + Inew;
// Convert to a cJU_JPIMMED_*_01 at the correct level:
// Build JP and set type below to: cJU_JPIMMED_X_01
JU_JPSETADT(PjpNull, 0, Index, cJU_JPIMMED_1_01 - 2 + BranchLevel);
// Return pointer to Value area in cJU_JPIMMED_X_01
JUDYLCODE(Pjpm->jpm_PValue = (Pjv_t) PjpNull;)
// The old JP now points to a BranchL that is at higher level. Therefore
// it contains excess DCD bits (in the least significant position) that
// must be removed (zeroed); that is, they become part of the Pop0
// subfield. Note that the remaining (lower) bytes in the Pop0 field do
// not change.
//
// Take from the old DCDMask, which went "down" to a lower BranchLevel,
// and zero any high bits that are still in the mask at the new, higher
// BranchLevel; then use this mask to zero the bits in jp_DcdPopO:
// Set old JP to a BranchL at correct level
Pjp->jp_Type = cJU_JPBRANCH_L2 - 2 + BranchLevel;
DCDMask ^= cJU_DCDMASK(BranchLevel);
DCDMask = ~DCDMask & JU_JPDCDPOP0(Pjp);
JP = *Pjp;
JU_JPSETADT(Pjp, JP.jp_Addr, DCDMask, JP.jp_Type);
return(1);
} // j__udyInsertBranch()

View File

@ -0,0 +1,87 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
// ************************************************************************ //
// JUDY - Memory Allocater //
// -by- //
// Douglas L. Baskins //
// Hewlett Packard //
// Fort Collins, Co //
// (970) 229-2027 //
// //
// ************************************************************************ //
// JUDY INCLUDE FILES
#include "Judy.h"
// ****************************************************************************
// J U D Y M A L L O C
//
// Allocate RAM. This is the single location in Judy code that calls
// malloc(3C). Note: JPM accounting occurs at a higher level.
Word_t JudyMalloc(
Word_t Words)
{
Word_t Addr;
Addr = (Word_t) malloc(Words * sizeof(Word_t));
return(Addr);
} // JudyMalloc()
// ****************************************************************************
// J U D Y F R E E
void JudyFree(
void * PWord,
Word_t Words)
{
(void) Words;
free(PWord);
} // JudyFree()
// ****************************************************************************
// J U D Y M A L L O C
//
// Higher-level "wrapper" for allocating objects that need not be in RAM,
// although at this time they are in fact only in RAM. Later we hope that some
// entire subtrees (at a JPM or branch) can be "virtual", so their allocations
// and frees should go through this level.
Word_t JudyMallocVirtual(
Word_t Words)
{
return(JudyMalloc(Words));
} // JudyMallocVirtual()
// ****************************************************************************
// J U D Y F R E E
void JudyFreeVirtual(
void * PWord,
Word_t Words)
{
JudyFree(PWord, Words);
} // JudyFreeVirtual()

View File

@ -0,0 +1,782 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Judy malloc/free interface functions for Judy1 and JudyL.
//
// Compile with one of -DJUDY1 or -DJUDYL.
//
// Compile with -DTRACEMI (Malloc Interface) to turn on tracing of malloc/free
// calls at the interface level. (See also TRACEMF in lower-level code.)
// Use -DTRACEMI2 for a terser format suitable for trace analysis.
//
// There can be malloc namespace bits in the LSBs of "raw" addresses from most,
// but not all, of the j__udy*Alloc*() functions; see also JudyPrivate.h. To
// test the Judy code, compile this file with -DMALLOCBITS and use debug flavor
// only (for assertions). This test ensures that (a) all callers properly mask
// the namespace bits out before dereferencing a pointer (or else a core dump
// occurs), and (b) all callers send "raw" (unmasked) addresses to
// j__udy*Free*() calls.
//
// Note: Currently -DDEBUG turns on MALLOCBITS automatically.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
// Set "hidden" global j__uMaxWords to the maximum number of words to allocate
// to any one array (large enough to have a JPM, otherwise j__uMaxWords is
// ignored), to trigger a fake malloc error when the number is exceeded. Note,
// this code is always executed, not #ifdefd, because its virtually free.
//
// Note: To keep the MALLOC macro faster and simpler, set j__uMaxWords to
// MAXINT, not zero, by default.
Word_t j__uMaxWords = ~0UL;
// This macro hides the faking of a malloc failure:
//
// Note: To keep this fast, just compare WordsPrev to j__uMaxWords without the
// complexity of first adding WordsNow, meaning the trigger point is not
// exactly where you might assume, but it shouldnt matter.
#define MALLOC(MallocFunc,WordsPrev,WordsNow) \
(((WordsPrev) > j__uMaxWords) ? 0UL : MallocFunc(WordsNow))
// Clear words starting at address:
//
// Note: Only use this for objects that care; in other cases, it doesnt
// matter if the objects memory is pre-zeroed.
#define ZEROWORDS(Addr,Words) \
{ \
Word_t Words__ = (Words); \
PWord_t Addr__ = (PWord_t) (Addr); \
while (Words__--) *Addr__++ = 0UL; \
}
#ifdef TRACEMI
// TRACING SUPPORT:
//
// Note: For TRACEMI, use a format for address printing compatible with other
// tracing facilities; in particular, %x not %lx, to truncate the "noisy" high
// part on 64-bit systems.
//
// TBD: The trace macros need fixing for alternate address types.
//
// Note: TRACEMI2 supports trace analysis no matter the underlying malloc/free
// engine used.
#include <stdio.h>
static Word_t j__udyMemSequence = 0L; // event sequence number.
#define TRACE_ALLOC5(a,b,c,d,e) (void) printf(a, (b), c, d)
#define TRACE_FREE5( a,b,c,d,e) (void) printf(a, (b), c, d)
#define TRACE_ALLOC6(a,b,c,d,e,f) (void) printf(a, (b), c, d, e)
#define TRACE_FREE6( a,b,c,d,e,f) (void) printf(a, (b), c, d, e)
#else
#ifdef TRACEMI2
#include <stdio.h>
#define b_pw cJU_BYTESPERWORD
#define TRACE_ALLOC5(a,b,c,d,e) \
(void) printf("a %lx %lx %lx\n", (b), (d) * b_pw, e)
#define TRACE_FREE5( a,b,c,d,e) \
(void) printf("f %lx %lx %lx\n", (b), (d) * b_pw, e)
#define TRACE_ALLOC6(a,b,c,d,e,f) \
(void) printf("a %lx %lx %lx\n", (b), (e) * b_pw, f)
#define TRACE_FREE6( a,b,c,d,e,f) \
(void) printf("f %lx %lx %lx\n", (b), (e) * b_pw, f)
static Word_t j__udyMemSequence = 0L; // event sequence number.
#else
#define TRACE_ALLOC5(a,b,c,d,e) // null.
#define TRACE_FREE5( a,b,c,d,e) // null.
#define TRACE_ALLOC6(a,b,c,d,e,f) // null.
#define TRACE_FREE6( a,b,c,d,e,f) // null.
#endif // ! TRACEMI2
#endif // ! TRACEMI
// MALLOC NAMESPACE SUPPORT:
#if (defined(DEBUG) && (! defined(MALLOCBITS))) // for now, DEBUG => MALLOCBITS:
#define MALLOCBITS 1
#endif
#ifdef MALLOCBITS
#define MALLOCBITS_VALUE 0x3 // bit pattern to use.
#define MALLOCBITS_MASK 0x7 // note: matches mask__ in JudyPrivate.h.
#define MALLOCBITS_SET( Type,Addr) \
((Addr) = (Type) ((Word_t) (Addr) | MALLOCBITS_VALUE))
#define MALLOCBITS_TEST(Type,Addr) \
assert((((Word_t) (Addr)) & MALLOCBITS_MASK) == MALLOCBITS_VALUE); \
((Addr) = (Type) ((Word_t) (Addr) & ~MALLOCBITS_VALUE))
#else
#define MALLOCBITS_SET( Type,Addr) // null.
#define MALLOCBITS_TEST(Type,Addr) // null.
#endif
// SAVE ERROR INFORMATION IN A Pjpm:
//
// "Small" (invalid) Addr values are used to distinguish overrun and no-mem
// errors. (TBD, non-zero invalid values are no longer returned from
// lower-level functions, that is, JU_ERRNO_OVERRUN is no longer detected.)
#define J__UDYSETALLOCERROR(Addr) \
{ \
JU_ERRID(Pjpm) = __LINE__; \
if ((Word_t) (Addr) > 0) JU_ERRNO(Pjpm) = JU_ERRNO_OVERRUN; \
else JU_ERRNO(Pjpm) = JU_ERRNO_NOMEM; \
return(0); \
}
// ****************************************************************************
// ALLOCATION FUNCTIONS:
//
// To help the compiler catch coding errors, each function returns a specific
// object type.
//
// Note: Only j__udyAllocJPM() and j__udyAllocJLW() return multiple values <=
// sizeof(Word_t) to indicate the type of memory allocation failure. Other
// allocation functions convert this failure to a JU_ERRNO.
// Note: Unlike other j__udyAlloc*() functions, Pjpms are returned non-raw,
// that is, without malloc namespace or root pointer type bits:
FUNCTION Pjpm_t j__udyAllocJPM(void)
{
Word_t Words = sizeof(jpm_t) / cJU_BYTESPERWORD;
Pjpm_t Pjpm = (Pjpm_t) MALLOC(JudyMalloc, Words, Words);
assert((Words * cJU_BYTESPERWORD) == sizeof(jpm_t));
if ((Word_t) Pjpm > sizeof(Word_t))
{
ZEROWORDS(Pjpm, Words);
Pjpm->jpm_TotalMemWords = Words;
}
TRACE_ALLOC5("0x%x %8lu = j__udyAllocJPM(), Words = %lu\n",
Pjpm, j__udyMemSequence++, Words, cJU_LEAFW_MAXPOP1 + 1);
// MALLOCBITS_SET(Pjpm_t, Pjpm); // see above.
return(Pjpm);
} // j__udyAllocJPM()
FUNCTION Pjbl_t j__udyAllocJBL(Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbl_t) / cJU_BYTESPERWORD;
Pjbl_t PjblRaw = (Pjbl_t) MALLOC(JudyMallocVirtual,
Pjpm->jpm_TotalMemWords, Words);
assert((Words * cJU_BYTESPERWORD) == sizeof(jbl_t));
if ((Word_t) PjblRaw > sizeof(Word_t))
{
ZEROWORDS(P_JBL(PjblRaw), Words);
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjblRaw); }
TRACE_ALLOC5("0x%x %8lu = j__udyAllocJBL(), Words = %lu\n", PjblRaw,
j__udyMemSequence++, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjbl_t, PjblRaw);
return(PjblRaw);
} // j__udyAllocJBL()
FUNCTION Pjbb_t j__udyAllocJBB(Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbb_t) / cJU_BYTESPERWORD;
Pjbb_t PjbbRaw = (Pjbb_t) MALLOC(JudyMallocVirtual,
Pjpm->jpm_TotalMemWords, Words);
assert((Words * cJU_BYTESPERWORD) == sizeof(jbb_t));
if ((Word_t) PjbbRaw > sizeof(Word_t))
{
ZEROWORDS(P_JBB(PjbbRaw), Words);
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjbbRaw); }
TRACE_ALLOC5("0x%x %8lu = j__udyAllocJBB(), Words = %lu\n", PjbbRaw,
j__udyMemSequence++, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjbb_t, PjbbRaw);
return(PjbbRaw);
} // j__udyAllocJBB()
FUNCTION Pjp_t j__udyAllocJBBJP(Word_t NumJPs, Pjpm_t Pjpm)
{
Word_t Words = JU_BRANCHJP_NUMJPSTOWORDS(NumJPs);
Pjp_t PjpRaw;
PjpRaw = (Pjp_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjpRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjpRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJBBJP(%lu), Words = %lu\n", PjpRaw,
j__udyMemSequence++, NumJPs, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjp_t, PjpRaw);
return(PjpRaw);
} // j__udyAllocJBBJP()
FUNCTION Pjbu_t j__udyAllocJBU(Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbu_t) / cJU_BYTESPERWORD;
Pjbu_t PjbuRaw = (Pjbu_t) MALLOC(JudyMallocVirtual,
Pjpm->jpm_TotalMemWords, Words);
assert((Words * cJU_BYTESPERWORD) == sizeof(jbu_t));
if ((Word_t) PjbuRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjbuRaw); }
TRACE_ALLOC5("0x%x %8lu = j__udyAllocJBU(), Words = %lu\n", PjbuRaw,
j__udyMemSequence++, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjbu_t, PjbuRaw);
return(PjbuRaw);
} // j__udyAllocJBU()
#if (defined(JUDYL) || (! defined(JU_64BIT)))
FUNCTION Pjll_t j__udyAllocJLL1(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF1POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL1(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL1()
#endif // (JUDYL || (! JU_64BIT))
FUNCTION Pjll_t j__udyAllocJLL2(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF2POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL2(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL2()
FUNCTION Pjll_t j__udyAllocJLL3(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF3POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL3(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL3()
#ifdef JU_64BIT
FUNCTION Pjll_t j__udyAllocJLL4(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF4POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL4(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL4()
FUNCTION Pjll_t j__udyAllocJLL5(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF5POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL5(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL5()
FUNCTION Pjll_t j__udyAllocJLL6(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF6POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL6(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL6()
FUNCTION Pjll_t j__udyAllocJLL7(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF7POPTOWORDS(Pop1);
Pjll_t PjllRaw;
PjllRaw = (Pjll_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjllRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjllRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLL7(%lu), Words = %lu\n", PjllRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjll_t, PjllRaw);
return(PjllRaw);
} // j__udyAllocJLL7()
#endif // JU_64BIT
// Note: Root-level leaf addresses are always whole words (Pjlw_t), and unlike
// other j__udyAlloc*() functions, they are returned non-raw, that is, without
// malloc namespace or root pointer type bits (the latter are added later by
// the caller):
FUNCTION Pjlw_t j__udyAllocJLW(Word_t Pop1)
{
Word_t Words = JU_LEAFWPOPTOWORDS(Pop1);
Pjlw_t Pjlw = (Pjlw_t) MALLOC(JudyMalloc, Words, Words);
TRACE_ALLOC6("0x%x %8lu = j__udyAllocJLW(%lu), Words = %lu\n", Pjlw,
j__udyMemSequence++, Pop1, Words, Pop1);
// MALLOCBITS_SET(Pjlw_t, Pjlw); // see above.
return(Pjlw);
} // j__udyAllocJLW()
FUNCTION Pjlb_t j__udyAllocJLB1(Pjpm_t Pjpm)
{
Word_t Words = sizeof(jlb_t) / cJU_BYTESPERWORD;
Pjlb_t PjlbRaw;
PjlbRaw = (Pjlb_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
assert((Words * cJU_BYTESPERWORD) == sizeof(jlb_t));
if ((Word_t) PjlbRaw > sizeof(Word_t))
{
ZEROWORDS(P_JLB(PjlbRaw), Words);
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjlbRaw); }
TRACE_ALLOC5("0x%x %8lu = j__udyAllocJLB1(), Words = %lu\n", PjlbRaw,
j__udyMemSequence++, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjlb_t, PjlbRaw);
return(PjlbRaw);
} // j__udyAllocJLB1()
#ifdef JUDYL
FUNCTION Pjv_t j__udyLAllocJV(Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JL_LEAFVPOPTOWORDS(Pop1);
Pjv_t PjvRaw;
PjvRaw = (Pjv_t) MALLOC(JudyMalloc, Pjpm->jpm_TotalMemWords, Words);
if ((Word_t) PjvRaw > sizeof(Word_t))
{
Pjpm->jpm_TotalMemWords += Words;
}
else { J__UDYSETALLOCERROR(PjvRaw); }
TRACE_ALLOC6("0x%x %8lu = j__udyLAllocJV(%lu), Words = %lu\n", PjvRaw,
j__udyMemSequence++, Pop1, Words, (Pjpm->jpm_Pop0) + 2);
MALLOCBITS_SET(Pjv_t, PjvRaw);
return(PjvRaw);
} // j__udyLAllocJV()
#endif // JUDYL
// ****************************************************************************
// FREE FUNCTIONS:
//
// To help the compiler catch coding errors, each function takes a specific
// object type to free.
// Note: j__udyFreeJPM() receives a root pointer with NO root pointer type
// bits present, that is, they must be stripped by the caller using P_JPM():
FUNCTION void j__udyFreeJPM(Pjpm_t PjpmFree, Pjpm_t PjpmStats)
{
Word_t Words = sizeof(jpm_t) / cJU_BYTESPERWORD;
// MALLOCBITS_TEST(Pjpm_t, PjpmFree); // see above.
JudyFree((Pvoid_t) PjpmFree, Words);
if (PjpmStats != (Pjpm_t) NULL) PjpmStats->jpm_TotalMemWords -= Words;
// Note: Log PjpmFree->jpm_Pop0, similar to other j__udyFree*() functions, not
// an assumed value of cJU_LEAFW_MAXPOP1, for when the caller is
// Judy*FreeArray(), jpm_Pop0 is set to 0, and the population after the free
// really will be 0, not cJU_LEAFW_MAXPOP1.
TRACE_FREE6("0x%x %8lu = j__udyFreeJPM(%lu), Words = %lu\n", PjpmFree,
j__udyMemSequence++, Words, Words, PjpmFree->jpm_Pop0);
} // j__udyFreeJPM()
FUNCTION void j__udyFreeJBL(Pjbl_t Pjbl, Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbl_t) / cJU_BYTESPERWORD;
MALLOCBITS_TEST(Pjbl_t, Pjbl);
JudyFreeVirtual((Pvoid_t) Pjbl, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE5("0x%x %8lu = j__udyFreeJBL(), Words = %lu\n", Pjbl,
j__udyMemSequence++, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJBL()
FUNCTION void j__udyFreeJBB(Pjbb_t Pjbb, Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbb_t) / cJU_BYTESPERWORD;
MALLOCBITS_TEST(Pjbb_t, Pjbb);
JudyFreeVirtual((Pvoid_t) Pjbb, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE5("0x%x %8lu = j__udyFreeJBB(), Words = %lu\n", Pjbb,
j__udyMemSequence++, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJBB()
FUNCTION void j__udyFreeJBBJP(Pjp_t Pjp, Word_t NumJPs, Pjpm_t Pjpm)
{
Word_t Words = JU_BRANCHJP_NUMJPSTOWORDS(NumJPs);
MALLOCBITS_TEST(Pjp_t, Pjp);
JudyFree((Pvoid_t) Pjp, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJBBJP(%lu), Words = %lu\n", Pjp,
j__udyMemSequence++, NumJPs, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJBBJP()
FUNCTION void j__udyFreeJBU(Pjbu_t Pjbu, Pjpm_t Pjpm)
{
Word_t Words = sizeof(jbu_t) / cJU_BYTESPERWORD;
MALLOCBITS_TEST(Pjbu_t, Pjbu);
JudyFreeVirtual((Pvoid_t) Pjbu, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE5("0x%x %8lu = j__udyFreeJBU(), Words = %lu\n", Pjbu,
j__udyMemSequence++, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJBU()
#if (defined(JUDYL) || (! defined(JU_64BIT)))
FUNCTION void j__udyFreeJLL1(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF1POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL1(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL1()
#endif // (JUDYL || (! JU_64BIT))
FUNCTION void j__udyFreeJLL2(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF2POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL2(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL2()
FUNCTION void j__udyFreeJLL3(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF3POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL3(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL3()
#ifdef JU_64BIT
FUNCTION void j__udyFreeJLL4(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF4POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL4(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL4()
FUNCTION void j__udyFreeJLL5(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF5POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL5(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL5()
FUNCTION void j__udyFreeJLL6(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF6POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL6(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL6()
FUNCTION void j__udyFreeJLL7(Pjll_t Pjll, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAF7POPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjll_t, Pjll);
JudyFree((Pvoid_t) Pjll, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLL7(%lu), Words = %lu\n", Pjll,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLL7()
#endif // JU_64BIT
// Note: j__udyFreeJLW() receives a root pointer with NO root pointer type
// bits present, that is, they are stripped by P_JLW():
FUNCTION void j__udyFreeJLW(Pjlw_t Pjlw, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JU_LEAFWPOPTOWORDS(Pop1);
// MALLOCBITS_TEST(Pjlw_t, Pjlw); // see above.
JudyFree((Pvoid_t) Pjlw, Words);
if (Pjpm) Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyFreeJLW(%lu), Words = %lu\n", Pjlw,
j__udyMemSequence++, Pop1, Words, Pop1 - 1);
} // j__udyFreeJLW()
FUNCTION void j__udyFreeJLB1(Pjlb_t Pjlb, Pjpm_t Pjpm)
{
Word_t Words = sizeof(jlb_t) / cJU_BYTESPERWORD;
MALLOCBITS_TEST(Pjlb_t, Pjlb);
JudyFree((Pvoid_t) Pjlb, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE5("0x%x %8lu = j__udyFreeJLB1(), Words = %lu\n", Pjlb,
j__udyMemSequence++, Words, Pjpm->jpm_Pop0);
} // j__udyFreeJLB1()
#ifdef JUDYL
FUNCTION void j__udyLFreeJV(Pjv_t Pjv, Word_t Pop1, Pjpm_t Pjpm)
{
Word_t Words = JL_LEAFVPOPTOWORDS(Pop1);
MALLOCBITS_TEST(Pjv_t, Pjv);
JudyFree((Pvoid_t) Pjv, Words);
Pjpm->jpm_TotalMemWords -= Words;
TRACE_FREE6("0x%x %8lu = j__udyLFreeJV(%lu), Words = %lu\n", Pjv,
j__udyMemSequence++, Pop1, Words, Pjpm->jpm_Pop0);
} // j__udyLFreeJV()
#endif // JUDYL

View File

@ -0,0 +1,259 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Return number of bytes of memory used to support a Judy1/L array.
// Compile with one of -DJUDY1 or -DJUDYL.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
FUNCTION static Word_t j__udyGetMemActive(Pjp_t);
// ****************************************************************************
// J U D Y 1 M E M A C T I V E
// J U D Y L M E M A C T I V E
#ifdef JUDY1
FUNCTION Word_t Judy1MemActive
#else
FUNCTION Word_t JudyLMemActive
#endif
(
Pcvoid_t PArray // from which to retrieve.
)
{
if (PArray == (Pcvoid_t)NULL) return(0);
if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW
{
Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf.
Word_t Words = Pjlw[0] + 1; // population.
#ifdef JUDY1
return((Words + 1) * sizeof(Word_t));
#else
return(((Words * 2) + 1) * sizeof(Word_t));
#endif
}
else
{
Pjpm_t Pjpm = P_JPM(PArray);
return(j__udyGetMemActive(&Pjpm->jpm_JP) + sizeof(jpm_t));
}
} // JudyMemActive()
// ****************************************************************************
// __ J U D Y G E T M E M A C T I V E
FUNCTION static Word_t j__udyGetMemActive(
Pjp_t Pjp) // top of subtree.
{
Word_t offset; // in a branch.
Word_t Bytes = 0; // actual bytes used at this level.
Word_t IdxSz; // bytes per index in leaves
switch (JU_JPTYPE(Pjp))
{
case cJU_JPBRANCH_L2:
case cJU_JPBRANCH_L3:
#ifdef JU_64BIT
case cJU_JPBRANCH_L4:
case cJU_JPBRANCH_L5:
case cJU_JPBRANCH_L6:
case cJU_JPBRANCH_L7:
#endif
case cJU_JPBRANCH_L:
{
Pjbl_t Pjbl = P_JBL(Pjp->jp_Addr);
for (offset = 0; offset < (Pjbl->jbl_NumJPs); ++offset)
Bytes += j__udyGetMemActive((Pjbl->jbl_jp) + offset);
return(Bytes + sizeof(jbl_t));
}
case cJU_JPBRANCH_B2:
case cJU_JPBRANCH_B3:
#ifdef JU_64BIT
case cJU_JPBRANCH_B4:
case cJU_JPBRANCH_B5:
case cJU_JPBRANCH_B6:
case cJU_JPBRANCH_B7:
#endif
case cJU_JPBRANCH_B:
{
Word_t subexp;
Word_t jpcount;
Pjbb_t Pjbb = P_JBB(Pjp->jp_Addr);
for (subexp = 0; subexp < cJU_NUMSUBEXPB; ++subexp)
{
jpcount = j__udyCountBitsB(JU_JBB_BITMAP(Pjbb, subexp));
Bytes += jpcount * sizeof(jp_t);
for (offset = 0; offset < jpcount; ++offset)
{
Bytes += j__udyGetMemActive(P_JP(JU_JBB_PJP(Pjbb, subexp))
+ offset);
}
}
return(Bytes + sizeof(jbb_t));
}
case cJU_JPBRANCH_U2:
case cJU_JPBRANCH_U3:
#ifdef JU_64BIT
case cJU_JPBRANCH_U4:
case cJU_JPBRANCH_U5:
case cJU_JPBRANCH_U6:
case cJU_JPBRANCH_U7:
#endif
case cJU_JPBRANCH_U:
{
Pjbu_t Pjbu = P_JBU(Pjp->jp_Addr);
for (offset = 0; offset < cJU_BRANCHUNUMJPS; ++offset)
{
if (((Pjbu->jbu_jp[offset].jp_Type) >= cJU_JPNULL1)
&& ((Pjbu->jbu_jp[offset].jp_Type) <= cJU_JPNULLMAX))
{
continue; // skip null JP to save time.
}
Bytes += j__udyGetMemActive(Pjbu->jbu_jp + offset);
}
return(Bytes + sizeof(jbu_t));
}
// -- Cases below here terminate and do not recurse. --
#if (defined(JUDYL) || (! defined(JU_64BIT)))
case cJU_JPLEAF1: IdxSz = 1; goto LeafWords;
#endif
case cJU_JPLEAF2: IdxSz = 2; goto LeafWords;
case cJU_JPLEAF3: IdxSz = 3; goto LeafWords;
#ifdef JU_64BIT
case cJU_JPLEAF4: IdxSz = 4; goto LeafWords;
case cJU_JPLEAF5: IdxSz = 5; goto LeafWords;
case cJU_JPLEAF6: IdxSz = 6; goto LeafWords;
case cJU_JPLEAF7: IdxSz = 7; goto LeafWords;
#endif
LeafWords:
#ifdef JUDY1
return(IdxSz * (JU_JPLEAF_POP0(Pjp) + 1));
#else
return((IdxSz + sizeof(Word_t))
* (JU_JPLEAF_POP0(Pjp) + 1));
#endif
case cJU_JPLEAF_B1:
{
#ifdef JUDY1
return(sizeof(jlb_t));
#else
Bytes = (JU_JPLEAF_POP0(Pjp) + 1) * sizeof(Word_t);
return(Bytes + sizeof(jlb_t));
#endif
}
JUDY1CODE(case cJ1_JPFULLPOPU1: return(0);)
#ifdef JUDY1
#define J__Mpy 0
#else
#define J__Mpy sizeof(Word_t)
#endif
case cJU_JPIMMED_1_01: return(0);
case cJU_JPIMMED_2_01: return(0);
case cJU_JPIMMED_3_01: return(0);
#ifdef JU_64BIT
case cJU_JPIMMED_4_01: return(0);
case cJU_JPIMMED_5_01: return(0);
case cJU_JPIMMED_6_01: return(0);
case cJU_JPIMMED_7_01: return(0);
#endif
case cJU_JPIMMED_1_02: return(J__Mpy * 2);
case cJU_JPIMMED_1_03: return(J__Mpy * 3);
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_1_04: return(J__Mpy * 4);
case cJU_JPIMMED_1_05: return(J__Mpy * 5);
case cJU_JPIMMED_1_06: return(J__Mpy * 6);
case cJU_JPIMMED_1_07: return(J__Mpy * 7);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_1_08: return(0);
case cJ1_JPIMMED_1_09: return(0);
case cJ1_JPIMMED_1_10: return(0);
case cJ1_JPIMMED_1_11: return(0);
case cJ1_JPIMMED_1_12: return(0);
case cJ1_JPIMMED_1_13: return(0);
case cJ1_JPIMMED_1_14: return(0);
case cJ1_JPIMMED_1_15: return(0);
#endif
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_2_02: return(J__Mpy * 2);
case cJU_JPIMMED_2_03: return(J__Mpy * 3);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_2_04: return(0);
case cJ1_JPIMMED_2_05: return(0);
case cJ1_JPIMMED_2_06: return(0);
case cJ1_JPIMMED_2_07: return(0);
#endif
#if (defined(JUDY1) || defined(JU_64BIT))
case cJU_JPIMMED_3_02: return(J__Mpy * 2);
#endif
#if (defined(JUDY1) && defined(JU_64BIT))
case cJ1_JPIMMED_3_03: return(0);
case cJ1_JPIMMED_3_04: return(0);
case cJ1_JPIMMED_3_05: return(0);
case cJ1_JPIMMED_4_02: return(0);
case cJ1_JPIMMED_4_03: return(0);
case cJ1_JPIMMED_5_02: return(0);
case cJ1_JPIMMED_5_03: return(0);
case cJ1_JPIMMED_6_02: return(0);
case cJ1_JPIMMED_7_02: return(0);
#endif
} // switch (JU_JPTYPE(Pjp))
return(0); // to make some compilers happy.
} // j__udyGetMemActive()

View File

@ -0,0 +1,61 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Return number of bytes of memory used to support a Judy1/L array.
// Compile with one of -DJUDY1 or -DJUDYL.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
#include "JudyPrivate1L.h"
#ifdef JUDY1
FUNCTION Word_t Judy1MemUsed
#else // JUDYL
FUNCTION Word_t JudyLMemUsed
#endif
(
Pcvoid_t PArray // from which to retrieve.
)
{
Word_t Words = 0;
if (PArray == (Pcvoid_t) NULL) return(0);
if (JU_LEAFW_POP0(PArray) < cJU_LEAFW_MAXPOP1) // must be a LEAFW
{
Pjlw_t Pjlw = P_JLW(PArray); // first word of leaf.
Words = JU_LEAFWPOPTOWORDS(Pjlw[0] + 1); // based on pop1.
}
else
{
Pjpm_t Pjpm = P_JPM(PArray);
Words = Pjpm->jpm_TotalMemWords;
}
return(Words * sizeof(Word_t)); // convert to bytes.
} // Judy1MemUsed() / JudyLMemUsed()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,401 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// JudyPrintJP() debugging/tracing function for Judy1 or JudyL code.
// The caller should #include this file, with its static function (replicated
// in each compilation unit), in another *.c file, and compile with one of
// -DJUDY1 or -DJUDYL.
//
// The caller can set j__udyIndex and/or j__udyPopulation non-zero to have
// those values reported, and also to control trace-enabling (see below).
//
// Tracing is disabled by default unless one or both of two env parameters is
// set (regardless of value). If either value is set but null or evaluates to
// zero, tracing is immediately enabled. To disable tracing until a particular
// j__udy*Index value is seen, set STARTINDEX=<hex-index> in the env. To
// disable it until a particular j__udy*Population value is seen, set
// STARTPOP=<decimal-population> in the env. Once either condition is met,
// tracing "latches on".
//
// Example:
//
// STARTPOP=0 // immediate tracing.
// STARTINDEX=f35430a8 // not until one of these is met.
// STARTPOP=1000000
//
// Note: Trace-enabling does nothing unless the caller sets the appropriate
// global variable non-zero.
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#include <stdlib.h> // for getenv() and strtoul().
// GLOBALS FROM CALLER:
//
// Note: This storage is declared once in each compilation unit that includes
// this file, but the linker should merge all cases into single locations, but
// ONLY if these are uninitialized, so ASSUME they are 0 to start.
Word_t j__udyIndex; // current Index itself, optional from caller.
Word_t j__udyPopulation; // Indexes in array, optional from caller.
// Other globals:
static Word_t startindex = 0; // see usage below.
static Word_t startpop = 0;
static bool_t enabled = FALSE; // by default, unless env params set.
// Shorthand for announcing JP addresses, Desc (in context), and JP types:
//
// Note: Width is at least one blank wider than any JP type name, and the line
// is left unfinished.
//
// Note: Use a format for address printing compatible with other tracing
// facilities; in particular, %x not %lx, to truncate the "noisy" high part on
// 64-bit systems.
#define JPTYPE(Type) printf("0x%lx %s %-17s", (Word_t) Pjp, Desc, Type)
// Shorthands for announcing expanse populations from DcdPopO fields:
#define POP0 printf("Pop1 = 0 ")
#define POP1 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xff) + 1))
#define POP2 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffff) + 1))
#define POP3 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffffff) + 1))
#ifdef JU_64BIT
#define POP4 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffffffff) + 1))
#define POP5 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffffffffff) + 1))
#define POP6 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffffffffffff) + 1))
#define POP7 printf("Pop1 = %ld ", (Word_t) ((JU_JPDCDPOP0(Pjp) & 0xffffffffffffff) + 1))
#endif
// Shorthands for announcing populations of Immeds:
//
// Note: Line up the small populations that often occur together, but beyond
// that, dont worry about it because populations can get arbitrarily large.
#define POP_1 printf("Pop1 = 1 ")
#define POP_2 printf("Pop1 = 2 ")
#define POP_3 printf("Pop1 = 3 ")
#define POP_4 printf("Pop1 = 4 ")
#define POP_5 printf("Pop1 = 5 ")
#define POP_6 printf("Pop1 = 6 ")
#define POP_7 printf("Pop1 = 7 ")
#define POP_8 printf("Pop1 = 8 ")
#define POP_9 printf("Pop1 = 8 ")
#define POP_10 printf("Pop1 = 10 ")
#define POP_11 printf("Pop1 = 11 ")
#define POP_12 printf("Pop1 = 12 ")
#define POP_13 printf("Pop1 = 13 ")
#define POP_14 printf("Pop1 = 14 ")
#define POP_15 printf("Pop1 = 15 ")
// Shorthands for other announcements:
#define NUMJPSL printf("NumJPs = %d ", P_JBL(Pjp->jp_Addr)->jbl_NumJPs)
#define OOPS printf("-- OOPS, invalid Type\n"); exit(1)
// This is harder to compute:
#define NUMJPSB \
{ \
Pjbb_t Pjbb = P_JBB(Pjp->jp_Addr); \
Word_t subexp; \
int numJPs = 0; \
\
for (subexp = 0; subexp < cJU_NUMSUBEXPB; ++subexp) \
numJPs += j__udyCountBitsB(JU_JBB_BITMAP(Pjbb, subexp));\
\
printf("NumJPs = %d ", numJPs); \
}
// ****************************************************************************
// J U D Y P R I N T J P
//
// Dump information about a JP, at least its address, type, population, and
// number of JPs, as appropriate. Error out upon any unexpected JP type.
//
// TBD: Dump more detailed information about the JP?
FUNCTION static void JudyPrintJP(
Pjp_t Pjp, // JP to describe.
char * Desc, // brief description of caller, such as "i".
int Line) // callers source line number.
{
static bool_t checked = FALSE; // set upon first entry and check for params.
char * value; // for getenv().
// CHECK FOR EXTERNAL ENABLING:
//
// If a parameter is set, report the value, even if it is null or otherwise
// evaluates to zero, in which case enable tracing immediately; otherwise wait
// for the value to be hit.
#define GETENV(Name,Value,Base) \
if ((value = getenv (Name)) != (char *) NULL) \
{ \
(Value) = strtoul (value, (char **) NULL, Base); \
enabled |= ((Value) == 0); /* see above */ \
\
(void) printf ("JudyPrintJP(\"%s\"): $%s = %lu\n", \
Desc, Name, Value); \
}
if (! checked) // only check once.
{
checked = TRUE;
GETENV ("STARTINDEX", startindex, 16);
GETENV ("STARTPOP", startpop, 10);
(void) printf ("JudyPrintJP(\"%s\"): Tracing present %s\n", Desc,
enabled ? "and immediately enabled" :
(startindex || startpop) ?
"but disabled until start condition met" :
"but not enabled by env parameter");
}
if (! enabled) // check repeatedly until latched enabled:
{
if (startindex && (startindex == j__udyIndex))
{
(void) printf ("=== TRACING ENABLED (\"%s\"), "
"startindex = 0x%lx\n", Desc, startindex);
enabled = TRUE;
}
else if (startpop && (startpop == j__udyPopulation))
{
(void) printf ("=== TRACING ENABLED (\"%s\"), "
"startpop = %lu\n", Desc, startpop);
enabled = TRUE;
}
else
{
return; // print nothing this time.
}
}
// SWITCH ON JP TYPE:
switch (JU_JPTYPE(Pjp))
{
// Note: The following COULD be merged more tightly between Judy1 and JudyL,
// but we decided that the output should say cJ1*/cJL*, not cJU*, to be more
// specific.
#ifdef JUDY1
case cJ1_JPNULL1: JPTYPE("cJ1_JPNULL1"); POP0; break;
case cJ1_JPNULL2: JPTYPE("cJ1_JPNULL2"); POP0; break;
case cJ1_JPNULL3: JPTYPE("cJ1_JPNULL3"); POP0; break;
#ifdef JU_64BIT
case cJ1_JPNULL4: JPTYPE("cJ1_JPNULL4"); POP0; break;
case cJ1_JPNULL5: JPTYPE("cJ1_JPNULL5"); POP0; break;
case cJ1_JPNULL6: JPTYPE("cJ1_JPNULL6"); POP0; break;
case cJ1_JPNULL7: JPTYPE("cJ1_JPNULL7"); POP0; break;
#endif
case cJ1_JPBRANCH_L2: JPTYPE("cJ1_JPBRANCH_L2"); POP2;NUMJPSL;break;
case cJ1_JPBRANCH_L3: JPTYPE("cJ1_JPBRANCH_L3"); POP3;NUMJPSL;break;
#ifdef JU_64BIT
case cJ1_JPBRANCH_L4: JPTYPE("cJ1_JPBRANCH_L4"); POP4;NUMJPSL;break;
case cJ1_JPBRANCH_L5: JPTYPE("cJ1_JPBRANCH_L5"); POP5;NUMJPSL;break;
case cJ1_JPBRANCH_L6: JPTYPE("cJ1_JPBRANCH_L6"); POP6;NUMJPSL;break;
case cJ1_JPBRANCH_L7: JPTYPE("cJ1_JPBRANCH_L7"); POP7;NUMJPSL;break;
#endif
case cJ1_JPBRANCH_L: JPTYPE("cJ1_JPBRANCH_L"); NUMJPSL;break;
case cJ1_JPBRANCH_B2: JPTYPE("cJ1_JPBRANCH_B2"); POP2;NUMJPSB;break;
case cJ1_JPBRANCH_B3: JPTYPE("cJ1_JPBRANCH_B3"); POP3;NUMJPSB;break;
#ifdef JU_64BIT
case cJ1_JPBRANCH_B4: JPTYPE("cJ1_JPBRANCH_B4"); POP4;NUMJPSB;break;
case cJ1_JPBRANCH_B5: JPTYPE("cJ1_JPBRANCH_B5"); POP5;NUMJPSB;break;
case cJ1_JPBRANCH_B6: JPTYPE("cJ1_JPBRANCH_B6"); POP6;NUMJPSB;break;
case cJ1_JPBRANCH_B7: JPTYPE("cJ1_JPBRANCH_B7"); POP7;NUMJPSB;break;
#endif
case cJ1_JPBRANCH_B: JPTYPE("cJ1_JPBRANCH_B"); NUMJPSB;break;
case cJ1_JPBRANCH_U2: JPTYPE("cJ1_JPBRANCH_U2"); POP2; break;
case cJ1_JPBRANCH_U3: JPTYPE("cJ1_JPBRANCH_U3"); POP3; break;
#ifdef JU_64BIT
case cJ1_JPBRANCH_U4: JPTYPE("cJ1_JPBRANCH_U4"); POP4; break;
case cJ1_JPBRANCH_U5: JPTYPE("cJ1_JPBRANCH_U5"); POP5; break;
case cJ1_JPBRANCH_U6: JPTYPE("cJ1_JPBRANCH_U6"); POP6; break;
case cJ1_JPBRANCH_U7: JPTYPE("cJ1_JPBRANCH_U7"); POP7; break;
#endif
case cJ1_JPBRANCH_U: JPTYPE("cJ1_JPBRANCH_U"); break;
#ifndef JU_64BIT
case cJ1_JPLEAF1: JPTYPE("cJ1_JPLEAF1"); POP1; break;
#endif
case cJ1_JPLEAF2: JPTYPE("cJ1_JPLEAF2"); POP2; break;
case cJ1_JPLEAF3: JPTYPE("cJ1_JPLEAF3"); POP3; break;
#ifdef JU_64BIT
case cJ1_JPLEAF4: JPTYPE("cJ1_JPLEAF4"); POP4; break;
case cJ1_JPLEAF5: JPTYPE("cJ1_JPLEAF5"); POP5; break;
case cJ1_JPLEAF6: JPTYPE("cJ1_JPLEAF6"); POP6; break;
case cJ1_JPLEAF7: JPTYPE("cJ1_JPLEAF7"); POP7; break;
#endif
case cJ1_JPLEAF_B1: JPTYPE("cJ1_JPLEAF_B1"); POP1; break;
case cJ1_JPFULLPOPU1: JPTYPE("cJ1_JPFULLPOPU1"); POP1; break;
case cJ1_JPIMMED_1_01: JPTYPE("cJ1_JPIMMED_1_01"); POP_1; break;
case cJ1_JPIMMED_2_01: JPTYPE("cJ1_JPIMMED_2_01"); POP_1; break;
case cJ1_JPIMMED_3_01: JPTYPE("cJ1_JPIMMED_3_01"); POP_1; break;
#ifdef JU_64BIT
case cJ1_JPIMMED_4_01: JPTYPE("cJ1_JPIMMED_4_01"); POP_1; break;
case cJ1_JPIMMED_5_01: JPTYPE("cJ1_JPIMMED_5_01"); POP_1; break;
case cJ1_JPIMMED_6_01: JPTYPE("cJ1_JPIMMED_6_01"); POP_1; break;
case cJ1_JPIMMED_7_01: JPTYPE("cJ1_JPIMMED_7_01"); POP_1; break;
#endif
case cJ1_JPIMMED_1_02: JPTYPE("cJ1_JPIMMED_1_02"); POP_2; break;
case cJ1_JPIMMED_1_03: JPTYPE("cJ1_JPIMMED_1_03"); POP_3; break;
case cJ1_JPIMMED_1_04: JPTYPE("cJ1_JPIMMED_1_04"); POP_4; break;
case cJ1_JPIMMED_1_05: JPTYPE("cJ1_JPIMMED_1_05"); POP_5; break;
case cJ1_JPIMMED_1_06: JPTYPE("cJ1_JPIMMED_1_06"); POP_6; break;
case cJ1_JPIMMED_1_07: JPTYPE("cJ1_JPIMMED_1_07"); POP_7; break;
#ifdef JU_64BIT
case cJ1_JPIMMED_1_08: JPTYPE("cJ1_JPIMMED_1_08"); POP_8; break;
case cJ1_JPIMMED_1_09: JPTYPE("cJ1_JPIMMED_1_09"); POP_9; break;
case cJ1_JPIMMED_1_10: JPTYPE("cJ1_JPIMMED_1_10"); POP_10; break;
case cJ1_JPIMMED_1_11: JPTYPE("cJ1_JPIMMED_1_11"); POP_11; break;
case cJ1_JPIMMED_1_12: JPTYPE("cJ1_JPIMMED_1_12"); POP_12; break;
case cJ1_JPIMMED_1_13: JPTYPE("cJ1_JPIMMED_1_13"); POP_13; break;
case cJ1_JPIMMED_1_14: JPTYPE("cJ1_JPIMMED_1_14"); POP_14; break;
case cJ1_JPIMMED_1_15: JPTYPE("cJ1_JPIMMED_1_15"); POP_15; break;
#endif
case cJ1_JPIMMED_2_02: JPTYPE("cJ1_JPIMMED_2_02"); POP_2; break;
case cJ1_JPIMMED_2_03: JPTYPE("cJ1_JPIMMED_2_03"); POP_3; break;
#ifdef JU_64BIT
case cJ1_JPIMMED_2_04: JPTYPE("cJ1_JPIMMED_2_04"); POP_4; break;
case cJ1_JPIMMED_2_05: JPTYPE("cJ1_JPIMMED_2_05"); POP_5; break;
case cJ1_JPIMMED_2_06: JPTYPE("cJ1_JPIMMED_2_06"); POP_6; break;
case cJ1_JPIMMED_2_07: JPTYPE("cJ1_JPIMMED_2_07"); POP_7; break;
#endif
case cJ1_JPIMMED_3_02: JPTYPE("cJ1_JPIMMED_3_02"); POP_2; break;
#ifdef JU_64BIT
case cJ1_JPIMMED_3_03: JPTYPE("cJ1_JPIMMED_3_03"); POP_3; break;
case cJ1_JPIMMED_3_04: JPTYPE("cJ1_JPIMMED_3_04"); POP_4; break;
case cJ1_JPIMMED_3_05: JPTYPE("cJ1_JPIMMED_3_05"); POP_5; break;
case cJ1_JPIMMED_4_02: JPTYPE("cJ1_JPIMMED_4_02"); POP_2; break;
case cJ1_JPIMMED_4_03: JPTYPE("cJ1_JPIMMED_4_03"); POP_3; break;
case cJ1_JPIMMED_5_02: JPTYPE("cJ1_JPIMMED_5_02"); POP_2; break;
case cJ1_JPIMMED_5_03: JPTYPE("cJ1_JPIMMED_5_03"); POP_3; break;
case cJ1_JPIMMED_6_02: JPTYPE("cJ1_JPIMMED_6_02"); POP_2; break;
case cJ1_JPIMMED_7_02: JPTYPE("cJ1_JPIMMED_7_02"); POP_2; break;
#endif
case cJ1_JPIMMED_CAP: JPTYPE("cJ1_JPIMMED_CAP"); OOPS;
#else // JUDYL ===============================================================
case cJL_JPNULL1: JPTYPE("cJL_JPNULL1"); POP0; break;
case cJL_JPNULL2: JPTYPE("cJL_JPNULL2"); POP0; break;
case cJL_JPNULL3: JPTYPE("cJL_JPNULL3"); POP0; break;
#ifdef JU_64BIT
case cJL_JPNULL4: JPTYPE("cJL_JPNULL4"); POP0; break;
case cJL_JPNULL5: JPTYPE("cJL_JPNULL5"); POP0; break;
case cJL_JPNULL6: JPTYPE("cJL_JPNULL6"); POP0; break;
case cJL_JPNULL7: JPTYPE("cJL_JPNULL7"); POP0; break;
#endif
case cJL_JPBRANCH_L2: JPTYPE("cJL_JPBRANCH_L2"); POP2;NUMJPSL;break;
case cJL_JPBRANCH_L3: JPTYPE("cJL_JPBRANCH_L3"); POP3;NUMJPSL;break;
#ifdef JU_64BIT
case cJL_JPBRANCH_L4: JPTYPE("cJL_JPBRANCH_L4"); POP4;NUMJPSL;break;
case cJL_JPBRANCH_L5: JPTYPE("cJL_JPBRANCH_L5"); POP5;NUMJPSL;break;
case cJL_JPBRANCH_L6: JPTYPE("cJL_JPBRANCH_L6"); POP6;NUMJPSL;break;
case cJL_JPBRANCH_L7: JPTYPE("cJL_JPBRANCH_L7"); POP7;NUMJPSL;break;
#endif
case cJL_JPBRANCH_L: JPTYPE("cJL_JPBRANCH_L"); NUMJPSL;break;
case cJL_JPBRANCH_B2: JPTYPE("cJL_JPBRANCH_B2"); POP2;NUMJPSB;break;
case cJL_JPBRANCH_B3: JPTYPE("cJL_JPBRANCH_B3"); POP3;NUMJPSB;break;
#ifdef JU_64BIT
case cJL_JPBRANCH_B4: JPTYPE("cJL_JPBRANCH_B4"); POP4;NUMJPSB;break;
case cJL_JPBRANCH_B5: JPTYPE("cJL_JPBRANCH_B5"); POP5;NUMJPSB;break;
case cJL_JPBRANCH_B6: JPTYPE("cJL_JPBRANCH_B6"); POP6;NUMJPSB;break;
case cJL_JPBRANCH_B7: JPTYPE("cJL_JPBRANCH_B7"); POP7;NUMJPSB;break;
#endif
case cJL_JPBRANCH_B: JPTYPE("cJL_JPBRANCH_B"); NUMJPSB;break;
case cJL_JPBRANCH_U2: JPTYPE("cJL_JPBRANCH_U2"); POP2; break;
case cJL_JPBRANCH_U3: JPTYPE("cJL_JPBRANCH_U3"); POP3; break;
#ifdef JU_64BIT
case cJL_JPBRANCH_U4: JPTYPE("cJL_JPBRANCH_U4"); POP4; break;
case cJL_JPBRANCH_U5: JPTYPE("cJL_JPBRANCH_U5"); POP5; break;
case cJL_JPBRANCH_U6: JPTYPE("cJL_JPBRANCH_U6"); POP6; break;
case cJL_JPBRANCH_U7: JPTYPE("cJL_JPBRANCH_U7"); POP7; break;
#endif
case cJL_JPBRANCH_U: JPTYPE("cJL_JPBRANCH_U"); break;
case cJL_JPLEAF1: JPTYPE("cJL_JPLEAF1"); POP1; break;
case cJL_JPLEAF2: JPTYPE("cJL_JPLEAF2"); POP2; break;
case cJL_JPLEAF3: JPTYPE("cJL_JPLEAF3"); POP3; break;
#ifdef JU_64BIT
case cJL_JPLEAF4: JPTYPE("cJL_JPLEAF4"); POP4; break;
case cJL_JPLEAF5: JPTYPE("cJL_JPLEAF5"); POP5; break;
case cJL_JPLEAF6: JPTYPE("cJL_JPLEAF6"); POP6; break;
case cJL_JPLEAF7: JPTYPE("cJL_JPLEAF7"); POP7; break;
#endif
case cJL_JPLEAF_B1: JPTYPE("cJL_JPLEAF_B1"); POP1; break;
case cJL_JPIMMED_1_01: JPTYPE("cJL_JPIMMED_1_01"); POP_1; break;
case cJL_JPIMMED_2_01: JPTYPE("cJL_JPIMMED_2_01"); POP_1; break;
case cJL_JPIMMED_3_01: JPTYPE("cJL_JPIMMED_3_01"); POP_1; break;
#ifdef JU_64BIT
case cJL_JPIMMED_4_01: JPTYPE("cJL_JPIMMED_4_01"); POP_1; break;
case cJL_JPIMMED_5_01: JPTYPE("cJL_JPIMMED_5_01"); POP_1; break;
case cJL_JPIMMED_6_01: JPTYPE("cJL_JPIMMED_6_01"); POP_1; break;
case cJL_JPIMMED_7_01: JPTYPE("cJL_JPIMMED_7_01"); POP_1; break;
#endif
case cJL_JPIMMED_1_02: JPTYPE("cJL_JPIMMED_1_02"); POP_2; break;
case cJL_JPIMMED_1_03: JPTYPE("cJL_JPIMMED_1_03"); POP_3; break;
#ifdef JU_64BIT
case cJL_JPIMMED_1_04: JPTYPE("cJL_JPIMMED_1_04"); POP_4; break;
case cJL_JPIMMED_1_05: JPTYPE("cJL_JPIMMED_1_05"); POP_5; break;
case cJL_JPIMMED_1_06: JPTYPE("cJL_JPIMMED_1_06"); POP_6; break;
case cJL_JPIMMED_1_07: JPTYPE("cJL_JPIMMED_1_07"); POP_7; break;
case cJL_JPIMMED_2_02: JPTYPE("cJL_JPIMMED_2_02"); POP_2; break;
case cJL_JPIMMED_2_03: JPTYPE("cJL_JPIMMED_2_03"); POP_3; break;
case cJL_JPIMMED_3_02: JPTYPE("cJL_JPIMMED_3_02"); POP_2; break;
#endif
case cJL_JPIMMED_CAP: JPTYPE("cJL_JPIMMED_CAP"); OOPS;
#endif // JUDYL
default: printf("Unknown Type = %d", JU_JPTYPE(Pjp)); OOPS;
}
if (j__udyIndex) printf("Index = 0x%lx", j__udyIndex);
if (j__udyPopulation) printf("Pop = %lu", j__udyPopulation);
printf("line = %d\n", Line);
} // JudyPrintJP()

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,485 @@
#ifndef _JUDYPRIVATE1L_INCLUDED
#define _JUDYPRIVATE1L_INCLUDED
// _________________
//
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
// ****************************************************************************
// Declare common cJU_* names for JP Types that occur in both Judy1 and JudyL,
// for use by code that ifdefs JUDY1 and JUDYL. Only JP Types common to both
// Judy1 and JudyL are #defined here with equivalent cJU_* names. JP Types
// unique to only Judy1 or JudyL are listed in comments, so the type lists
// match the Judy1.h and JudyL.h files.
//
// This file also defines cJU_* for other JP-related constants and functions
// that some shared JUDY1/JUDYL code finds handy.
//
// At least in principle this file should be included AFTER Judy1.h or JudyL.h.
//
// WARNING: This file must be kept consistent with the enums in Judy1.h and
// JudyL.h.
//
// TBD: You might think, why not define common cJU_* enums in, say,
// JudyPrivate.h, and then inherit them into superset enums in Judy1.h and
// JudyL.h? The problem is that the enum lists for each class (cJ1_* and
// cJL_*) must be numerically "packed" into the correct order, for two reasons:
// (1) allow the compiler to generate "tight" switch statements with no wasted
// slots (although this is not very big), and (2) allow calculations using the
// enum values, although this is also not an issue if the calculations are only
// within each cJ*_JPIMMED_*_* class and the members are packed within the
// class.
#ifdef JUDY1
#define cJU_JRPNULL cJ1_JRPNULL
#define cJU_JPNULL1 cJ1_JPNULL1
#define cJU_JPNULL2 cJ1_JPNULL2
#define cJU_JPNULL3 cJ1_JPNULL3
#ifdef JU_64BIT
#define cJU_JPNULL4 cJ1_JPNULL4
#define cJU_JPNULL5 cJ1_JPNULL5
#define cJU_JPNULL6 cJ1_JPNULL6
#define cJU_JPNULL7 cJ1_JPNULL7
#endif
#define cJU_JPNULLMAX cJ1_JPNULLMAX
#define cJU_JPBRANCH_L2 cJ1_JPBRANCH_L2
#define cJU_JPBRANCH_L3 cJ1_JPBRANCH_L3
#ifdef JU_64BIT
#define cJU_JPBRANCH_L4 cJ1_JPBRANCH_L4
#define cJU_JPBRANCH_L5 cJ1_JPBRANCH_L5
#define cJU_JPBRANCH_L6 cJ1_JPBRANCH_L6
#define cJU_JPBRANCH_L7 cJ1_JPBRANCH_L7
#endif
#define cJU_JPBRANCH_L cJ1_JPBRANCH_L
#define j__U_BranchBJPPopToWords j__1_BranchBJPPopToWords
#define cJU_JPBRANCH_B2 cJ1_JPBRANCH_B2
#define cJU_JPBRANCH_B3 cJ1_JPBRANCH_B3
#ifdef JU_64BIT
#define cJU_JPBRANCH_B4 cJ1_JPBRANCH_B4
#define cJU_JPBRANCH_B5 cJ1_JPBRANCH_B5
#define cJU_JPBRANCH_B6 cJ1_JPBRANCH_B6
#define cJU_JPBRANCH_B7 cJ1_JPBRANCH_B7
#endif
#define cJU_JPBRANCH_B cJ1_JPBRANCH_B
#define cJU_JPBRANCH_U2 cJ1_JPBRANCH_U2
#define cJU_JPBRANCH_U3 cJ1_JPBRANCH_U3
#ifdef JU_64BIT
#define cJU_JPBRANCH_U4 cJ1_JPBRANCH_U4
#define cJU_JPBRANCH_U5 cJ1_JPBRANCH_U5
#define cJU_JPBRANCH_U6 cJ1_JPBRANCH_U6
#define cJU_JPBRANCH_U7 cJ1_JPBRANCH_U7
#endif
#define cJU_JPBRANCH_U cJ1_JPBRANCH_U
#ifndef JU_64BIT
#define cJU_JPLEAF1 cJ1_JPLEAF1
#endif
#define cJU_JPLEAF2 cJ1_JPLEAF2
#define cJU_JPLEAF3 cJ1_JPLEAF3
#ifdef JU_64BIT
#define cJU_JPLEAF4 cJ1_JPLEAF4
#define cJU_JPLEAF5 cJ1_JPLEAF5
#define cJU_JPLEAF6 cJ1_JPLEAF6
#define cJU_JPLEAF7 cJ1_JPLEAF7
#endif
#define cJU_JPLEAF_B1 cJ1_JPLEAF_B1
// cJ1_JPFULLPOPU1
#define cJU_JPIMMED_1_01 cJ1_JPIMMED_1_01
#define cJU_JPIMMED_2_01 cJ1_JPIMMED_2_01
#define cJU_JPIMMED_3_01 cJ1_JPIMMED_3_01
#ifdef JU_64BIT
#define cJU_JPIMMED_4_01 cJ1_JPIMMED_4_01
#define cJU_JPIMMED_5_01 cJ1_JPIMMED_5_01
#define cJU_JPIMMED_6_01 cJ1_JPIMMED_6_01
#define cJU_JPIMMED_7_01 cJ1_JPIMMED_7_01
#endif
#define cJU_JPIMMED_1_02 cJ1_JPIMMED_1_02
#define cJU_JPIMMED_1_03 cJ1_JPIMMED_1_03
#define cJU_JPIMMED_1_04 cJ1_JPIMMED_1_04
#define cJU_JPIMMED_1_05 cJ1_JPIMMED_1_05
#define cJU_JPIMMED_1_06 cJ1_JPIMMED_1_06
#define cJU_JPIMMED_1_07 cJ1_JPIMMED_1_07
#ifdef JU_64BIT
// cJ1_JPIMMED_1_08
// cJ1_JPIMMED_1_09
// cJ1_JPIMMED_1_10
// cJ1_JPIMMED_1_11
// cJ1_JPIMMED_1_12
// cJ1_JPIMMED_1_13
// cJ1_JPIMMED_1_14
// cJ1_JPIMMED_1_15
#endif
#define cJU_JPIMMED_2_02 cJ1_JPIMMED_2_02
#define cJU_JPIMMED_2_03 cJ1_JPIMMED_2_03
#ifdef JU_64BIT
// cJ1_JPIMMED_2_04
// cJ1_JPIMMED_2_05
// cJ1_JPIMMED_2_06
// cJ1_JPIMMED_2_07
#endif
#define cJU_JPIMMED_3_02 cJ1_JPIMMED_3_02
#ifdef JU_64BIT
// cJ1_JPIMMED_3_03
// cJ1_JPIMMED_3_04
// cJ1_JPIMMED_3_05
// cJ1_JPIMMED_4_02
// cJ1_JPIMMED_4_03
// cJ1_JPIMMED_5_02
// cJ1_JPIMMED_5_03
// cJ1_JPIMMED_6_02
// cJ1_JPIMMED_7_02
#endif
#define cJU_JPIMMED_CAP cJ1_JPIMMED_CAP
#else // JUDYL ****************************************************************
#define cJU_JRPNULL cJL_JRPNULL
#define cJU_JPNULL1 cJL_JPNULL1
#define cJU_JPNULL2 cJL_JPNULL2
#define cJU_JPNULL3 cJL_JPNULL3
#ifdef JU_64BIT
#define cJU_JPNULL4 cJL_JPNULL4
#define cJU_JPNULL5 cJL_JPNULL5
#define cJU_JPNULL6 cJL_JPNULL6
#define cJU_JPNULL7 cJL_JPNULL7
#endif
#define cJU_JPNULLMAX cJL_JPNULLMAX
#define cJU_JPBRANCH_L2 cJL_JPBRANCH_L2
#define cJU_JPBRANCH_L3 cJL_JPBRANCH_L3
#ifdef JU_64BIT
#define cJU_JPBRANCH_L4 cJL_JPBRANCH_L4
#define cJU_JPBRANCH_L5 cJL_JPBRANCH_L5
#define cJU_JPBRANCH_L6 cJL_JPBRANCH_L6
#define cJU_JPBRANCH_L7 cJL_JPBRANCH_L7
#endif
#define cJU_JPBRANCH_L cJL_JPBRANCH_L
#define j__U_BranchBJPPopToWords j__L_BranchBJPPopToWords
#define cJU_JPBRANCH_B2 cJL_JPBRANCH_B2
#define cJU_JPBRANCH_B3 cJL_JPBRANCH_B3
#ifdef JU_64BIT
#define cJU_JPBRANCH_B4 cJL_JPBRANCH_B4
#define cJU_JPBRANCH_B5 cJL_JPBRANCH_B5
#define cJU_JPBRANCH_B6 cJL_JPBRANCH_B6
#define cJU_JPBRANCH_B7 cJL_JPBRANCH_B7
#endif
#define cJU_JPBRANCH_B cJL_JPBRANCH_B
#define cJU_JPBRANCH_U2 cJL_JPBRANCH_U2
#define cJU_JPBRANCH_U3 cJL_JPBRANCH_U3
#ifdef JU_64BIT
#define cJU_JPBRANCH_U4 cJL_JPBRANCH_U4
#define cJU_JPBRANCH_U5 cJL_JPBRANCH_U5
#define cJU_JPBRANCH_U6 cJL_JPBRANCH_U6
#define cJU_JPBRANCH_U7 cJL_JPBRANCH_U7
#endif
#define cJU_JPBRANCH_U cJL_JPBRANCH_U
#define cJU_JPLEAF1 cJL_JPLEAF1
#define cJU_JPLEAF2 cJL_JPLEAF2
#define cJU_JPLEAF3 cJL_JPLEAF3
#ifdef JU_64BIT
#define cJU_JPLEAF4 cJL_JPLEAF4
#define cJU_JPLEAF5 cJL_JPLEAF5
#define cJU_JPLEAF6 cJL_JPLEAF6
#define cJU_JPLEAF7 cJL_JPLEAF7
#endif
#define cJU_JPLEAF_B1 cJL_JPLEAF_B1
#define cJU_JPIMMED_1_01 cJL_JPIMMED_1_01
#define cJU_JPIMMED_2_01 cJL_JPIMMED_2_01
#define cJU_JPIMMED_3_01 cJL_JPIMMED_3_01
#ifdef JU_64BIT
#define cJU_JPIMMED_4_01 cJL_JPIMMED_4_01
#define cJU_JPIMMED_5_01 cJL_JPIMMED_5_01
#define cJU_JPIMMED_6_01 cJL_JPIMMED_6_01
#define cJU_JPIMMED_7_01 cJL_JPIMMED_7_01
#endif
#define cJU_JPIMMED_1_02 cJL_JPIMMED_1_02
#define cJU_JPIMMED_1_03 cJL_JPIMMED_1_03
#ifdef JU_64BIT
#define cJU_JPIMMED_1_04 cJL_JPIMMED_1_04
#define cJU_JPIMMED_1_05 cJL_JPIMMED_1_05
#define cJU_JPIMMED_1_06 cJL_JPIMMED_1_06
#define cJU_JPIMMED_1_07 cJL_JPIMMED_1_07
#define cJU_JPIMMED_2_02 cJL_JPIMMED_2_02
#define cJU_JPIMMED_2_03 cJL_JPIMMED_2_03
#define cJU_JPIMMED_3_02 cJL_JPIMMED_3_02
#endif
#define cJU_JPIMMED_CAP cJL_JPIMMED_CAP
#endif // JUDYL
// ****************************************************************************
// cJU*_ other than JP types:
#ifdef JUDY1
#define cJU_LEAFW_MAXPOP1 cJ1_LEAFW_MAXPOP1
#ifndef JU_64BIT
#define cJU_LEAF1_MAXPOP1 cJ1_LEAF1_MAXPOP1
#endif
#define cJU_LEAF2_MAXPOP1 cJ1_LEAF2_MAXPOP1
#define cJU_LEAF3_MAXPOP1 cJ1_LEAF3_MAXPOP1
#ifdef JU_64BIT
#define cJU_LEAF4_MAXPOP1 cJ1_LEAF4_MAXPOP1
#define cJU_LEAF5_MAXPOP1 cJ1_LEAF5_MAXPOP1
#define cJU_LEAF6_MAXPOP1 cJ1_LEAF6_MAXPOP1
#define cJU_LEAF7_MAXPOP1 cJ1_LEAF7_MAXPOP1
#endif
#define cJU_IMMED1_MAXPOP1 cJ1_IMMED1_MAXPOP1
#define cJU_IMMED2_MAXPOP1 cJ1_IMMED2_MAXPOP1
#define cJU_IMMED3_MAXPOP1 cJ1_IMMED3_MAXPOP1
#ifdef JU_64BIT
#define cJU_IMMED4_MAXPOP1 cJ1_IMMED4_MAXPOP1
#define cJU_IMMED5_MAXPOP1 cJ1_IMMED5_MAXPOP1
#define cJU_IMMED6_MAXPOP1 cJ1_IMMED6_MAXPOP1
#define cJU_IMMED7_MAXPOP1 cJ1_IMMED7_MAXPOP1
#endif
#define JU_LEAF1POPTOWORDS(Pop1) J1_LEAF1POPTOWORDS(Pop1)
#define JU_LEAF2POPTOWORDS(Pop1) J1_LEAF2POPTOWORDS(Pop1)
#define JU_LEAF3POPTOWORDS(Pop1) J1_LEAF3POPTOWORDS(Pop1)
#ifdef JU_64BIT
#define JU_LEAF4POPTOWORDS(Pop1) J1_LEAF4POPTOWORDS(Pop1)
#define JU_LEAF5POPTOWORDS(Pop1) J1_LEAF5POPTOWORDS(Pop1)
#define JU_LEAF6POPTOWORDS(Pop1) J1_LEAF6POPTOWORDS(Pop1)
#define JU_LEAF7POPTOWORDS(Pop1) J1_LEAF7POPTOWORDS(Pop1)
#endif
#define JU_LEAFWPOPTOWORDS(Pop1) J1_LEAFWPOPTOWORDS(Pop1)
#ifndef JU_64BIT
#define JU_LEAF1GROWINPLACE(Pop1) J1_LEAF1GROWINPLACE(Pop1)
#endif
#define JU_LEAF2GROWINPLACE(Pop1) J1_LEAF2GROWINPLACE(Pop1)
#define JU_LEAF3GROWINPLACE(Pop1) J1_LEAF3GROWINPLACE(Pop1)
#ifdef JU_64BIT
#define JU_LEAF4GROWINPLACE(Pop1) J1_LEAF4GROWINPLACE(Pop1)
#define JU_LEAF5GROWINPLACE(Pop1) J1_LEAF5GROWINPLACE(Pop1)
#define JU_LEAF6GROWINPLACE(Pop1) J1_LEAF6GROWINPLACE(Pop1)
#define JU_LEAF7GROWINPLACE(Pop1) J1_LEAF7GROWINPLACE(Pop1)
#endif
#define JU_LEAFWGROWINPLACE(Pop1) J1_LEAFWGROWINPLACE(Pop1)
#define j__udyCreateBranchL j__udy1CreateBranchL
#define j__udyCreateBranchB j__udy1CreateBranchB
#define j__udyCreateBranchU j__udy1CreateBranchU
#define j__udyCascade1 j__udy1Cascade1
#define j__udyCascade2 j__udy1Cascade2
#define j__udyCascade3 j__udy1Cascade3
#ifdef JU_64BIT
#define j__udyCascade4 j__udy1Cascade4
#define j__udyCascade5 j__udy1Cascade5
#define j__udyCascade6 j__udy1Cascade6
#define j__udyCascade7 j__udy1Cascade7
#endif
#define j__udyCascadeL j__udy1CascadeL
#define j__udyInsertBranch j__udy1InsertBranch
#define j__udyBranchBToBranchL j__udy1BranchBToBranchL
#ifndef JU_64BIT
#define j__udyLeafB1ToLeaf1 j__udy1LeafB1ToLeaf1
#endif
#define j__udyLeaf1ToLeaf2 j__udy1Leaf1ToLeaf2
#define j__udyLeaf2ToLeaf3 j__udy1Leaf2ToLeaf3
#ifndef JU_64BIT
#define j__udyLeaf3ToLeafW j__udy1Leaf3ToLeafW
#else
#define j__udyLeaf3ToLeaf4 j__udy1Leaf3ToLeaf4
#define j__udyLeaf4ToLeaf5 j__udy1Leaf4ToLeaf5
#define j__udyLeaf5ToLeaf6 j__udy1Leaf5ToLeaf6
#define j__udyLeaf6ToLeaf7 j__udy1Leaf6ToLeaf7
#define j__udyLeaf7ToLeafW j__udy1Leaf7ToLeafW
#endif
#define jpm_t j1pm_t
#define Pjpm_t Pj1pm_t
#define jlb_t j1lb_t
#define Pjlb_t Pj1lb_t
#define JU_JLB_BITMAP J1_JLB_BITMAP
#define j__udyAllocJPM j__udy1AllocJ1PM
#define j__udyAllocJBL j__udy1AllocJBL
#define j__udyAllocJBB j__udy1AllocJBB
#define j__udyAllocJBBJP j__udy1AllocJBBJP
#define j__udyAllocJBU j__udy1AllocJBU
#ifndef JU_64BIT
#define j__udyAllocJLL1 j__udy1AllocJLL1
#endif
#define j__udyAllocJLL2 j__udy1AllocJLL2
#define j__udyAllocJLL3 j__udy1AllocJLL3
#ifdef JU_64BIT
#define j__udyAllocJLL4 j__udy1AllocJLL4
#define j__udyAllocJLL5 j__udy1AllocJLL5
#define j__udyAllocJLL6 j__udy1AllocJLL6
#define j__udyAllocJLL7 j__udy1AllocJLL7
#endif
#define j__udyAllocJLW j__udy1AllocJLW
#define j__udyAllocJLB1 j__udy1AllocJLB1
#define j__udyFreeJPM j__udy1FreeJ1PM
#define j__udyFreeJBL j__udy1FreeJBL
#define j__udyFreeJBB j__udy1FreeJBB
#define j__udyFreeJBBJP j__udy1FreeJBBJP
#define j__udyFreeJBU j__udy1FreeJBU
#ifndef JU_64BIT
#define j__udyFreeJLL1 j__udy1FreeJLL1
#endif
#define j__udyFreeJLL2 j__udy1FreeJLL2
#define j__udyFreeJLL3 j__udy1FreeJLL3
#ifdef JU_64BIT
#define j__udyFreeJLL4 j__udy1FreeJLL4
#define j__udyFreeJLL5 j__udy1FreeJLL5
#define j__udyFreeJLL6 j__udy1FreeJLL6
#define j__udyFreeJLL7 j__udy1FreeJLL7
#endif
#define j__udyFreeJLW j__udy1FreeJLW
#define j__udyFreeJLB1 j__udy1FreeJLB1
#define j__udyFreeSM j__udy1FreeSM
#define j__uMaxWords j__u1MaxWords
#ifdef DEBUG
#define JudyCheckPop Judy1CheckPop
#endif
#else // JUDYL ****************************************************************
#define cJU_LEAFW_MAXPOP1 cJL_LEAFW_MAXPOP1
#define cJU_LEAF1_MAXPOP1 cJL_LEAF1_MAXPOP1
#define cJU_LEAF2_MAXPOP1 cJL_LEAF2_MAXPOP1
#define cJU_LEAF3_MAXPOP1 cJL_LEAF3_MAXPOP1
#ifdef JU_64BIT
#define cJU_LEAF4_MAXPOP1 cJL_LEAF4_MAXPOP1
#define cJU_LEAF5_MAXPOP1 cJL_LEAF5_MAXPOP1
#define cJU_LEAF6_MAXPOP1 cJL_LEAF6_MAXPOP1
#define cJU_LEAF7_MAXPOP1 cJL_LEAF7_MAXPOP1
#endif
#define cJU_IMMED1_MAXPOP1 cJL_IMMED1_MAXPOP1
#define cJU_IMMED2_MAXPOP1 cJL_IMMED2_MAXPOP1
#define cJU_IMMED3_MAXPOP1 cJL_IMMED3_MAXPOP1
#ifdef JU_64BIT
#define cJU_IMMED4_MAXPOP1 cJL_IMMED4_MAXPOP1
#define cJU_IMMED5_MAXPOP1 cJL_IMMED5_MAXPOP1
#define cJU_IMMED6_MAXPOP1 cJL_IMMED6_MAXPOP1
#define cJU_IMMED7_MAXPOP1 cJL_IMMED7_MAXPOP1
#endif
#define JU_LEAF1POPTOWORDS(Pop1) JL_LEAF1POPTOWORDS(Pop1)
#define JU_LEAF2POPTOWORDS(Pop1) JL_LEAF2POPTOWORDS(Pop1)
#define JU_LEAF3POPTOWORDS(Pop1) JL_LEAF3POPTOWORDS(Pop1)
#ifdef JU_64BIT
#define JU_LEAF4POPTOWORDS(Pop1) JL_LEAF4POPTOWORDS(Pop1)
#define JU_LEAF5POPTOWORDS(Pop1) JL_LEAF5POPTOWORDS(Pop1)
#define JU_LEAF6POPTOWORDS(Pop1) JL_LEAF6POPTOWORDS(Pop1)
#define JU_LEAF7POPTOWORDS(Pop1) JL_LEAF7POPTOWORDS(Pop1)
#endif
#define JU_LEAFWPOPTOWORDS(Pop1) JL_LEAFWPOPTOWORDS(Pop1)
#define JU_LEAF1GROWINPLACE(Pop1) JL_LEAF1GROWINPLACE(Pop1)
#define JU_LEAF2GROWINPLACE(Pop1) JL_LEAF2GROWINPLACE(Pop1)
#define JU_LEAF3GROWINPLACE(Pop1) JL_LEAF3GROWINPLACE(Pop1)
#ifdef JU_64BIT
#define JU_LEAF4GROWINPLACE(Pop1) JL_LEAF4GROWINPLACE(Pop1)
#define JU_LEAF5GROWINPLACE(Pop1) JL_LEAF5GROWINPLACE(Pop1)
#define JU_LEAF6GROWINPLACE(Pop1) JL_LEAF6GROWINPLACE(Pop1)
#define JU_LEAF7GROWINPLACE(Pop1) JL_LEAF7GROWINPLACE(Pop1)
#endif
#define JU_LEAFWGROWINPLACE(Pop1) JL_LEAFWGROWINPLACE(Pop1)
#define j__udyCreateBranchL j__udyLCreateBranchL
#define j__udyCreateBranchB j__udyLCreateBranchB
#define j__udyCreateBranchU j__udyLCreateBranchU
#define j__udyCascade1 j__udyLCascade1
#define j__udyCascade2 j__udyLCascade2
#define j__udyCascade3 j__udyLCascade3
#ifdef JU_64BIT
#define j__udyCascade4 j__udyLCascade4
#define j__udyCascade5 j__udyLCascade5
#define j__udyCascade6 j__udyLCascade6
#define j__udyCascade7 j__udyLCascade7
#endif
#define j__udyCascadeL j__udyLCascadeL
#define j__udyInsertBranch j__udyLInsertBranch
#define j__udyBranchBToBranchL j__udyLBranchBToBranchL
#define j__udyLeafB1ToLeaf1 j__udyLLeafB1ToLeaf1
#define j__udyLeaf1ToLeaf2 j__udyLLeaf1ToLeaf2
#define j__udyLeaf2ToLeaf3 j__udyLLeaf2ToLeaf3
#ifndef JU_64BIT
#define j__udyLeaf3ToLeafW j__udyLLeaf3ToLeafW
#else
#define j__udyLeaf3ToLeaf4 j__udyLLeaf3ToLeaf4
#define j__udyLeaf4ToLeaf5 j__udyLLeaf4ToLeaf5
#define j__udyLeaf5ToLeaf6 j__udyLLeaf5ToLeaf6
#define j__udyLeaf6ToLeaf7 j__udyLLeaf6ToLeaf7
#define j__udyLeaf7ToLeafW j__udyLLeaf7ToLeafW
#endif
#define jpm_t jLpm_t
#define Pjpm_t PjLpm_t
#define jlb_t jLlb_t
#define Pjlb_t PjLlb_t
#define JU_JLB_BITMAP JL_JLB_BITMAP
#define j__udyAllocJPM j__udyLAllocJLPM
#define j__udyAllocJBL j__udyLAllocJBL
#define j__udyAllocJBB j__udyLAllocJBB
#define j__udyAllocJBBJP j__udyLAllocJBBJP
#define j__udyAllocJBU j__udyLAllocJBU
#define j__udyAllocJLL1 j__udyLAllocJLL1
#define j__udyAllocJLL2 j__udyLAllocJLL2
#define j__udyAllocJLL3 j__udyLAllocJLL3
#ifdef JU_64BIT
#define j__udyAllocJLL4 j__udyLAllocJLL4
#define j__udyAllocJLL5 j__udyLAllocJLL5
#define j__udyAllocJLL6 j__udyLAllocJLL6
#define j__udyAllocJLL7 j__udyLAllocJLL7
#endif
#define j__udyAllocJLW j__udyLAllocJLW
#define j__udyAllocJLB1 j__udyLAllocJLB1
// j__udyLAllocJV
#define j__udyFreeJPM j__udyLFreeJLPM
#define j__udyFreeJBL j__udyLFreeJBL
#define j__udyFreeJBB j__udyLFreeJBB
#define j__udyFreeJBBJP j__udyLFreeJBBJP
#define j__udyFreeJBU j__udyLFreeJBU
#define j__udyFreeJLL1 j__udyLFreeJLL1
#define j__udyFreeJLL2 j__udyLFreeJLL2
#define j__udyFreeJLL3 j__udyLFreeJLL3
#ifdef JU_64BIT
#define j__udyFreeJLL4 j__udyLFreeJLL4
#define j__udyFreeJLL5 j__udyLFreeJLL5
#define j__udyFreeJLL6 j__udyLFreeJLL6
#define j__udyFreeJLL7 j__udyLFreeJLL7
#endif
#define j__udyFreeJLW j__udyLFreeJLW
#define j__udyFreeJLB1 j__udyLFreeJLB1
#define j__udyFreeSM j__udyLFreeSM
// j__udyLFreeJV
#define j__uMaxWords j__uLMaxWords
#ifdef DEBUG
#define JudyCheckPop JudyLCheckPop
#endif
#endif // JUDYL
#endif // _JUDYPRIVATE1L_INCLUDED

View File

@ -0,0 +1,779 @@
#ifndef _JUDY_PRIVATE_BRANCH_INCLUDED
#define _JUDY_PRIVATE_BRANCH_INCLUDED
// _________________
//
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
//
// Header file for all Judy sources, for global but private (non-exported)
// declarations specific to branch support.
//
// See also the "Judy Shop Manual" (try judy/doc/int/JudyShopManual.*).
// ****************************************************************************
// JUDY POINTER (JP) SUPPORT
// ****************************************************************************
//
// This "rich pointer" object is pivotal to Judy execution.
//
// JP CONTAINING OTHER THAN IMMEDIATE INDEXES:
//
// If the JP points to a linear or bitmap leaf, jp_DcdPopO contains the
// Population-1 in LSbs and Decode (Dcd) bytes in the MSBs. (In practice the
// Decode bits are masked off while accessing the Pop0 bits.)
//
// The Decode Size, the number of Dcd bytes available, is encoded in jpo_Type.
// It can also be thought of as the number of states "skipped" in the SM, where
// each state decodes 8 bits = 1 byte.
//
// TBD: Dont need two structures, except possibly to force jp_Type to highest
// address!
//
// Note: The jpo_u union is not required by HP-UX or Linux but Win32 because
// the cl.exe compiler otherwise refuses to pack a bitfield (DcdPopO) with
// anything else, even with the -Zp option. This is pretty ugly, but
// fortunately portable, and its all hide-able by macros (see below).
typedef struct J_UDY_POINTER_OTHERS // JPO.
{
Word_t j_po_Addr; // first word: Pjp_t, Word_t, etc.
union {
// Word_t j_po_DcdPop0:cJU_BITSPERWORD-cJU_BITSPERBYTE;
uint8_t j_po_DcdP0[sizeof(Word_t) - 1];
uint8_t j_po_Bytes[sizeof(Word_t)]; // last byte = jp_Type.
} jpo_u;
} jpo_t;
// JP CONTAINING IMMEDIATE INDEXES:
//
// j_pi_1Index[] plus j_pi_LIndex[] together hold as many N-byte (1..3-byte
// [1..7-byte]) Indexes as will fit in sizeof(jpi_t) less 1 byte for j_pi_Type
// (that is, 7..1 [15..1] Indexes).
//
// For Judy1, j_pi_1Index[] is used and j_pi_LIndex[] is not used.
// For JudyL, j_pi_LIndex[] is used and j_pi_1Index[] is not used.
//
// Note: Actually when Pop1 = 1, jpi_t is not used, and the least bytes of the
// single Index are stored in j_po_DcdPopO, for both Judy1 and JudyL, so for
// JudyL the j_po_Addr field can hold the target value.
//
// TBD: Revise this structure to not overload j_po_DcdPopO this way? The
// current arrangement works, its just confusing.
typedef struct _JUDY_POINTER_IMMED // JPI.
{
uint8_t j_pi_1Index[sizeof(Word_t)]; // see above.
uint8_t j_pi_LIndex[sizeof(Word_t) - 1]; // see above.
uint8_t j_pi_Type; // JP type, 1 of cJ*_JPIMMED*.
} jpi_t;
// UNION OF JP TYPES:
//
// A branch is an array of cJU_BRANCHUNUMJPS (256) of this object, or an
// alternate data type such as: A linear branch which is a list of 2..7 JPs,
// or a bitmap branch which contains 8 lists of 0..32 JPs. JPs reside only in
// branches of a Judy SM.
typedef union J_UDY_POINTER // JP.
{
jpo_t j_po; // other than immediate indexes.
jpi_t j_pi; // immediate indexes.
} jp_t, *Pjp_t;
// For coding convenience:
//
// Note, jp_Type has the same bits in jpo_t and jpi_t.
#define jp_1Index j_pi.j_pi_1Index // for storing Indexes in first word.
#define jp_LIndex j_pi.j_pi_LIndex // for storing Indexes in second word.
#define jp_Addr j_po.j_po_Addr
//#define jp_DcdPop0 j_po.jpo_u.j_po_DcdPop0
#define jp_Type j_po.jpo_u.j_po_Bytes[sizeof(Word_t) - 1]
#define jp_DcdP0 j_po.jpo_u.j_po_DcdP0
// ****************************************************************************
// JUDY POINTER (JP) -- RELATED MACROS AND CONSTANTS
// ****************************************************************************
// EXTRACT VALUES FROM JP:
//
// Masks for the bytes in the Dcd and Pop0 parts of jp_DcdPopO:
//
// cJU_DCDMASK() consists of a mask that excludes the (LSb) Pop0 bytes and
// also, just to be safe, the top byte of the word, since jp_DcdPopO is 1 byte
// less than a full word.
//
// Note: These are constant macros (cJU) because cPopBytes should be a
// constant. Also note cPopBytes == state in the SM.
#define cJU_POP0MASK(cPopBytes) JU_LEASTBYTESMASK(cPopBytes)
#define cJU_DCDMASK(cPopBytes) \
((cJU_ALLONES >> cJU_BITSPERBYTE) & (~cJU_POP0MASK(cPopBytes)))
// Mask off the high byte from INDEX to it can be compared to DcdPopO:
#define JU_TRIMTODCDSIZE(INDEX) ((cJU_ALLONES >> cJU_BITSPERBYTE) & (INDEX))
// Get from jp_DcdPopO the Pop0 for various branch JP Types:
//
// Note: There are no simple macros for cJU_BRANCH* Types because their
// populations must be added up and dont reside in an already-calculated
// place.
#define JU_JPBRANCH_POP0(PJP,cPopBytes) \
(JU_JPDCDPOP0(PJP) & cJU_POP0MASK(cPopBytes))
// METHOD FOR DETERMINING IF OBJECTS HAVE ROOM TO GROW:
//
// J__U_GROWCK() is a generic method to determine if an object can grow in
// place, based on whether the next population size (one more) would use the
// same space.
#define J__U_GROWCK(POP1,MAXPOP1,POPTOWORDS) \
(((POP1) != (MAXPOP1)) && (POPTOWORDS[POP1] == POPTOWORDS[(POP1) + 1]))
#define JU_BRANCHBJPGROWINPLACE(NumJPs) \
J__U_GROWCK(NumJPs, cJU_BITSPERSUBEXPB, j__U_BranchBJPPopToWords)
// DETERMINE IF AN INDEX IS (NOT) IN A JPS EXPANSE:
#define JU_DCDNOTMATCHINDEX(INDEX,PJP,POP0BYTES) \
(((INDEX) ^ JU_JPDCDPOP0(PJP)) & cJU_DCDMASK(POP0BYTES))
// NUMBER OF JPs IN AN UNCOMPRESSED BRANCH:
//
// An uncompressed branch is simply an array of 256 Judy Pointers (JPs). It is
// a minimum cacheline fill object. Define it here before its first needed.
#define cJU_BRANCHUNUMJPS cJU_SUBEXPPERSTATE
// ****************************************************************************
// JUDY BRANCH LINEAR (JBL) SUPPORT
// ****************************************************************************
//
// A linear branch is a way of compressing empty expanses (null JPs) out of an
// uncompressed 256-way branch, when the number of populated expanses is so
// small that even a bitmap branch is excessive.
//
// The maximum number of JPs in a Judy linear branch:
//
// Note: This number results in a 1-cacheline sized structure. Previous
// versions had a larger struct so a linear branch didnt become a bitmap
// branch until the memory consumed was even, but for speed, its better to
// switch "sooner" and keep a linear branch fast.
#define cJU_BRANCHLMAXJPS 7
// LINEAR BRANCH STRUCT:
//
// 1-byte count, followed by array of byte-sized expanses, followed by JPs.
typedef struct J__UDY_BRANCH_LINEAR
{
uint8_t jbl_NumJPs; // num of JPs (Pjp_t), 1..N.
uint8_t jbl_Expanse[cJU_BRANCHLMAXJPS]; // 1..7 MSbs of pop exps.
jp_t jbl_jp [cJU_BRANCHLMAXJPS]; // JPs for populated exps.
} jbl_t, * Pjbl_t;
// ****************************************************************************
// JUDY BRANCH BITMAP (JBB) SUPPORT
// ****************************************************************************
//
// A bitmap branch is a way of compressing empty expanses (null JPs) out of
// uncompressed 256-way branch. This costs 1 additional cache line fill, but
// can save a lot of memory when it matters most, near the leaves, and
// typically there will be only one at most in the path to any Index (leaf).
//
// The bitmap indicates which of the cJU_BRANCHUNUMJPS (256) JPs in the branch
// are NOT null, that is, their expanses are populated. The jbb_t also
// contains N pointers to "mini" Judy branches ("subexpanses") of up to M JPs
// each (see BITMAP_BRANCHMxN, for example, BITMAP_BRANCH32x8), where M x N =
// cJU_BRANCHUNUMJPS. These are dynamically allocated and never contain
// cJ*_JPNULL* jp_Types. An empty subexpanse is represented by no bit sets in
// the corresponding subexpanse bitmap, in which case the corresponding
// jbbs_Pjp pointers value is unused.
//
// Note that the number of valid JPs in each 1-of-N subexpanses is determined
// by POPULATION rather than by EXPANSE -- the desired outcome to save memory
// when near the leaves. Note that the memory required for 185 JPs is about as
// much as an uncompressed 256-way branch, therefore 184 is set as the maximum.
// However, it is expected that a conversion to an uncompressed 256-way branch
// will normally take place before this limit is reached for other reasons,
// such as improving performance when the "wasted" memory is well amortized by
// the population under the branch, preserving an acceptable overall
// bytes/Index in the Judy array.
//
// The number of pointers to arrays of JPs in the Judy bitmap branch:
//
// Note: The numbers below are the same in both 32 and 64 bit systems.
#define cJU_BRANCHBMAXJPS 184 // maximum JPs for bitmap branches.
// Convenience wrappers for referencing BranchB bitmaps or JP subarray
// pointers:
//
// Note: JU_JBB_PJP produces a "raw" memory address that must pass through
// P_JP before use, except when freeing memory:
#define JU_JBB_BITMAP(Pjbb, SubExp) ((Pjbb)->jbb_jbbs[SubExp].jbbs_Bitmap)
#define JU_JBB_PJP( Pjbb, SubExp) ((Pjbb)->jbb_jbbs[SubExp].jbbs_Pjp)
#define JU_SUBEXPB(Digit) (((Digit) / cJU_BITSPERSUBEXPB) & (cJU_NUMSUBEXPB-1))
#define JU_BITMAPTESTB(Pjbb, Index) \
(JU_JBB_BITMAP(Pjbb, JU_SUBEXPB(Index)) & JU_BITPOSMASKB(Index))
#define JU_BITMAPSETB(Pjbb, Index) \
(JU_JBB_BITMAP(Pjbb, JU_SUBEXPB(Index)) |= JU_BITPOSMASKB(Index))
// Note: JU_BITMAPCLEARB is not defined because the code does it a faster way.
typedef struct J__UDY_BRANCH_BITMAP_SUBEXPANSE
{
BITMAPB_t jbbs_Bitmap;
Pjp_t jbbs_Pjp;
} jbbs_t;
typedef struct J__UDY_BRANCH_BITMAP
{
jbbs_t jbb_jbbs [cJU_NUMSUBEXPB];
#ifdef SUBEXPCOUNTS
Word_t jbb_subPop1[cJU_NUMSUBEXPB];
#endif
} jbb_t, * Pjbb_t;
#define JU_BRANCHJP_NUMJPSTOWORDS(NumJPs) (j__U_BranchBJPPopToWords[NumJPs])
#ifdef SUBEXPCOUNTS
#define cJU_NUMSUBEXPU 16 // number of subexpanse counts.
#endif
// ****************************************************************************
// JUDY BRANCH UNCOMPRESSED (JBU) SUPPORT
// ****************************************************************************
// Convenience wrapper for referencing BranchU JPs:
//
// Note: This produces a non-"raw" address already passed through P_JBU().
#define JU_JBU_PJP(Pjp,Index,Level) \
(&((P_JBU((Pjp)->jp_Addr))->jbu_jp[JU_DIGITATSTATE(Index, Level)]))
#define JU_JBU_PJP0(Pjp) \
(&((P_JBU((Pjp)->jp_Addr))->jbu_jp[0]))
typedef struct J__UDY_BRANCH_UNCOMPRESSED
{
jp_t jbu_jp [cJU_BRANCHUNUMJPS]; // JPs for populated exp.
#ifdef SUBEXPCOUNTS
Word_t jbu_subPop1[cJU_NUMSUBEXPU];
#endif
} jbu_t, * Pjbu_t;
// ****************************************************************************
// OTHER SUPPORT FOR JUDY STATE MACHINES (SMs)
// ****************************************************************************
// OBJECT SIZES IN WORDS:
//
// Word_ts per various JudyL structures that have constant sizes.
// cJU_WORDSPERJP should always be 2; this is fundamental to the Judy
// structures.
#define cJU_WORDSPERJP (sizeof(jp_t) / cJU_BYTESPERWORD)
#define cJU_WORDSPERCL (cJU_BYTESPERCL / cJU_BYTESPERWORD)
// OPPORTUNISTIC UNCOMPRESSION:
//
// Define populations at which a BranchL or BranchB must convert to BranchU.
// Earlier conversion is possible with good memory efficiency -- see below.
#ifndef NO_BRANCHU
// Max population below BranchL, then convert to BranchU:
#define JU_BRANCHL_MAX_POP 1000
// Minimum global population increment before next conversion of a BranchB to a
// BranchU:
//
// This is was done to allow malloc() to coalesce memory before the next big
// (~512 words) allocation.
#define JU_BTOU_POP_INCREMENT 300
// Min/max population below BranchB, then convert to BranchU:
#define JU_BRANCHB_MIN_POP 135
#define JU_BRANCHB_MAX_POP 750
#else // NO_BRANCHU
// These are set up to have conservative conversion schedules to BranchU:
#define JU_BRANCHL_MAX_POP (-1UL)
#define JU_BTOU_POP_INCREMENT 300
#define JU_BRANCHB_MIN_POP 1000
#define JU_BRANCHB_MAX_POP (-1UL)
#endif // NO_BRANCHU
// MISCELLANEOUS MACROS:
// Get N most significant bits from the shifted Index word:
//
// As Index words are decoded, they are shifted left so only relevant,
// undecoded Index bits remain.
#define JU_BITSFROMSFTIDX(SFTIDX, N) ((SFTIDX) >> (cJU_BITSPERWORD - (N)))
// TBD: I have my doubts about the necessity of these macros (dlb):
// Produce 1-digit mask at specified state:
#define cJU_MASKATSTATE(State) (0xffL << (((State) - 1) * cJU_BITSPERBYTE))
// Get byte (digit) from Index at the specified state, right justified:
//
// Note: State must be 1..cJU_ROOTSTATE, and Digits must be 1..(cJU_ROOTSTATE
// - 1), but theres no way to assert these within an expression.
#define JU_DIGITATSTATE(Index,cState) \
((uint8_t)((Index) >> (((cState) - 1) * cJU_BITSPERBYTE)))
// Similarly, place byte (digit) at correct position for the specified state:
//
// Note: Cast digit to a Word_t first so there are no complaints or problems
// about shifting it more than 32 bits on a 64-bit system, say, when it is a
// uint8_t from jbl_Expanse[]. (Believe it or not, the C standard says to
// promote an unsigned char to a signed int; -Ac does not do this, but -Ae
// does.)
//
// Also, to make lint happy, cast the whole result again because apparently
// shifting a Word_t does not result in a Word_t!
#define JU_DIGITTOSTATE(Digit,cState) \
((Word_t) (((Word_t) (Digit)) << (((cState) - 1) * cJU_BITSPERBYTE)))
#endif // ! _JUDY_PRIVATE_BRANCH_INCLUDED
#ifdef TEST_INSDEL
// ****************************************************************************
// TEST CODE FOR INSERT/DELETE MACROS
// ****************************************************************************
//
// To use this, compile a temporary *.c file containing:
//
// #define DEBUG
// #define JUDY_ASSERT
// #define TEST_INSDEL
// #include "JudyPrivate.h"
// #include "JudyPrivateBranch.h"
//
// Use a command like this: cc -Ae +DD64 -I. -I JudyCommon -o t t.c
// For best results, include +DD64 on a 64-bit system.
//
// This test code exercises some tricky macros, but the output must be studied
// manually to verify it. Assume that for even-index testing, whole words
// (Word_t) suffices.
#include <stdio.h>
#define INDEXES 3 // in each array.
// ****************************************************************************
// I N I T
//
// Set up variables for next test. See usage.
FUNCTION void Init (
int base,
PWord_t PeIndex,
PWord_t PoIndex,
PWord_t Peleaf, // always whole words.
#ifndef JU_64BIT
uint8_t * Poleaf3)
#else
uint8_t * Poleaf3,
uint8_t * Poleaf5,
uint8_t * Poleaf6,
uint8_t * Poleaf7)
#endif
{
int offset;
*PeIndex = 99;
for (offset = 0; offset <= INDEXES; ++offset)
Peleaf[offset] = base + offset;
for (offset = 0; offset < (INDEXES + 1) * 3; ++offset)
Poleaf3[offset] = base + offset;
#ifndef JU_64BIT
*PoIndex = (91 << 24) | (92 << 16) | (93 << 8) | 94;
#else
*PoIndex = (91L << 56) | (92L << 48) | (93L << 40) | (94L << 32)
| (95L << 24) | (96L << 16) | (97L << 8) | 98L;
for (offset = 0; offset < (INDEXES + 1) * 5; ++offset)
Poleaf5[offset] = base + offset;
for (offset = 0; offset < (INDEXES + 1) * 6; ++offset)
Poleaf6[offset] = base + offset;
for (offset = 0; offset < (INDEXES + 1) * 7; ++offset)
Poleaf7[offset] = base + offset;
#endif
} // Init()
// ****************************************************************************
// P R I N T L E A F
//
// Print the byte values in a leaf.
FUNCTION void PrintLeaf (
char * Label, // for output.
int IOffset, // insertion offset in array.
int Indsize, // index size in bytes.
uint8_t * PLeaf) // array of Index bytes.
{
int offset; // in PLeaf.
int byte; // in one word.
(void) printf("%s %u: ", Label, IOffset);
for (offset = 0; offset <= INDEXES; ++offset)
{
for (byte = 0; byte < Indsize; ++byte)
(void) printf("%2d", PLeaf[(offset * Indsize) + byte]);
(void) printf(" ");
}
(void) printf("\n");
} // PrintLeaf()
// ****************************************************************************
// M A I N
//
// Test program.
FUNCTION main()
{
Word_t eIndex; // even, to insert.
Word_t oIndex; // odd, to insert.
Word_t eleaf [ INDEXES + 1]; // even leaf, index size 4.
uint8_t oleaf3[(INDEXES + 1) * 3]; // odd leaf, index size 3.
#ifdef JU_64BIT
uint8_t oleaf5[(INDEXES + 1) * 5]; // odd leaf, index size 5.
uint8_t oleaf6[(INDEXES + 1) * 6]; // odd leaf, index size 6.
uint8_t oleaf7[(INDEXES + 1) * 7]; // odd leaf, index size 7.
#endif
Word_t eleaf_2 [ INDEXES + 1]; // same, but second arrays:
uint8_t oleaf3_2[(INDEXES + 1) * 3];
#ifdef JU_64BIT
uint8_t oleaf5_2[(INDEXES + 1) * 5];
uint8_t oleaf6_2[(INDEXES + 1) * 6];
uint8_t oleaf7_2[(INDEXES + 1) * 7];
#endif
int ioffset; // index insertion offset.
#ifndef JU_64BIT
#define INIT Init( 0, & eIndex, & oIndex, eleaf, oleaf3)
#define INIT2 INIT; Init(50, & eIndex, & oIndex, eleaf_2, oleaf3_2)
#else
#define INIT Init( 0, & eIndex, & oIndex, eleaf, oleaf3, \
oleaf5, oleaf6, oleaf7)
#define INIT2 INIT; Init(50, & eIndex, & oIndex, eleaf_2, oleaf3_2, \
oleaf5_2, oleaf6_2, oleaf7_2)
#endif
#define WSIZE sizeof (Word_t) // shorthand.
#ifdef PRINTALL // to turn on "noisy" printouts.
#define PRINTLEAF(Label,IOffset,Indsize,PLeaf) \
PrintLeaf(Label,IOffset,Indsize,PLeaf)
#else
#define PRINTLEAF(Label,IOffset,Indsize,PLeaf) \
if (ioffset == 0) \
PrintLeaf(Label,IOffset,Indsize,PLeaf)
#endif
(void) printf(
"In each case, tests operate on an initial array of %d indexes. Even-index\n"
"tests set index values to 0,1,2...; odd-index tests set byte values to\n"
"0,1,2... Inserted indexes have a value of 99 or else byte values 91,92,...\n",
INDEXES);
(void) puts("\nJU_INSERTINPLACE():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, WSIZE, (uint8_t *) eleaf);
JU_INSERTINPLACE(eleaf, INDEXES, ioffset, eIndex);
PrintLeaf("After ", ioffset, WSIZE, (uint8_t *) eleaf);
}
(void) puts("\nJU_INSERTINPLACE3():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 3, oleaf3);
JU_INSERTINPLACE3(oleaf3, INDEXES, ioffset, oIndex);
PrintLeaf("After ", ioffset, 3, oleaf3);
}
#ifdef JU_64BIT
(void) puts("\nJU_INSERTINPLACE5():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 5, oleaf5);
JU_INSERTINPLACE5(oleaf5, INDEXES, ioffset, oIndex);
PrintLeaf("After ", ioffset, 5, oleaf5);
}
(void) puts("\nJU_INSERTINPLACE6():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 6, oleaf6);
JU_INSERTINPLACE6(oleaf6, INDEXES, ioffset, oIndex);
PrintLeaf("After ", ioffset, 6, oleaf6);
}
(void) puts("\nJU_INSERTINPLACE7():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 7, oleaf7);
JU_INSERTINPLACE7(oleaf7, INDEXES, ioffset, oIndex);
PrintLeaf("After ", ioffset, 7, oleaf7);
}
#endif // JU_64BIT
(void) puts("\nJU_DELETEINPLACE():");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, WSIZE, (uint8_t *) eleaf);
JU_DELETEINPLACE(eleaf, INDEXES, ioffset);
PrintLeaf("After ", ioffset, WSIZE, (uint8_t *) eleaf);
}
(void) puts("\nJU_DELETEINPLACE_ODD(3):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 3, oleaf3);
JU_DELETEINPLACE_ODD(oleaf3, INDEXES, ioffset, 3);
PrintLeaf("After ", ioffset, 3, oleaf3);
}
#ifdef JU_64BIT
(void) puts("\nJU_DELETEINPLACE_ODD(5):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 5, oleaf5);
JU_DELETEINPLACE_ODD(oleaf5, INDEXES, ioffset, 5);
PrintLeaf("After ", ioffset, 5, oleaf5);
}
(void) puts("\nJU_DELETEINPLACE_ODD(6):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 6, oleaf6);
JU_DELETEINPLACE_ODD(oleaf6, INDEXES, ioffset, 6);
PrintLeaf("After ", ioffset, 6, oleaf6);
}
(void) puts("\nJU_DELETEINPLACE_ODD(7):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT;
PRINTLEAF("Before", ioffset, 7, oleaf7);
JU_DELETEINPLACE_ODD(oleaf7, INDEXES, ioffset, 7);
PrintLeaf("After ", ioffset, 7, oleaf7);
}
#endif // JU_64BIT
(void) puts("\nJU_INSERTCOPY():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, WSIZE, (uint8_t *) eleaf);
PRINTLEAF("Before, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
JU_INSERTCOPY(eleaf_2, eleaf, INDEXES, ioffset, eIndex);
PRINTLEAF("After, src ", ioffset, WSIZE, (uint8_t *) eleaf);
PrintLeaf("After, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
}
(void) puts("\nJU_INSERTCOPY3():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 3, oleaf3);
PRINTLEAF("Before, dest", ioffset, 3, oleaf3_2);
JU_INSERTCOPY3(oleaf3_2, oleaf3, INDEXES, ioffset, oIndex);
PRINTLEAF("After, src ", ioffset, 3, oleaf3);
PrintLeaf("After, dest", ioffset, 3, oleaf3_2);
}
#ifdef JU_64BIT
(void) puts("\nJU_INSERTCOPY5():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 5, oleaf5);
PRINTLEAF("Before, dest", ioffset, 5, oleaf5_2);
JU_INSERTCOPY5(oleaf5_2, oleaf5, INDEXES, ioffset, oIndex);
PRINTLEAF("After, src ", ioffset, 5, oleaf5);
PrintLeaf("After, dest", ioffset, 5, oleaf5_2);
}
(void) puts("\nJU_INSERTCOPY6():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 6, oleaf6);
PRINTLEAF("Before, dest", ioffset, 6, oleaf6_2);
JU_INSERTCOPY6(oleaf6_2, oleaf6, INDEXES, ioffset, oIndex);
PRINTLEAF("After, src ", ioffset, 6, oleaf6);
PrintLeaf("After, dest", ioffset, 6, oleaf6_2);
}
(void) puts("\nJU_INSERTCOPY7():");
for (ioffset = 0; ioffset <= INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 7, oleaf7);
PRINTLEAF("Before, dest", ioffset, 7, oleaf7_2);
JU_INSERTCOPY7(oleaf7_2, oleaf7, INDEXES, ioffset, oIndex);
PRINTLEAF("After, src ", ioffset, 7, oleaf7);
PrintLeaf("After, dest", ioffset, 7, oleaf7_2);
}
#endif // JU_64BIT
(void) puts("\nJU_DELETECOPY():");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, WSIZE, (uint8_t *) eleaf);
PRINTLEAF("Before, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
JU_DELETECOPY(eleaf_2, eleaf, INDEXES, ioffset, ignore);
PRINTLEAF("After, src ", ioffset, WSIZE, (uint8_t *) eleaf);
PrintLeaf("After, dest", ioffset, WSIZE, (uint8_t *) eleaf_2);
}
(void) puts("\nJU_DELETECOPY_ODD(3):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 3, oleaf3);
PRINTLEAF("Before, dest", ioffset, 3, oleaf3_2);
JU_DELETECOPY_ODD(oleaf3_2, oleaf3, INDEXES, ioffset, 3);
PRINTLEAF("After, src ", ioffset, 3, oleaf3);
PrintLeaf("After, dest", ioffset, 3, oleaf3_2);
}
#ifdef JU_64BIT
(void) puts("\nJU_DELETECOPY_ODD(5):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 5, oleaf5);
PRINTLEAF("Before, dest", ioffset, 5, oleaf5_2);
JU_DELETECOPY_ODD(oleaf5_2, oleaf5, INDEXES, ioffset, 5);
PRINTLEAF("After, src ", ioffset, 5, oleaf5);
PrintLeaf("After, dest", ioffset, 5, oleaf5_2);
}
(void) puts("\nJU_DELETECOPY_ODD(6):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 6, oleaf6);
PRINTLEAF("Before, dest", ioffset, 6, oleaf6_2);
JU_DELETECOPY_ODD(oleaf6_2, oleaf6, INDEXES, ioffset, 6);
PRINTLEAF("After, src ", ioffset, 6, oleaf6);
PrintLeaf("After, dest", ioffset, 6, oleaf6_2);
}
(void) puts("\nJU_DELETECOPY_ODD(7):");
for (ioffset = 0; ioffset < INDEXES; ++ioffset)
{
INIT2;
PRINTLEAF("Before, src ", ioffset, 7, oleaf7);
PRINTLEAF("Before, dest", ioffset, 7, oleaf7_2);
JU_DELETECOPY_ODD(oleaf7_2, oleaf7, INDEXES, ioffset, 7);
PRINTLEAF("After, src ", ioffset, 7, oleaf7);
PrintLeaf("After, dest", ioffset, 7, oleaf7_2);
}
#endif // JU_64BIT
return(0);
} // main()
#endif // TEST_INSDEL

View File

@ -0,0 +1,296 @@
// Copyright (C) 2000 - 2002 Hewlett-Packard Company
//
// This program is free software; you can redistribute it and/or modify it
// under the term of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
// for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
// _________________
// @(#) $Revision$ $Source$
#ifndef JU_WIN
#include <unistd.h> // unavailable on win_*.
#endif
#include <stdlib.h>
#include <stdio.h>
#if (! (defined(JUDY1) || defined(JUDYL)))
#error: One of -DJUDY1 or -DJUDYL must be specified.
#endif
#define TERMINATOR 999 // terminator for Alloc tables
#define BPW sizeof(Word_t) // define bytes per word
#ifdef JUDY1
#include "Judy1.h"
#else
#include "JudyL.h"
#endif
FILE *fd;
// Definitions come from header files Judy1.h and JudyL.h:
int AllocSizes[] = ALLOCSIZES;
#define ROUNDUP(BYTES,BPW,OFFSETW) \
((((BYTES) + (BPW) - 1) / (BPW)) + (OFFSETW))
// ****************************************************************************
// G E N T A B L E
//
// Note: "const" is required for newer compilers.
FUNCTION void GenTable(
const char * TableName, // name of table string
const char * TableSize, // dimentioned size string
int IndexBytes, // bytes per Index
int LeafSize, // number elements in object
int ValueBytes, // bytes per Value
int OffsetWords) // 1 for LEAFW
{
int * PAllocSizes = AllocSizes;
int OWord;
int CurWord;
int IWord;
int ii;
int BytesOfIndex;
int BytesOfObject;
int Index;
int LastWords;
int Words [1000] = { 0 };
int Offset[1000] = { 0 };
int MaxWords;
MaxWords = ROUNDUP((IndexBytes + ValueBytes) * LeafSize, BPW, OffsetWords);
Words[0] = 0;
Offset[0] = 0;
CurWord = TERMINATOR;
// Walk through all number of Indexes in table:
for (Index = 1; /* null */; ++Index)
{
// Calculate byte required for next size:
BytesOfIndex = IndexBytes * Index;
BytesOfObject = (IndexBytes + ValueBytes) * Index;
// Round up and calculate words required for next size:
OWord = ROUNDUP(BytesOfObject, BPW, OffsetWords);
IWord = ROUNDUP(BytesOfIndex, BPW, OffsetWords);
// Root-level leaves of population of 1 and 2 do not have the 1 word offset:
// Save minimum value of offset:
Offset[Index] = IWord;
// Round up to next available size of words:
while (OWord > *PAllocSizes) PAllocSizes++;
if (Index == LeafSize)
{
CurWord = Words[Index] = OWord;
break;
}
// end of available sizes ?
if (*PAllocSizes == TERMINATOR)
{
fprintf(stderr, "BUG, in %sPopToWords, sizes not big enough for object\n", TableName);
exit(1);
}
// Save words required and last word:
if (*PAllocSizes < MaxWords) { CurWord = Words[Index] = *PAllocSizes; }
else { CurWord = Words[Index] = MaxWords; }
} // for each index
LastWords = TERMINATOR;
// Round up to largest size in each group of malloc sizes:
for (ii = LeafSize; ii > 0; ii--)
{
if (LastWords > (Words[ii] - ii)) LastWords = Offset[ii];
else Offset[ii] = LastWords;
}
// Print the PopToWords[] table:
fprintf(fd,"\n//\tobject uses %d words\n", CurWord);
fprintf(fd,"//\t%s = %d\n", TableSize, LeafSize);
fprintf(fd,"const uint8_t\n");
fprintf(fd,"%sPopToWords[%s + 1] =\n", TableName, TableSize);
fprintf(fd,"{\n\t 0,");
for (ii = 1; ii <= LeafSize; ii++)
{
// 8 columns per line, starting with 1:
if ((ii % 8) == 1) fprintf(fd,"\n\t");
fprintf(fd,"%2d", Words[ii]);
// If not last number place comma:
if (ii != LeafSize) fprintf(fd,", ");
}
fprintf(fd,"\n};\n");
// Print the Offset table if needed:
if (! ValueBytes) return;
fprintf(fd,"const uint8_t\n");
fprintf(fd,"%sOffset[%s + 1] =\n", TableName, TableSize);
fprintf(fd,"{\n");
fprintf(fd,"\t 0,");
for (ii = 1; ii <= LeafSize; ii++)
{
if ((ii % 8) == 1) fprintf(fd,"\n\t");
fprintf(fd,"%2d", Offset[ii]);
if (ii != LeafSize) fprintf(fd,", ");
}
fprintf(fd,"\n};\n");
} // GenTable()
// ****************************************************************************
// M A I N
FUNCTION int main()
{
int ii;
#ifdef JUDY1
char *fname = "Judy1Tables.c";
#else
char *fname = "JudyLTables.c";
#endif
if ((fd = fopen(fname, "w")) == NULL){
perror("FATAL ERROR: could not write to Judy[1L]Tables.c file\n");
return (-1);
}
fprintf(fd,"// @(#) From generation tool: $Revision$ $Source$\n");
fprintf(fd,"//\n\n");
// ================================ Judy1 =================================
#ifdef JUDY1
fprintf(fd,"#include \"Judy1.h\"\n");
fprintf(fd,"// Leave the malloc() sizes readable in the binary (via "
"strings(1)):\n");
fprintf(fd,"const char * Judy1MallocSizes = \"Judy1MallocSizes =");
for (ii = 0; AllocSizes[ii] != TERMINATOR; ii++)
fprintf(fd," %d,", AllocSizes[ii]);
#ifndef JU_64BIT
fprintf(fd," Leaf1 = %d\";\n\n", cJ1_LEAF1_MAXPOP1);
#else
fprintf(fd,"\";\n\n"); // no Leaf1 in this case.
#endif
// ================================ 32 bit ================================
#ifndef JU_64BIT
GenTable("j__1_BranchBJP","cJU_BITSPERSUBEXPB", 8, cJU_BITSPERSUBEXPB,0,0);
GenTable("j__1_Leaf1", "cJ1_LEAF1_MAXPOP1", 1, cJ1_LEAF1_MAXPOP1, 0, 0);
GenTable("j__1_Leaf2", "cJ1_LEAF2_MAXPOP1", 2, cJ1_LEAF2_MAXPOP1, 0, 0);
GenTable("j__1_Leaf3", "cJ1_LEAF3_MAXPOP1", 3, cJ1_LEAF3_MAXPOP1, 0, 0);
GenTable("j__1_LeafW", "cJ1_LEAFW_MAXPOP1", 4, cJ1_LEAFW_MAXPOP1, 0, 1);
#endif
// ================================ 64 bit ================================
#ifdef JU_64BIT
GenTable("j__1_BranchBJP","cJU_BITSPERSUBEXPB",16, cJU_BITSPERSUBEXPB,0,0);
GenTable("j__1_Leaf2", "cJ1_LEAF2_MAXPOP1", 2, cJ1_LEAF2_MAXPOP1, 0, 0);
GenTable("j__1_Leaf3", "cJ1_LEAF3_MAXPOP1", 3, cJ1_LEAF3_MAXPOP1, 0, 0);
GenTable("j__1_Leaf4", "cJ1_LEAF4_MAXPOP1", 4, cJ1_LEAF4_MAXPOP1, 0, 0);
GenTable("j__1_Leaf5", "cJ1_LEAF5_MAXPOP1", 5, cJ1_LEAF5_MAXPOP1, 0, 0);
GenTable("j__1_Leaf6", "cJ1_LEAF6_MAXPOP1", 6, cJ1_LEAF6_MAXPOP1, 0, 0);
GenTable("j__1_Leaf7", "cJ1_LEAF7_MAXPOP1", 7, cJ1_LEAF7_MAXPOP1, 0, 0);
GenTable("j__1_LeafW", "cJ1_LEAFW_MAXPOP1", 8, cJ1_LEAFW_MAXPOP1, 0, 1);
#endif
#endif // JUDY1
// ================================ JudyL =================================
#ifdef JUDYL
fprintf(fd,"#include \"JudyL.h\"\n");
fprintf(fd,"// Leave the malloc() sizes readable in the binary (via "
"strings(1)):\n");
fprintf(fd,"const char * JudyLMallocSizes = \"JudyLMallocSizes =");
for (ii = 0; AllocSizes[ii] != TERMINATOR; ii++)
fprintf(fd," %d,", AllocSizes[ii]);
fprintf(fd," Leaf1 = %ld\";\n\n", (Word_t)cJL_LEAF1_MAXPOP1);
#ifndef JU_64BIT
// ================================ 32 bit ================================
GenTable("j__L_BranchBJP","cJU_BITSPERSUBEXPB", 8, cJU_BITSPERSUBEXPB, 0,0);
GenTable("j__L_Leaf1", "cJL_LEAF1_MAXPOP1", 1, cJL_LEAF1_MAXPOP1, BPW,0);
GenTable("j__L_Leaf2", "cJL_LEAF2_MAXPOP1", 2, cJL_LEAF2_MAXPOP1, BPW,0);
GenTable("j__L_Leaf3", "cJL_LEAF3_MAXPOP1", 3, cJL_LEAF3_MAXPOP1, BPW,0);
GenTable("j__L_LeafW", "cJL_LEAFW_MAXPOP1", 4, cJL_LEAFW_MAXPOP1, BPW,1);
GenTable("j__L_LeafV", "cJU_BITSPERSUBEXPL", 4, cJU_BITSPERSUBEXPL, 0,0);
#endif // 32 BIT
#ifdef JU_64BIT
// ================================ 64 bit ================================
GenTable("j__L_BranchBJP","cJU_BITSPERSUBEXPB",16, cJU_BITSPERSUBEXPB, 0,0);
GenTable("j__L_Leaf1", "cJL_LEAF1_MAXPOP1", 1, cJL_LEAF1_MAXPOP1, BPW,0);
GenTable("j__L_Leaf2", "cJL_LEAF2_MAXPOP1", 2, cJL_LEAF2_MAXPOP1, BPW,0);
GenTable("j__L_Leaf3", "cJL_LEAF3_MAXPOP1", 3, cJL_LEAF3_MAXPOP1, BPW,0);
GenTable("j__L_Leaf4", "cJL_LEAF4_MAXPOP1", 4, cJL_LEAF4_MAXPOP1, BPW,0);
GenTable("j__L_Leaf5", "cJL_LEAF5_MAXPOP1", 5, cJL_LEAF5_MAXPOP1, BPW,0);
GenTable("j__L_Leaf6", "cJL_LEAF6_MAXPOP1", 6, cJL_LEAF6_MAXPOP1, BPW,0);
GenTable("j__L_Leaf7", "cJL_LEAF7_MAXPOP1", 7, cJL_LEAF7_MAXPOP1, BPW,0);
GenTable("j__L_LeafW", "cJL_LEAFW_MAXPOP1", 8, cJL_LEAFW_MAXPOP1, BPW,1);
GenTable("j__L_LeafV", "cJU_BITSPERSUBEXPL", 8, cJU_BITSPERSUBEXPL, 0,0);
#endif // 64 BIT
#endif // JUDYL
fclose(fd);
return(0);
} // main()

View File

@ -0,0 +1,6 @@
INCLUDES = -I. -I..
AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@
noinst_LTLIBRARIES = libJudyMalloc.la
libJudyMalloc_la_SOURCES = JudyMalloc.c

View File

@ -0,0 +1,430 @@
# Makefile.in generated by automake 1.9.3 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libJudyMalloc_la_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
subdir = src/JudyCommon
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libJudyMalloc_la_LIBADD =
am_libJudyMalloc_la_OBJECTS = JudyMalloc.lo
libJudyMalloc_la_OBJECTS = $(am_libJudyMalloc_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libJudyMalloc_la_SOURCES)
DIST_SOURCES = $(libJudyMalloc_la_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
FLAVOR = @FLAVOR@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
VERSION_INFO = @VERSION_INFO@
WARN_CFLAGS = @WARN_CFLAGS@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_LD = @ac_ct_LD@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
INCLUDES = -I. -I..
AM_CFLAGS = @CFLAGS@ @WARN_CFLAGS@
noinst_LTLIBRARIES = libJudyMalloc.la
libJudyMalloc_la_SOURCES = JudyMalloc.c
all: all-am
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/JudyCommon/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/JudyCommon/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLTLIBRARIES:
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libJudyMalloc.la: $(libJudyMalloc_la_OBJECTS) $(libJudyMalloc_la_DEPENDENCIES)
$(LINK) $(libJudyMalloc_la_LDFLAGS) $(libJudyMalloc_la_OBJECTS) $(libJudyMalloc_la_LIBADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/JudyMalloc.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LTLIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
mostlyclean-am
distclean: distclean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-tags distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-info-am
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,66 @@
# @(#) $Revision$ $Source$
#
# This tree contains sources for Judy common files. These include shared
# header files, ifdef'd common source files for Judy1/JudyL functions, and
# shared utility functions.
# SHARED HEADER FILES:
JudyPrivate.h global private header file for all Judy internal
sources
JudyPrivateBranch.h global private header file for all Judy internal
sources, specifically for branch-related
declarations
JudyPrivate1L.h global private header file for Judy internal
sources that generate both Judy1 and JudyL
object files, via -DJUDY1 or -DJUDYL, using
common names for JP Types, plus some other
generic declarations too
# IFDEF'D COMMON SOURCE FILES FOR JUDY1/JUDYL FUNCTIONS:
#
# See Judy(3C) manual entry about these sources for exported functions.
JudyGet.c common code for Judy1Test() and JudyLGet()
JudyIns.c common code for Judy1Set() and JudyLIns()
JudyDel.c common code for Judy1Unset() and JudyLDel()
JudyFirst.c common code for Judy1 and JudyL
JudyPrevNext.c common code for Judy1, JudyL; Judy*Prev(), Judy*Next()
JudyPrevNextEmpty.c common code for Judy1, JudyL; Judy*PrevEmpty(),
Judy*NextEmpty()
JudyCount.c common code for Judy1 and JudyL
JudyByCount.c common code for Judy1 and JudyL
JudyFreeArray.c common code for Judy1 and JudyL
JudyMemUsed.c common code for Judy1 and JudyL
JudyMemActive.c common code for Judy1 and JudyL
JudyInsArray.c common code for Judy1 and JudyL
# SHARED UTILITY FUNCTIONS:
JudyMalloc.c source file
JudyTables.c static definitions of translation tables; a main
program is #ifdef-embedded to generate these tables
# Common code for Judy1 and JudyL that is compiled twice with -DJUDY1 or
# -DJUDYL:
JudyInsertBranch.c insert a linear branch between a branch and a leaf
JudyCreateBranch.c create and copy all types of branches
JudyCascade.c handles overflow insertion of an Index, including
common Decode bytes and branch creation
JudyDecascade.c handles underflow deletion of an Index, including
common Decode bytes and branch deletion
JudyMallocIF.c a Judy malloc/free interface, for statistics and
debugging
JudyPrintJP.c debug/trace code #included in other *.c files