exhaust: move functions to report.h

This commit is contained in:
Justin Viiret
2016-05-26 14:21:40 +10:00
committed by Matthew Barr
parent 9b7eca5400
commit 6e49544558
4 changed files with 69 additions and 72 deletions

View File

@@ -33,47 +33,9 @@
#ifndef EXHAUST_H
#define EXHAUST_H
#include "rose/rose_internal.h"
#include "util/multibit.h"
#include "ue2common.h"
/** Index meaning a given exhaustion key is invalid. */
#define INVALID_EKEY (~(u32)0)
/** \brief Test whether the given key (\a ekey) is set in the exhaustion vector
* \a evec. */
static really_inline
int isExhausted(const struct RoseEngine *t, const char *evec, u32 ekey) {
DEBUG_PRINTF("checking exhaustion %p %u\n", evec, ekey);
assert(ekey != INVALID_EKEY);
assert(ekey < t->ekeyCount);
return mmbit_isset((const u8 *)evec, t->ekeyCount, ekey);
}
/** \brief Returns 1 if all exhaustion keys in the bitvector are on. */
static really_inline
int isAllExhausted(const struct RoseEngine *t, const char *evec) {
if (!t->canExhaust) {
return 0; /* pattern set is inexhaustible */
}
return mmbit_all((const u8 *)evec, t->ekeyCount);
}
/** \brief Mark key \a ekey on in the exhaustion vector. */
static really_inline
void markAsMatched(const struct RoseEngine *t, char *evec, u32 ekey) {
DEBUG_PRINTF("marking as exhausted key %u\n", ekey);
assert(ekey != INVALID_EKEY);
assert(ekey < t->ekeyCount);
mmbit_set((u8 *)evec, t->ekeyCount, ekey);
}
/** \brief Clear all keys in the exhaustion vector. */
static really_inline
void clearEvec(const struct RoseEngine *t, char *evec) {
DEBUG_PRINTF("clearing evec %p %u\n", evec, t->ekeyCount);
mmbit_clear((u8 *)evec, t->ekeyCount);
}
#endif