Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/src/JudyCommon/JudyPrivate.h view on Meta::CPAN
Note that this example shows every possibly topology to reach a leaf in a
32-bit Judy SM, although this is a very subtle point!
STATE or`
LEVEL
+---+ +---+ +---+ +---+ +---+ +---+ +---+ +---+
|RJP| |RJP| |RJP| |RJP| |RJP| |RJP| |RJP| |RJP|
L---+ B---+ B---+ B---+ B---+ B---+ B---+ B---+
| | | | | | | |
| | | | | | | |
V V (2) V (2) V (2) V (2) V (2) V (2) V (2)
+------ +------ +------ +------ +------ +------ +------ +------
Four |< 2 > | 0 | 4* | C | 4* | 4* | C | C
byte |< 4 > | 0 | 0 | C | 1* | C | C | C 4
Index|< 1 > | C | C | C | C | C | C | C
Leaf |< 3 > | 3 | 2 | 3 | 1 | 2 | 3 | 3
+------ +--L--- +--L--- +--B--- +--L--- +--B--- +--B--- +--B---
| | | | | | |
/ | / | | / /
/ | / | | / /
| | | | | | |
V | V (4) | | V (4) V (4)
+------ | +------ | | +------ +------
Three |< 4 > | | 4+ | | | 4+ | 4+
byte Index|< 1 > O | 0 O O | 1* | C 3
Leaf |< 3 > | | C | | | C | C
+------ | | 2 | | | 1 | 2
/ +----L- | | +----L- +----B-
/ | | | | |
| / | / / /
| / | / / /
| / | | / /
| / | | / /
| | | | | |
V V | V(1) | V(1)
+------ +------ | +------ | +------
Two byte |< 1 > |< 1 > | | 4+ | | 4+
Index Leaf |< 3 > |< 3 > O | 1+ O | 1+ 2
+------ +------ / | C | | C
/ | 1 | | 1
| +-L---- | +-L----
| | | |
| / | /
| | | |
V V V V
+------ +------ +------ +------
One byte Index Leaf |< 3 > |< 3 > |< 3 > |< 3 > 1
+------ +------ +------ +------
#endif // A_PICTURE_IS_WORTH_1000_WORDS
// ****************************************************************************
// MISCELLANEOUS GLOBALS:
//
// PLATFORM-SPECIFIC CONVENIENCE MACROS:
//
// These are derived from context (set by cc or in system header files) or
// based on JU_<PLATFORM> macros from make_includes/platform.*.mk. We decided
// on 011018 that any macro reliably derivable from context (cc or headers) for
// ALL platforms supported by Judy is based on that derivation, but ANY
// exception means to stop using the external macro completely and derive from
// JU_<PLATFORM> instead.
// Other miscellaneous stuff:
#ifndef _BOOL_T
#define _BOOL_T
typedef int bool_t;
#endif
#define FUNCTION // null; easy to find functions.
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifdef TRACE // turn on all other tracing in the code:
#define TRACEJP 1 // JP traversals in JudyIns.c and JudyDel.c.
#define TRACEJPR 1 // JP traversals in retrieval code, JudyGet.c.
#define TRACECF 1 // cache fills in JudyGet.c.
#define TRACEMI 1 // malloc calls in JudyMallocIF.c.
#define TRACEMF 1 // malloc calls at a lower level in JudyMalloc.c.
#endif
// SUPPORT FOR DEBUG-ONLY CODE:
//
// By convention, use -DDEBUG to enable both debug-only code AND assertions in
// the Judy sources.
//
// Invert the sense of assertions, so they are off unless explicitly requested,
// in a uniform way.
//
// Note: It is NOT appropriate to put this in Judy.h; it would mess up
// application code.
#ifndef DEBUG
#define NDEBUG 1 // must be 1 for "#if".
#endif
// Shorthand notations to avoid #ifdefs for single-line conditional statements:
//
// Warning: These cannot be used around compiler directives, such as
// "#include", nor in the case where Code contains a comma other than nested
// within parentheses or quotes.
#ifndef DEBUG
#define DBGCODE(Code) // null.
#else
#define DBGCODE(Code) Code
#endif
#ifdef JUDY1
#define JUDY1CODE(Code) Code
src/judy-1.0.5/src/JudyCommon/JudyPrivate.h view on Meta::CPAN
(PDEST)[i_dx + 0 + 7] = (PSOURCE)[i_dx + 0]; \
(PDEST)[i_dx + 1 + 7] = (PSOURCE)[i_dx + 1]; \
(PDEST)[i_dx + 2 + 7] = (PSOURCE)[i_dx + 2]; \
(PDEST)[i_dx + 3 + 7] = (PSOURCE)[i_dx + 3]; \
(PDEST)[i_dx + 4 + 7] = (PSOURCE)[i_dx + 4]; \
(PDEST)[i_dx + 5 + 7] = (PSOURCE)[i_dx + 5]; \
(PDEST)[i_dx + 6 + 7] = (PSOURCE)[i_dx + 6]; \
} \
}
#endif // JU_64BIT
// Counterparts to the above for deleting an Index:
#define JU_DELETECOPY(PDEST,PSOURCE,POP1,OFFSET,IGNORE) \
assert((long) (POP1) > 0); \
assert((Word_t) (OFFSET) < (Word_t) (POP1)); \
{ \
Word_t i_offset; \
\
for (i_offset = 0; i_offset < (OFFSET); ++i_offset) \
(PDEST)[i_offset] = (PSOURCE)[i_offset]; \
\
for (++i_offset; i_offset < (POP1); ++i_offset) \
(PDEST)[i_offset - 1] = (PSOURCE)[i_offset]; \
}
// Variation for odd-byte-sized (non-native) Indexes, where cIS = Index Size;
// copy byte-by-byte:
//
// Note: There are no endian issues here because bytes are just shifted as-is,
// not converted to/from an Index.
//
// Note: If cIS == 1, JU_DELETECOPY_ODD == JU_DELETECOPY, at least in concept.
#define JU_DELETECOPY_ODD(PDEST,PSOURCE,POP1,OFFSET,cIS) \
assert((long) (POP1) > 0); \
assert((Word_t) (OFFSET) < (Word_t) (POP1)); \
{ \
uint8_t *_Pdest = (uint8_t *) (PDEST); \
uint8_t *_Psource = (uint8_t *) (PSOURCE); \
Word_t b_off; \
\
for (b_off = 0; b_off < ((OFFSET) * (cIS)); ++b_off) \
*_Pdest++ = *_Psource++; \
\
_Psource += (cIS); \
\
for (b_off += (cIS); b_off < ((POP1) * (cIS)); ++b_off) \
*_Pdest++ = *_Psource++; \
}
// GENERIC RETURN CODE HANDLING FOR JUDY1 (NO VALUE AREAS) AND JUDYL (VALUE
// AREAS):
//
// This common code hides Judy1 versus JudyL details of how to return various
// conditions, including a pointer to a value area for JudyL.
//
// First, define an internal variation of JERR called JERRI (I = int) to make
// lint happy. We accidentally shipped to 11.11 OEUR with all functions that
// return int or Word_t using JERR, which is type Word_t, for errors. Lint
// complains about this for functions that return int. So, internally use
// JERRI for error returns from the int functions. Experiments show that
// callers which compare int Foo() to (Word_t) JERR (~0UL) are OK, since JERRI
// sign-extends to match JERR.
#define JERRI ((int) ~0) // see above.
#ifdef JUDY1
#define JU_RET_FOUND return(1)
#define JU_RET_NOTFOUND return(0)
// For Judy1, these all "fall through" to simply JU_RET_FOUND, since there is no
// value area pointer to return:
#define JU_RET_FOUND_LEAFW(PJLW,POP1,OFFSET) JU_RET_FOUND
#define JU_RET_FOUND_JPM(Pjpm) JU_RET_FOUND
#define JU_RET_FOUND_PVALUE(Pjv,OFFSET) JU_RET_FOUND
#ifndef JU_64BIT
#define JU_RET_FOUND_LEAF1(Pjll,POP1,OFFSET) JU_RET_FOUND
#endif
#define JU_RET_FOUND_LEAF2(Pjll,POP1,OFFSET) JU_RET_FOUND
#define JU_RET_FOUND_LEAF3(Pjll,POP1,OFFSET) JU_RET_FOUND
#ifdef JU_64BIT
#define JU_RET_FOUND_LEAF4(Pjll,POP1,OFFSET) JU_RET_FOUND
#define JU_RET_FOUND_LEAF5(Pjll,POP1,OFFSET) JU_RET_FOUND
#define JU_RET_FOUND_LEAF6(Pjll,POP1,OFFSET) JU_RET_FOUND
#define JU_RET_FOUND_LEAF7(Pjll,POP1,OFFSET) JU_RET_FOUND
#endif
#define JU_RET_FOUND_IMM_01(Pjp) JU_RET_FOUND
#define JU_RET_FOUND_IMM(Pjp,OFFSET) JU_RET_FOUND
// Note: No JudyL equivalent:
#define JU_RET_FOUND_FULLPOPU1 JU_RET_FOUND
#define JU_RET_FOUND_LEAF_B1(PJLB,SUBEXP,OFFSET) JU_RET_FOUND
#else // JUDYL
// JU_RET_FOUND // see below; must NOT be defined for JudyL.
#define JU_RET_NOTFOUND return((PPvoid_t) NULL)
// For JudyL, the location of the value area depends on the JP type and other
// factors:
//
// TBD: The value areas should be accessed via data structures, here and in
// Dougs code, not by hard-coded address calculations.
//
// This is useful in insert/delete code when the value area is returned from
// lower levels in the JPM:
#define JU_RET_FOUND_JPM(Pjpm) return((PPvoid_t) ((Pjpm)->jpm_PValue))
// This is useful in insert/delete code when the value area location is already
// computed:
#define JU_RET_FOUND_PVALUE(Pjv,OFFSET) return((PPvoid_t) ((Pjv) + OFFSET))
( run in 1.220 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )