]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Rose: make all NFA callbacks take scratch as ctx
authorJustin Viiret <justin.viiret@intel.com>
Thu, 3 Mar 2016 03:23:08 +0000 (14:23 +1100)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 20 Apr 2016 03:34:54 +0000 (13:34 +1000)
src/rose/catchup.c
src/rose/match.h

index c740fe087fc78ba4c7301f8c78a6c12099c2c03c..40327350ce6529b71e14c4648f581fab6811e587 100644 (file)
@@ -272,8 +272,8 @@ restart:
 /* for use by mpv (chained) only */
 static UNUSED
 int roseNfaFinalBlastAdaptor(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     DEBUG_PRINTF("called\n");
@@ -302,8 +302,8 @@ int roseNfaFinalBlastAdaptor(u64a offset, ReportID id, void *context) {
 static UNUSED
 int roseNfaFinalBlastAdaptorNoInternal(u64a offset, ReportID id,
                                        void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     DEBUG_PRINTF("called\n");
@@ -468,8 +468,8 @@ done:
 
 static UNUSED
 int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     const struct internal_report *ri = getInternalReport(t, id);
@@ -507,8 +507,8 @@ int roseNfaBlastAdaptor(u64a offset, ReportID id, void *context) {
 
 static UNUSED
 int roseNfaBlastAdaptorNoInternal(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     DEBUG_PRINTF("called\n");
@@ -536,8 +536,8 @@ int roseNfaBlastAdaptorNoInternal(u64a offset, ReportID id, void *context) {
 
 static UNUSED
 int roseNfaBlastAdaptorNoChain(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     DEBUG_PRINTF("masky got himself a blasted match @%llu id %u !woot!\n",
@@ -564,8 +564,8 @@ int roseNfaBlastAdaptorNoChain(u64a offset, ReportID id, void *context) {
 static UNUSED
 int roseNfaBlastAdaptorNoInternalNoChain(u64a offset, ReportID id,
                                          void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     /* chained nfas are run under the control of the anchored catchup */
@@ -589,8 +589,8 @@ int roseNfaBlastAdaptorNoInternalNoChain(u64a offset, ReportID id,
 static UNUSED
 int roseNfaBlastSomAdaptor(u64a from_offset, u64a offset, ReportID id,
                            void *context) {
-    struct RoseContext *tctxt = context;
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     const struct RoseEngine *t = scratch->core_info.rose;
 
     DEBUG_PRINTF("called\n");
@@ -618,12 +618,12 @@ int roseNfaBlastSomAdaptor(u64a from_offset, u64a offset, ReportID id,
 }
 
 int roseNfaAdaptor(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
 
     updateLastMatchOffset(tctxt, offset);
 
-    struct hs_scratch *scratch = tctxtToScratch(tctxt);
     const struct RoseEngine *t = scratch->core_info.rose;
     if (handleReportInternally(t, scratch, id, offset)) {
         return MO_CONTINUE_MATCHING;
@@ -633,21 +633,23 @@ int roseNfaAdaptor(u64a offset, ReportID id, void *context) {
 }
 
 int roseNfaAdaptorNoInternal(u64a offset, ReportID id, void *context) {
-    struct RoseContext *tctxt = context;
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
     updateLastMatchOffset(tctxt, offset);
 
-    return tctxt->cb(offset, id, tctxtToScratch(tctxt));
+    return tctxt->cb(offset, id, scratch);
 }
 
 int roseNfaSomAdaptor(u64a from_offset, u64a offset, ReportID id,
                       void *context) {
-    struct RoseContext *tctxt = context;
+    struct hs_scratch *scratch = context;
+    struct RoseContext *tctxt = &scratch->tctxt;
     DEBUG_PRINTF("masky got himself a match @%llu id %u !woot!\n", offset, id);
     updateLastMatchOffset(tctxt, offset);
 
     /* must be a external report as haig cannot directly participate in chain */
-    return tctxt->cb_som(from_offset, offset, id, tctxtToScratch(tctxt));
+    return tctxt->cb_som(from_offset, offset, id, scratch);
 }
 
 static really_inline
index f9889139516d57a23a95b30ca8ce5b56b61fcde6..d62fe553ee39d942fafebf985ccccf5468cffecb 100644 (file)
@@ -84,7 +84,7 @@ void initQueue(struct mq *q, u32 qi, const struct RoseEngine *t,
         q->cb = roseNfaAdaptor;
     }
     q->som_cb = roseNfaSomAdaptor;
-    q->context = &scratch->tctxt;
+    q->context = scratch;
     q->report_current = 0;
 
     DEBUG_PRINTF("qi=%u, offset=%llu, fullState=%u, streamState=%u, "