nfa: unify NfaCallback and SomNfaCallback

Use just one callback type, with both start and end offsets.
This commit is contained in:
Justin Viiret
2016-06-24 16:22:43 +10:00
committed by Matthew Barr
parent 9087d59be5
commit cf9e40ae1c
29 changed files with 103 additions and 234 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -53,14 +53,8 @@
* are 0, which means 'stop running the engine' or non-zero, which means
* 'continue matching'.
*/
typedef int (*NfaCallback)(u64a offset, ReportID id, void *context);
/** \brief The type for an NFA callback which also tracks start of match.
*
* see \ref NfaCallback
*/
typedef int (*SomNfaCallback)(u64a from_offset, u64a to_offset, ReportID id,
void *context);
typedef int (*NfaCallback)(u64a from_offset, u64a to_offset, ReportID id,
void *context);
/**
* standard \ref NfaCallback return value indicating that engine execution

View File

@@ -98,7 +98,7 @@ char subCastleReportCurrent(const struct Castle *c, struct mq *q,
if (match == REPEAT_MATCH) {
DEBUG_PRINTF("firing match at %llu for sub %u, report %u\n", offset,
subIdx, sub->report);
if (q->cb(offset, sub->report, q->context) == MO_HALT_MATCHING) {
if (q->cb(0, offset, sub->report, q->context) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;
}
}
@@ -457,7 +457,7 @@ char subCastleFireMatch(const struct Castle *c, const void *full_state,
i = mmbit_iterate(matching, c->numRepeats, i)) {
const struct SubCastle *sub = getSubCastle(c, i);
DEBUG_PRINTF("firing match at %llu for sub %u\n", offset, i);
if (cb(offset, sub->report, ctx) == MO_HALT_MATCHING) {
if (cb(0, offset, sub->report, ctx) == MO_HALT_MATCHING) {
DEBUG_PRINTF("caller told us to halt\n");
return MO_HALT_MATCHING;
}

View File

@@ -110,7 +110,7 @@ u64a expandSomValue(u32 comp_slot_width, u64a curr_offset,
}
static really_inline
char doReports(SomNfaCallback cb, void *ctxt, const struct mcclellan *m,
char doReports(NfaCallback cb, void *ctxt, const struct mcclellan *m,
const struct gough_som_info *som, u16 s, u64a loc,
char eod, u16 * const cached_accept_state,
u32 * const cached_accept_id, u32 * const cached_accept_som) {
@@ -307,7 +307,7 @@ u16 goughEnableStarts(const struct mcclellan *m, u16 s, u64a som_offset,
static really_inline
char goughExec16_i(const struct mcclellan *m, struct gough_som_info *som,
u16 *state, const u8 *buf, size_t len, u64a offAdj,
SomNfaCallback cb, void *ctxt, const u8 **c_final,
NfaCallback cb, void *ctxt, const u8 **c_final,
enum MatchMode mode) {
assert(ISALIGNED_N(state, 2));
@@ -461,7 +461,7 @@ with_accel:
static really_inline
char goughExec8_i(const struct mcclellan *m, struct gough_som_info *som,
u8 *state, const u8 *buf, size_t len, u64a offAdj,
SomNfaCallback cb, void *ctxt, const u8 **c_final,
NfaCallback cb, void *ctxt, const u8 **c_final,
enum MatchMode mode) {
u8 s = *state;
const u8 *c = buf, *c_end = buf + len;
@@ -595,7 +595,7 @@ with_accel:
static never_inline
char goughExec8_i_ni(const struct mcclellan *m, struct gough_som_info *som,
u8 *state, const u8 *buf, size_t len, u64a offAdj,
SomNfaCallback cb, void *ctxt, const u8 **final_point,
NfaCallback cb, void *ctxt, const u8 **final_point,
enum MatchMode mode) {
return goughExec8_i(m, som, state, buf, len, offAdj, cb, ctxt, final_point,
mode);
@@ -604,7 +604,7 @@ char goughExec8_i_ni(const struct mcclellan *m, struct gough_som_info *som,
static never_inline
char goughExec16_i_ni(const struct mcclellan *m, struct gough_som_info *som,
u16 *state, const u8 *buf, size_t len, u64a offAdj,
SomNfaCallback cb, void *ctxt, const u8 **final_point,
NfaCallback cb, void *ctxt, const u8 **final_point,
enum MatchMode mode) {
return goughExec16_i(m, som, state, buf, len, offAdj, cb, ctxt, final_point,
mode);
@@ -622,7 +622,7 @@ const struct gough_som_info *getSomInfoConst(const char *state_base) {
static really_inline
char nfaExecGough8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
const u8 *hend, SomNfaCallback cb, void *context,
const u8 *hend, NfaCallback cb, void *context,
struct mq *q, s64a end, enum MatchMode mode) {
DEBUG_PRINTF("enter\n");
struct gough_som_info *som = getSomInfo(q->state);
@@ -755,7 +755,7 @@ char nfaExecGough8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
static really_inline
char nfaExecGough16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
const u8 *hend, SomNfaCallback cb, void *context,
const u8 *hend, NfaCallback cb, void *context,
struct mq *q, s64a end, enum MatchMode mode) {
struct gough_som_info *som = getSomInfo(q->state);
assert(n->type == GOUGH_NFA_16);
@@ -887,7 +887,7 @@ char nfaExecGough16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_8);
const u8 *hend = q->history + q->hlength;
@@ -899,7 +899,7 @@ char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end) {
char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_16);
const u8 *hend = q->history + q->hlength;
@@ -911,7 +911,7 @@ char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end) {
char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_8);
const u8 *hend = q->history + q->hlength;
@@ -923,7 +923,7 @@ char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end) {
char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_16);
const u8 *hend = q->history + q->hlength;
@@ -935,7 +935,7 @@ char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end) {
char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_8);
const u8 *hend = q->history + q->hlength;
@@ -952,7 +952,7 @@ char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report) {
char nfaExecGough16_QR(const struct NFA *n, struct mq *q, ReportID report) {
u64a offset = q->offset;
const u8 *buffer = q->buffer;
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *context = q->context;
assert(n->type == GOUGH_NFA_16);
const u8 *hend = q->history + q->hlength;
@@ -994,7 +994,7 @@ char nfaExecGough16_initCompressedState(const struct NFA *nfa, u64a offset,
char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *ctxt = q->context;
u8 s = *(u8 *)q->state;
u64a offset = q_cur_offset(q);
@@ -1016,7 +1016,7 @@ char nfaExecGough8_reportCurrent(const struct NFA *n, struct mq *q) {
char nfaExecGough16_reportCurrent(const struct NFA *n, struct mq *q) {
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(n);
SomNfaCallback cb = q->som_cb;
NfaCallback cb = q->cb;
void *ctxt = q->context;
u16 s = *(u16 *)q->state;
const struct mstate_aux *aux = get_aux(m, s);
@@ -1059,7 +1059,7 @@ char nfaExecGough16_inAnyAccept(const struct NFA *n, struct mq *q) {
static
char goughCheckEOD(const struct NFA *nfa, u16 s,
const struct gough_som_info *som,
u64a offset, SomNfaCallback cb, void *ctxt) {
u64a offset, NfaCallback cb, void *ctxt) {
const struct mcclellan *m = (const struct mcclellan *)getImplNfa(nfa);
const struct mstate_aux *aux = get_aux(m, s);
@@ -1070,21 +1070,19 @@ char goughCheckEOD(const struct NFA *nfa, u16 s,
}
char nfaExecGough8_testEOD(const struct NFA *nfa, const char *state,
UNUSED const char *streamState, u64a offset,
UNUSED NfaCallback callback,
SomNfaCallback som_callback, void *context) {
UNUSED const char *streamState, u64a offset,
NfaCallback callback, void *context) {
const struct gough_som_info *som = getSomInfoConst(state);
return goughCheckEOD(nfa, *(const u8 *)state, som, offset, som_callback,
return goughCheckEOD(nfa, *(const u8 *)state, som, offset, callback,
context);
}
char nfaExecGough16_testEOD(const struct NFA *nfa, const char *state,
UNUSED const char *streamState, u64a offset,
UNUSED NfaCallback callback,
SomNfaCallback som_callback, void *context) {
UNUSED const char *streamState, u64a offset,
NfaCallback callback, void *context) {
assert(ISALIGNED_N(state, 8));
const struct gough_som_info *som = getSomInfoConst(state);
return goughCheckEOD(nfa, *(const u16 *)state, som, offset, som_callback,
return goughCheckEOD(nfa, *(const u16 *)state, som, offset, callback,
context);
}

View File

@@ -39,8 +39,7 @@ struct mq;
char nfaExecGough8_testEOD(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
char nfaExecGough8_Q(const struct NFA *n, struct mq *q, s64a end);
char nfaExecGough8_Q2(const struct NFA *n, struct mq *q, s64a end);
char nfaExecGough8_QR(const struct NFA *n, struct mq *q, ReportID report);
@@ -62,8 +61,7 @@ char nfaExecGough8_expandState(const struct NFA *nfa, void *dest,
char nfaExecGough16_testEOD(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
char nfaExecGough16_Q(const struct NFA *n, struct mq *q, s64a end);
char nfaExecGough16_Q2(const struct NFA *n, struct mq *q, s64a end);
char nfaExecGough16_QR(const struct NFA *n, struct mq *q, ReportID report);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -293,7 +293,7 @@ char lbrMatchLoop(const struct lbr_common *l, const u64a begin, const u64a end,
}
DEBUG_PRINTF("firing match at %llu\n", i);
if (cb(i, l->report, ctx) == MO_HALT_MATCHING) {
if (cb(0, i, l->report, ctx) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;
}
}

View File

@@ -72,7 +72,7 @@ char JOIN(ENGINE_EXEC_NAME, _reportCurrent)(const struct NFA *nfa,
const struct lbr_common *l = getImplNfa(nfa);
u64a offset = q_cur_offset(q);
DEBUG_PRINTF("firing match %u at %llu\n", l->report, offset);
q->cb(offset, l->report, q->context);
q->cb(0, offset, l->report, q->context);
return 0;
}
@@ -215,7 +215,7 @@ char JOIN(ENGINE_EXEC_NAME, _Q_i)(const struct NFA *nfa, struct mq *q,
if (q->report_current) {
DEBUG_PRINTF("report_current: fire match at %llu\n", q_cur_offset(q));
int rv = q->cb(q_cur_offset(q), l->report, q->context);
int rv = q->cb(0, q_cur_offset(q), l->report, q->context);
q->report_current = 0;
if (rv == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;

View File

@@ -54,8 +54,7 @@ extern "C"
#define GENERATE_NFA_DECL(gf_name) \
char gf_name##_testEOD(const struct NFA *nfa, const char *state, \
const char *streamState, u64a offset, \
NfaCallback callback, SomNfaCallback som_cb, \
void *context); \
NfaCallback callback, void *context); \
char gf_name##_Q(const struct NFA *n, struct mq *q, s64a end); \
char gf_name##_Q2(const struct NFA *n, struct mq *q, s64a end); \
char gf_name##_QR(const struct NFA *n, struct mq *q, ReportID report); \

View File

@@ -119,7 +119,7 @@ char PROCESS_ACCEPTS_FN(const IMPL_NFA_T *limex, STATE_T *s,
if (TESTBIT_STATE(s, a->state)) {
DEBUG_PRINTF("state %u is on, firing report id=%u, offset=%llu\n",
a->state, a->externalId, offset);
int rv = callback(offset, a->externalId, context);
int rv = callback(0, offset, a->externalId, context);
if (unlikely(rv == MO_HALT_MATCHING)) {
return 1;
}
@@ -150,7 +150,7 @@ char PROCESS_ACCEPTS_NOSQUASH_FN(const STATE_T *s,
if (TESTBIT_STATE(s, a->state)) {
DEBUG_PRINTF("state %u is on, firing report id=%u, offset=%llu\n",
a->state, a->externalId, offset);
int rv = callback(offset, a->externalId, context);
int rv = callback(0, offset, a->externalId, context);
if (unlikely(rv == MO_HALT_MATCHING)) {
return 1;
}

View File

@@ -130,7 +130,7 @@ int limexRunReports(const ReportID *reports, NfaCallback callback,
for (; *reports != MO_INVALID_IDX; ++reports) {
DEBUG_PRINTF("firing report for id %u at offset %llu\n",
*reports, offset);
int rv = callback(offset, *reports, context);
int rv = callback(0, offset, *reports, context);
if (rv == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;
}

View File

@@ -809,10 +809,8 @@ char JOIN(LIMEX_API_ROOT, _QR)(const struct NFA *n, struct mq *q,
}
char JOIN(LIMEX_API_ROOT, _testEOD)(const struct NFA *n, const char *state,
const char *streamState, u64a offset,
NfaCallback callback,
UNUSED SomNfaCallback som_callback,
void *context) {
const char *streamState, u64a offset,
NfaCallback callback, void *context) {
assert(n && state);
const IMPL_NFA_T *limex = getImplNfa(n);

View File

@@ -42,13 +42,13 @@
static really_inline
char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
u16 s, u64a loc, char eod, u16 * const cached_accept_state,
u32 * const cached_accept_id) {
u16 s, u64a loc, char eod, u16 *const cached_accept_state,
u32 *const cached_accept_id) {
DEBUG_PRINTF("reporting state = %hu, loc=%llu, eod %hhu\n",
(u16)(s & STATE_MASK), loc, eod);
if (!eod && s == *cached_accept_state) {
if (cb(loc, *cached_accept_id, ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, *cached_accept_id, ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING; /* termination requested */
}
@@ -71,7 +71,7 @@ char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
*cached_accept_id = rl->report[0];
DEBUG_PRINTF("reporting %u\n", rl->report[0]);
if (cb(loc, rl->report[0], ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, rl->report[0], ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING; /* termination requested */
}
@@ -80,7 +80,7 @@ char doComplexReport(NfaCallback cb, void *ctxt, const struct mcclellan *m,
for (u32 i = 0; i < count; i++) {
DEBUG_PRINTF("reporting %u\n", rl->report[i]);
if (cb(loc, rl->report[i], ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, rl->report[i], ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING; /* termination requested */
}
}
@@ -146,7 +146,7 @@ without_accel:
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING; /* termination requested */
}
} else if (doComplexReport(cb, ctxt, m, s & STATE_MASK, loc, 0,
@@ -186,7 +186,7 @@ with_accel:
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING; /* termination requested */
}
} else if (doComplexReport(cb, ctxt, m, s & STATE_MASK, loc, 0,
@@ -328,7 +328,7 @@ without_accel:
u64a loc = (c - 1) - buf + offAdj + 1;
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;
}
} else if (doComplexReport(cb, ctxt, m, s, loc, 0,
@@ -360,7 +360,7 @@ with_accel:
u64a loc = (c - 1) - buf + offAdj + 1;
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
if (cb(loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
if (cb(0, loc, m->arb_report, ctxt) == MO_HALT_MATCHING) {
return MO_HALT_MATCHING;
}
} else if (doComplexReport(cb, ctxt, m, s, loc, 0,
@@ -475,7 +475,7 @@ char nfaExecMcClellan16_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
int rv;
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
rv = cb(q_cur_offset(q), m->arb_report, context);
rv = cb(0, q_cur_offset(q), m->arb_report, context);
} else {
u32 cached_accept_id = 0;
u16 cached_accept_state = 0;
@@ -632,7 +632,7 @@ char nfaExecMcClellan8_Q2i(const struct NFA *n, u64a offset, const u8 *buffer,
int rv;
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
rv = cb(q_cur_offset(q), m->arb_report, context);
rv = cb(0, q_cur_offset(q), m->arb_report, context);
} else {
u32 cached_accept_id = 0;
u16 cached_accept_state = 0;
@@ -836,7 +836,7 @@ char nfaExecMcClellan8_reportCurrent(const struct NFA *n, struct mq *q) {
if (s >= m->accept_limit_8) {
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
cb(offset, m->arb_report, ctxt);
cb(0, offset, m->arb_report, ctxt);
} else {
u32 cached_accept_id = 0;
u16 cached_accept_state = 0;
@@ -864,7 +864,7 @@ char nfaExecMcClellan16_reportCurrent(const struct NFA *n, struct mq *q) {
if (aux->accept) {
if (single) {
DEBUG_PRINTF("reporting %u\n", m->arb_report);
cb(offset, m->arb_report, ctxt);
cb(0, offset, m->arb_report, ctxt);
} else {
u32 cached_accept_id = 0;
u16 cached_accept_state = 0;
@@ -1073,17 +1073,15 @@ void nfaExecMcClellan16_SimpStream(const struct NFA *nfa, char *state,
}
char nfaExecMcClellan8_testEOD(const struct NFA *nfa, const char *state,
UNUSED const char *streamState,
u64a offset, NfaCallback callback,
UNUSED SomNfaCallback som_cb, void *context) {
UNUSED const char *streamState, u64a offset,
NfaCallback callback, void *context) {
return mcclellanCheckEOD(nfa, *(const u8 *)state, offset, callback,
context);
}
char nfaExecMcClellan16_testEOD(const struct NFA *nfa, const char *state,
UNUSED const char *streamState,
u64a offset, NfaCallback callback,
UNUSED SomNfaCallback som_cb, void *context) {
UNUSED const char *streamState, u64a offset,
NfaCallback callback, void *context) {
assert(ISALIGNED_N(state, 2));
return mcclellanCheckEOD(nfa, *(const u16 *)state, offset, callback,
context);

View File

@@ -39,8 +39,7 @@ struct NFA;
char nfaExecMcClellan8_testEOD(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
char nfaExecMcClellan8_Q(const struct NFA *n, struct mq *q, s64a end);
char nfaExecMcClellan8_Q2(const struct NFA *n, struct mq *q, s64a end);
char nfaExecMcClellan8_QR(const struct NFA *n, struct mq *q, ReportID report);
@@ -63,8 +62,7 @@ char nfaExecMcClellan8_expandState(const struct NFA *nfa, void *dest,
char nfaExecMcClellan16_testEOD(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
char nfaExecMcClellan16_Q(const struct NFA *n, struct mq *q, s64a end);
char nfaExecMcClellan16_Q2(const struct NFA *n, struct mq *q, s64a end);
char nfaExecMcClellan16_QR(const struct NFA *n, struct mq *q, ReportID report);

View File

@@ -131,7 +131,8 @@ char processReports(const struct mpv *m, u8 *reporters,
rl_count++;
}
if (cb(report_offset, curr->report, ctxt) == MO_HALT_MATCHING) {
if (cb(0, report_offset, curr->report, ctxt) ==
MO_HALT_MATCHING) {
DEBUG_PRINTF("bailing\n");
return MO_HALT_MATCHING;
}
@@ -180,7 +181,7 @@ char processReportsForRange(const struct mpv *m, u8 *reporters,
for (size_t i = 2; i <= length; i++) {
for (u32 j = 0; j < rl_count; j++) {
if (cb(first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
if (cb(0, first_offset + i, rl[j], ctxt) == MO_HALT_MATCHING) {
DEBUG_PRINTF("bailing\n");
return MO_HALT_MATCHING;
}

View File

@@ -225,6 +225,9 @@ char nfaQueueExecRose(const struct NFA *nfa, struct mq *q, ReportID report);
* Runs an NFA in reverse from (buf + buflen) to buf and then from (hbuf + hlen)
* to hbuf (main buffer and history buffer).
*
* Note: provides the match location as the "end" offset when the callback is
* called.
*
* @param nfa engine to run
* @param offset base offset of buf
* @param buf main buffer
@@ -249,7 +252,6 @@ char nfaBlockExecReverse(const struct NFA *nfa, u64a offset, const u8 *buf,
* (including br region)
* @param offset the offset to return (via the callback) with each match
* @param callback the callback to call for each match raised
* @param som_cb the callback to call for each match raised (Haig)
* @param context context pointer passed to each callback
*
* @return @ref MO_HALT_MATCHING if the user instructed us to halt, otherwise
@@ -257,8 +259,7 @@ char nfaBlockExecReverse(const struct NFA *nfa, u64a offset, const u8 *buf,
*/
char nfaCheckFinalState(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
/**
* Indicates if an engine is a zombie.

View File

@@ -76,15 +76,14 @@
char nfaCheckFinalState(const struct NFA *nfa, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context) {
NfaCallback callback, void *context) {
assert(ISALIGNED_CL(nfa) && ISALIGNED_CL(getImplNfa(nfa)));
// Caller should avoid calling us if we can never produce matches.
assert(nfaAcceptsEod(nfa));
DISPATCH_BY_NFA_TYPE(_testEOD(nfa, state, streamState, offset, callback,
som_cb, context));
context));
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Intel Corporation
* Copyright (c) 2015-2016, Intel Corporation
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -97,7 +97,6 @@ struct mq {
* callback. If true, the queue must be located at a
* point where MO_MATCHES_PENDING was returned */
NfaCallback cb; /**< callback to trigger on matches */
SomNfaCallback som_cb; /**< callback with som info; used by haig */
void *context; /**< context to pass along with a callback */
struct mq_item items[MAX_MQE_LEN]; /**< queue items */
};

View File

@@ -85,7 +85,6 @@ void copyQueueProperties(const struct mq *q1, struct mq *q2,
q2->history = q1->history;
q2->hlength = q1->hlength;
q2->cb = q1->cb;
q2->som_cb = q1->som_cb;
q2->context = q1->context;
q2->scratch = q1->scratch;
q2->report_current = q1->report_current;
@@ -266,8 +265,7 @@ void copyBack(const struct Tamarama *t, struct mq *q, struct mq *q1) {
char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context) {
NfaCallback callback, void *context) {
const struct Tamarama *t = getImplNfa(n);
u32 activeIdx = loadActiveIdx(streamState, t->activeIdxSize);
if (activeIdx == t->numSubEngines) {
@@ -278,8 +276,8 @@ char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
if (nfaAcceptsEod(sub)) {
assert(!isContainerType(sub->type));
const char *subStreamState = streamState + t->activeIdxSize;
return nfaCheckFinalState(sub, state, subStreamState,
offset, callback, som_cb, context);
return nfaCheckFinalState(sub, state, subStreamState, offset, callback,
context);
}
return MO_CONTINUE_MATCHING;

View File

@@ -43,8 +43,7 @@ struct hs_scratch;
char nfaExecTamarama0_testEOD(const struct NFA *n, const char *state,
const char *streamState, u64a offset,
NfaCallback callback, SomNfaCallback som_cb,
void *context);
NfaCallback callback, void *context);
char nfaExecTamarama0_QR(const struct NFA *n, struct mq *q, ReportID report);
char nfaExecTamarama0_reportCurrent(const struct NFA *n, struct mq *q);
char nfaExecTamarama0_inAccept(const struct NFA *n, ReportID report,