]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
eod: move stream eod code to stream.c
authorJustin Viiret <justin.viiret@intel.com>
Wed, 15 Jun 2016 00:33:51 +0000 (10:33 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Fri, 8 Jul 2016 00:55:36 +0000 (10:55 +1000)
CMakeLists.txt
src/rose/eod.c [deleted file]
src/rose/stream.c

index 92caf4ce80ea18d2a48e3f06366f2403a7ce593d..d49de2775cf142e66f75e2a78b018a52a98814e7 100644 (file)
@@ -495,7 +495,6 @@ set (hs_exec_SRCS
     src/rose/block.c
     src/rose/catchup.h
     src/rose/catchup.c
-    src/rose/eod.c
     src/rose/infix.h
     src/rose/init.h
     src/rose/init.c
diff --git a/src/rose/eod.c b/src/rose/eod.c
deleted file mode 100644 (file)
index dd471c9..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *  * Neither the name of Intel Corporation nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "catchup.h"
-#include "match.h"
-#include "program_runtime.h"
-#include "rose.h"
-#include "util/fatbit.h"
-
-static really_inline
-void initContext(const struct RoseEngine *t, u64a offset,
-                 struct hs_scratch *scratch) {
-    struct RoseContext *tctxt = &scratch->tctxt;
-    /* TODO: diff groups for eod */
-    tctxt->groups = loadGroups(t, scratch->core_info.state);
-    tctxt->lit_offset_adjust = scratch->core_info.buf_offset
-                             - scratch->core_info.hlen
-                             + 1; // index after last byte
-    tctxt->delayLastEndOffset = offset;
-    tctxt->lastEndOffset = offset;
-    tctxt->filledDelayedSlots = 0;
-    tctxt->lastMatchOffset = 0;
-    tctxt->minMatchOffset = offset;
-    tctxt->minNonMpvMatchOffset = offset;
-    tctxt->next_mpv_offset = offset;
-
-    scratch->catchup_pq.qm_size = 0;
-    scratch->al_log_sum = 0; /* clear the anchored logs */
-
-    fatbit_clear(scratch->aqa);
-}
-
-void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
-                       struct hs_scratch *scratch) {
-    assert(scratch);
-    assert(t->requiresEodCheck);
-    DEBUG_PRINTF("ci buf %p/%zu his %p/%zu\n", scratch->core_info.buf,
-                 scratch->core_info.len, scratch->core_info.hbuf,
-                 scratch->core_info.hlen);
-
-    // We should not have been called if we've already been told to terminate
-    // matching.
-    assert(!told_to_stop_matching(scratch));
-
-    if (t->maxBiAnchoredWidth != ROSE_BOUND_INF
-        && offset > t->maxBiAnchoredWidth) {
-        DEBUG_PRINTF("bailing, we are beyond max width\n");
-        /* also some of the history/state may be stale */
-        return;
-    }
-
-    if (!t->eodProgramOffset) {
-        DEBUG_PRINTF("no eod program\n");
-        return;
-    }
-
-    initContext(t, offset, scratch);
-
-    DEBUG_PRINTF("running eod program at %u\n", t->eodProgramOffset);
-
-    // There should be no pending delayed literals.
-    assert(!scratch->tctxt.filledDelayedSlots);
-
-    const u64a som = 0;
-    const size_t match_len = 0;
-    const char in_anchored = 0;
-    const char in_catchup = 0;
-    const char from_mpv = 0;
-    const char skip_mpv_catchup = 1;
-
-    // Note: we ignore the result, as this is the last thing to ever happen on
-    // a scan.
-    roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
-                   in_anchored, in_catchup, from_mpv, skip_mpv_catchup);
-}
index b08fe04d63d8b98ab1a0b77afdf863b89f5d6d27..0e382f035ccec3e19b1ea58e3c7458d3a9fa1d95 100644 (file)
 #include "infix.h"
 #include "match.h"
 #include "miracle.h"
+#include "program_runtime.h"
+#include "rose.h"
 #include "hwlm/hwlm.h"
 #include "nfa/mcclellan.h"
 #include "nfa/nfa_api.h"
 #include "nfa/nfa_api_queue.h"
 #include "nfa/nfa_internal.h"
 #include "util/fatbit.h"
-#include "rose.h"
 
 static rose_inline
 void runAnchoredTableStream(const struct RoseEngine *t, const void *atable,
@@ -558,3 +559,70 @@ exit:
                  scratch->core_info.status);
     return;
 }
+
+static rose_inline
+void roseStreamInitEod(const struct RoseEngine *t, u64a offset,
+                       struct hs_scratch *scratch) {
+    struct RoseContext *tctxt = &scratch->tctxt;
+    /* TODO: diff groups for eod */
+    tctxt->groups = loadGroups(t, scratch->core_info.state);
+    tctxt->lit_offset_adjust = scratch->core_info.buf_offset
+                             - scratch->core_info.hlen
+                             + 1; // index after last byte
+    tctxt->delayLastEndOffset = offset;
+    tctxt->lastEndOffset = offset;
+    tctxt->filledDelayedSlots = 0;
+    tctxt->lastMatchOffset = 0;
+    tctxt->minMatchOffset = offset;
+    tctxt->minNonMpvMatchOffset = offset;
+    tctxt->next_mpv_offset = offset;
+
+    scratch->catchup_pq.qm_size = 0;
+    scratch->al_log_sum = 0; /* clear the anchored logs */
+
+    fatbit_clear(scratch->aqa);
+}
+
+void roseStreamEodExec(const struct RoseEngine *t, u64a offset,
+                       struct hs_scratch *scratch) {
+    assert(scratch);
+    assert(t->requiresEodCheck);
+    DEBUG_PRINTF("ci buf %p/%zu his %p/%zu\n", scratch->core_info.buf,
+                 scratch->core_info.len, scratch->core_info.hbuf,
+                 scratch->core_info.hlen);
+
+    // We should not have been called if we've already been told to terminate
+    // matching.
+    assert(!told_to_stop_matching(scratch));
+
+    if (t->maxBiAnchoredWidth != ROSE_BOUND_INF
+        && offset > t->maxBiAnchoredWidth) {
+        DEBUG_PRINTF("bailing, we are beyond max width\n");
+        /* also some of the history/state may be stale */
+        return;
+    }
+
+    if (!t->eodProgramOffset) {
+        DEBUG_PRINTF("no eod program\n");
+        return;
+    }
+
+    roseStreamInitEod(t, offset, scratch);
+
+    DEBUG_PRINTF("running eod program at %u\n", t->eodProgramOffset);
+
+    // There should be no pending delayed literals.
+    assert(!scratch->tctxt.filledDelayedSlots);
+
+    const u64a som = 0;
+    const size_t match_len = 0;
+    const char in_anchored = 0;
+    const char in_catchup = 0;
+    const char from_mpv = 0;
+    const char skip_mpv_catchup = 1;
+
+    // Note: we ignore the result, as this is the last thing to ever happen on
+    // a scan.
+    roseRunProgram(t, scratch, t->eodProgramOffset, som, offset, match_len,
+                   in_anchored, in_catchup, from_mpv, skip_mpv_catchup);
+}