Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/src/JudyCommon/JudyPrivateBranch.h view on Meta::CPAN
// 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.
( run in 0.734 second using v1.01-cache-2.11-cpan-df04353d9ac )