Alien-Judy
view release on metacpan or search on metacpan
src/judy-1.0.5/src/Judy.h view on Meta::CPAN
JU_ERRNO_NONE = 0,
JU_ERRNO_FULL = 1,
JU_ERRNO_NFMAX = JU_ERRNO_FULL,
// JU_ERRNO_NOMEM comes from malloc(3C) when Judy cannot obtain needed memory.
// The system errno value is also set to ENOMEM. This error can be recoverable
// if the calling application frees other memory.
//
// TBD: Currently there is no guarantee the Judy array has no memory leaks
// upon JU_ERRNO_NOMEM.
JU_ERRNO_NOMEM = 2,
// Problems with parameters from the calling program:
//
// JU_ERRNO_NULLPPARRAY means PPArray was null; perhaps PArray was passed where
// &PArray was intended. Similarly, JU_ERRNO_NULLPINDEX means PIndex was null;
// perhaps &Index was intended. Also, JU_ERRNO_NONNULLPARRAY,
// JU_ERRNO_NULLPVALUE, and JU_ERRNO_UNSORTED, all added later (hence with
// higher numbers), mean: A non-null array was passed in where a null pointer
// was required; PValue was null; and unsorted indexes were detected.
JU_ERRNO_NULLPPARRAY = 3, // see above.
JU_ERRNO_NONNULLPARRAY = 10, // see above.
JU_ERRNO_NULLPINDEX = 4, // see above.
JU_ERRNO_NULLPVALUE = 11, // see above.
JU_ERRNO_NOTJUDY1 = 5, // PArray is not to a Judy1 array.
JU_ERRNO_NOTJUDYL = 6, // PArray is not to a JudyL array.
JU_ERRNO_NOTJUDYSL = 7, // PArray is not to a JudySL array.
JU_ERRNO_UNSORTED = 12, // see above.
// Errors below this point are not recoverable; further tries to access the
// Judy array might result in EFAULT and a core dump:
//
// JU_ERRNO_OVERRUN occurs when Judy detects, upon reallocation, that a block
// of memory in its own freelist was modified since being freed.
JU_ERRNO_OVERRUN = 8,
// JU_ERRNO_CORRUPT occurs when Judy detects an impossible value in a Judy data
// structure:
//
// Note: The Judy data structure contains some redundant elements that support
// this type of checking.
JU_ERRNO_CORRUPT = 9
// Warning: At least some C or C++ compilers do not tolerate a trailing comma
// above here. At least we know of one case, in aCC; see JAGad58928.
} JU_Errno_t;
// Judy errno structure:
//
// WARNING: For compatibility with possible future changes, the fields of this
// struct should not be referenced directly. Instead use the macros supplied
// below.
// This structure should be declared on the stack in a threaded process.
typedef struct J_UDY_ERROR_STRUCT
{
JU_Errno_t je_Errno; // one of the enums above.
int je_ErrID; // often an internal source line number.
Word_t je_reserved[4]; // for future backward compatibility.
} JError_t, * PJError_t;
// Related macros:
//
// Fields from error struct:
#define JU_ERRNO(PJError) ((PJError)->je_Errno)
#define JU_ERRID(PJError) ((PJError)->je_ErrID)
// For checking return values from various Judy functions:
//
// Note: Define JERR as -1, not as the seemingly more portable (Word_t)
// (~0UL), to avoid a compiler "overflow in implicit constant conversion"
// warning.
#define JERR (-1) /* functions returning int or Word_t */
#define PJERR ((Pvoid_t) (~0UL)) /* mainly for use here, see below */
#define PPJERR ((PPvoid_t) (~0UL)) /* functions that return PPvoid_t */
// Convenience macro for when detailed error information (PJError_t) is not
// desired by the caller; a purposely short name:
#define PJE0 ((PJError_t) NULL)
// ****************************************************************************
// JUDY FUNCTIONS:
//
// P_JE is a shorthand for use below:
#define P_JE PJError_t PJError
// ****************************************************************************
// JUDY1 FUNCTIONS:
extern int Judy1Test( Pcvoid_t PArray, Word_t Index, P_JE);
extern int Judy1Set( PPvoid_t PPArray, Word_t Index, P_JE);
extern int Judy1SetArray( PPvoid_t PPArray, Word_t Count,
const Word_t * const PIndex,
P_JE);
extern int Judy1Unset( PPvoid_t PPArray, Word_t Index, P_JE);
extern Word_t Judy1Count( Pcvoid_t PArray, Word_t Index1,
Word_t Index2, P_JE);
extern int Judy1ByCount( Pcvoid_t PArray, Word_t Count,
Word_t * PIndex, P_JE);
extern Word_t Judy1FreeArray( PPvoid_t PPArray, P_JE);
extern Word_t Judy1MemUsed( Pcvoid_t PArray);
extern Word_t Judy1MemActive( Pcvoid_t PArray);
extern int Judy1First( Pcvoid_t PArray, Word_t * PIndex, P_JE);
extern int Judy1Next( Pcvoid_t PArray, Word_t * PIndex, P_JE);
extern int Judy1Last( Pcvoid_t PArray, Word_t * PIndex, P_JE);
extern int Judy1Prev( Pcvoid_t PArray, Word_t * PIndex, P_JE);
src/judy-1.0.5/src/Judy.h view on Meta::CPAN
#define J_1P(Rc,PArray,Index,Func,FuncName) \
{ \
JError_t J_Error; \
if (((Rc) = (Pvoid_t) Func(PArray, Index, &J_Error)) == PJERR) \
J_E(FuncName, &J_Error); \
}
#define J_2I(Rc,PArray,Index,Arg2,Func,FuncName) \
{ \
JError_t J_Error; \
if (((Rc) = Func(PArray, Index, Arg2, &J_Error)) == JERR) \
J_E(FuncName, &J_Error); \
}
// Variation for Judy*Count functions, which return 0, not JERR, for error (and
// also for other non-error cases):
//
// Note: JU_ERRNO_NFMAX should only apply to 32-bit Judy1, but this header
// file lacks the necessary ifdefs to make it go away otherwise, so always
// check against it.
#define J_2C(Rc,PArray,Index1,Index2,Func,FuncName) \
{ \
JError_t J_Error; \
if ((((Rc) = Func(PArray, Index1, Index2, &J_Error)) == 0) \
&& (JU_ERRNO(&J_Error) > JU_ERRNO_NFMAX)) \
{ \
J_E(FuncName, &J_Error); \
} \
}
#define J_2P(PV,PArray,Index,Arg2,Func,FuncName) \
{ \
JError_t J_Error; \
if (((PV) = (Pvoid_t) Func(PArray, Index, Arg2, &J_Error)) \
== PJERR) J_E(FuncName, &J_Error); \
}
// Variations for Judy*Set/InsArray functions:
#define J_2AI(Rc,PArray,Count,PIndex,Func,FuncName) \
{ \
JError_t J_Error; \
if (((Rc) = Func(PArray, Count, PIndex, &J_Error)) == JERR) \
J_E(FuncName, &J_Error); \
}
#define J_3AI(Rc,PArray,Count,PIndex,PValue,Func,FuncName) \
{ \
JError_t J_Error; \
if (((Rc) = Func(PArray, Count, PIndex, PValue, &J_Error)) \
== JERR) J_E(FuncName, &J_Error); \
}
#endif /* ================ ! JUDYERROR_NOTEST ============================= */
// Some of the macros are special cases that use inlined shortcuts for speed
// with root-level leaves:
// This is a slower version with current processors, but in the future...
#define J1T(Rc,PArray,Index) \
(Rc) = Judy1Test((Pvoid_t)(PArray), Index, PJE0)
#define J1S( Rc, PArray, Index) \
J_1I(Rc, (&(PArray)), Index, Judy1Set, "Judy1Set")
#define J1SA(Rc, PArray, Count, PIndex) \
J_2AI(Rc,(&(PArray)), Count, PIndex, Judy1SetArray, "Judy1SetArray")
#define J1U( Rc, PArray, Index) \
J_1I(Rc, (&(PArray)), Index, Judy1Unset, "Judy1Unset")
#define J1F( Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1First, "Judy1First")
#define J1N( Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1Next, "Judy1Next")
#define J1L( Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1Last, "Judy1Last")
#define J1P( Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1Prev, "Judy1Prev")
#define J1FE(Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1FirstEmpty, "Judy1FirstEmpty")
#define J1NE(Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1NextEmpty, "Judy1NextEmpty")
#define J1LE(Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1LastEmpty, "Judy1LastEmpty")
#define J1PE(Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), Judy1PrevEmpty, "Judy1PrevEmpty")
#define J1C( Rc, PArray, Index1, Index2) \
J_2C(Rc, PArray, Index1, Index2, Judy1Count, "Judy1Count")
#define J1BC(Rc, PArray, Count, Index) \
J_2I(Rc, PArray, Count, &(Index), Judy1ByCount, "Judy1ByCount")
#define J1FA(Rc, PArray) \
J_0I(Rc, (&(PArray)), Judy1FreeArray, "Judy1FreeArray")
#define J1MU(Rc, PArray) \
(Rc) = Judy1MemUsed(PArray)
#define JLG(PV,PArray,Index) \
(PV) = (Pvoid_t)JudyLGet((Pvoid_t)PArray, Index, PJE0)
#define JLI( PV, PArray, Index) \
J_1P(PV, (&(PArray)), Index, JudyLIns, "JudyLIns")
#define JLIA(Rc, PArray, Count, PIndex, PValue) \
J_3AI(Rc,(&(PArray)), Count, PIndex, PValue, JudyLInsArray, \
"JudyLInsArray")
#define JLD( Rc, PArray, Index) \
J_1I(Rc, (&(PArray)), Index, JudyLDel, "JudyLDel")
#define JLF( PV, PArray, Index) \
J_1P(PV, PArray, &(Index), JudyLFirst, "JudyLFirst")
#define JLN( PV, PArray, Index) \
J_1P(PV, PArray, &(Index), JudyLNext, "JudyLNext")
#define JLL( PV, PArray, Index) \
J_1P(PV, PArray, &(Index), JudyLLast, "JudyLLast")
#define JLP( PV, PArray, Index) \
J_1P(PV, PArray, &(Index), JudyLPrev, "JudyLPrev")
#define JLFE(Rc, PArray, Index) \
J_1I(Rc, PArray, &(Index), JudyLFirstEmpty, "JudyLFirstEmpty")
#define JLNE(Rc, PArray, Index) \
( run in 0.472 second using v1.01-cache-2.11-cpan-39bf76dae61 )