diff options
author | Ivan Blinkov <ivan@blinkov.ru> | 2022-02-10 16:47:10 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:10 +0300 |
commit | 1aeb9a455974457866f78722ad98114bafc84e8a (patch) | |
tree | e4340eaf1668684d83a0a58c36947c5def5350ad /contrib/libs/hyperscan/src/som | |
parent | bd5ef432f5cfb1e18851381329d94665a4c22470 (diff) | |
download | ydb-1aeb9a455974457866f78722ad98114bafc84e8a.tar.gz |
Restoring authorship annotation for Ivan Blinkov <ivan@blinkov.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/hyperscan/src/som')
-rw-r--r-- | contrib/libs/hyperscan/src/som/slot_manager.cpp | 22 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/slot_manager.h | 24 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/slot_manager_internal.h | 14 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/som.h | 14 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/som_operation.h | 168 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/som_runtime.c | 92 | ||||
-rw-r--r-- | contrib/libs/hyperscan/src/som/som_runtime.h | 12 |
7 files changed, 173 insertions, 173 deletions
diff --git a/contrib/libs/hyperscan/src/som/slot_manager.cpp b/contrib/libs/hyperscan/src/som/slot_manager.cpp index d97e8fc1d7..ec7f8cbdc5 100644 --- a/contrib/libs/hyperscan/src/som/slot_manager.cpp +++ b/contrib/libs/hyperscan/src/som/slot_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,11 +26,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/** - * \file +/** + * \file * \brief SOM Slot Manager. */ - + #include "slot_manager.h" #include "slot_manager_internal.h" @@ -40,7 +40,7 @@ #include "nfagraph/ng_som_util.h" #include "nfagraph/ng_region.h" #include "util/charreach.h" -#include "util/hash.h" +#include "util/hash.h" #include "util/make_unique.h" #include "util/dump_charclass.h" #include "util/verify_types.h" @@ -66,8 +66,8 @@ SlotCacheEntry::SlotCacheEntry(const NGHolder &prefix_in, size_t SlotEntryHasher::operator()(const SlotCacheEntry &e) const { assert(e.prefix); - size_t v = hash_all(hash_holder(*e.prefix), e.parent_slot, - e.is_reset, e.escapes); + size_t v = hash_all(hash_holder(*e.prefix), e.parent_slot, + e.is_reset, e.escapes); DEBUG_PRINTF("%zu vertices, parent_slot=%u, escapes=%s, is_reset=%d " "hashes to %zx\n", num_vertices(*e.prefix), e.parent_slot, @@ -137,7 +137,7 @@ u32 SomSlotManager::getSomSlot(const NGHolder &prefix, u32 SomSlotManager::getInitialResetSomSlot(const NGHolder &prefix, const NGHolder &g, - const unordered_map<NFAVertex, u32> ®ion_map, + const unordered_map<NFAVertex, u32> ®ion_map, u32 last_sent_region, bool *prefix_already_implemented) { DEBUG_PRINTF("getting initial reset; last sent region %u\n", last_sent_region); @@ -165,9 +165,9 @@ u32 SomSlotManager::getInitialResetSomSlot(const NGHolder &prefix, // Clone a copy of g (and its region map) that we will be able to store // later on. shared_ptr<NGHolder> gg = make_shared<NGHolder>(); - unordered_map<NFAVertex, NFAVertex> orig_to_copy; + unordered_map<NFAVertex, NFAVertex> orig_to_copy; cloneHolder(*gg, g, &orig_to_copy); - unordered_map<NFAVertex, u32> gg_region_map; + unordered_map<NFAVertex, u32> gg_region_map; for (const auto &m : region_map) { assert(contains(region_map, m.first)); gg_region_map.emplace(orig_to_copy.at(m.first), m.second); @@ -241,7 +241,7 @@ u32 SomSlotManager::numSomSlots() const { return nextSomSlot; } -u32 SomSlotManager::addRevNfa(bytecode_ptr<NFA> nfa, u32 maxWidth) { +u32 SomSlotManager::addRevNfa(bytecode_ptr<NFA> nfa, u32 maxWidth) { u32 rv = verify_u32(rev_nfas.size()); rev_nfas.push_back(move(nfa)); diff --git a/contrib/libs/hyperscan/src/som/slot_manager.h b/contrib/libs/hyperscan/src/som/slot_manager.h index e5b2d794c0..84e2632fea 100644 --- a/contrib/libs/hyperscan/src/som/slot_manager.h +++ b/contrib/libs/hyperscan/src/som/slot_manager.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,8 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/** - * \file +/** + * \file * \brief SOM Slot Manager. */ @@ -35,13 +35,13 @@ #define SLOT_MANAGER_H #include "ue2common.h" -#include "nfagraph/ng_holder.h" -#include "util/bytecode_ptr.h" -#include "util/noncopyable.h" +#include "nfagraph/ng_holder.h" +#include "util/bytecode_ptr.h" +#include "util/noncopyable.h" #include <deque> #include <memory> -#include <unordered_map> +#include <unordered_map> struct NFA; @@ -55,7 +55,7 @@ struct SlotCache; /** \brief SOM slot manager. Used to hand out SOM slots and track their * relationships during SOM construction. Also stores reverse NFAs used for * SOM. */ -class SomSlotManager : noncopyable { +class SomSlotManager : noncopyable { public: explicit SomSlotManager(u8 precision); ~SomSlotManager(); @@ -69,7 +69,7 @@ public: /** prefix must be acting as a resetting sentinel and should be a dag (if * not how are we establish som?) */ u32 getInitialResetSomSlot(const NGHolder &prefix, const NGHolder &g, - const std::unordered_map<NFAVertex, u32> ®ion_map, + const std::unordered_map<NFAVertex, u32> ®ion_map, u32 last_sent_region, bool *prefix_already_implemented); @@ -79,11 +79,11 @@ public: u32 numSomSlots() const; - const std::deque<bytecode_ptr<NFA>> &getRevNfas() const { + const std::deque<bytecode_ptr<NFA>> &getRevNfas() const { return rev_nfas; } - u32 addRevNfa(bytecode_ptr<NFA> nfa, u32 maxWidth); + u32 addRevNfa(bytecode_ptr<NFA> nfa, u32 maxWidth); u32 somHistoryRequired() const { return historyRequired; } @@ -98,7 +98,7 @@ private: std::unique_ptr<SlotCache> cache; /** \brief Reverse NFAs used for SOM support. */ - std::deque<bytecode_ptr<NFA>> rev_nfas; + std::deque<bytecode_ptr<NFA>> rev_nfas; /** \brief In streaming mode, the amount of history we've committed to * using for SOM rev NFAs. */ diff --git a/contrib/libs/hyperscan/src/som/slot_manager_internal.h b/contrib/libs/hyperscan/src/som/slot_manager_internal.h index 7e1fecc7e6..358ed630c9 100644 --- a/contrib/libs/hyperscan/src/som/slot_manager_internal.h +++ b/contrib/libs/hyperscan/src/som/slot_manager_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -35,8 +35,8 @@ #include "ue2common.h" #include <memory> -#include <unordered_map> -#include <unordered_set> +#include <unordered_map> +#include <unordered_set> #include <vector> namespace ue2 { @@ -44,14 +44,14 @@ namespace ue2 { struct InitialResetEntry { InitialResetEntry(std::shared_ptr<const NGHolder> sent_in, std::shared_ptr<const NGHolder> body_in, - const std::unordered_map<NFAVertex, u32> &body_regions_in, + const std::unordered_map<NFAVertex, u32> &body_regions_in, u32 sent_region_in, u32 first_bad_region_in) : sent(sent_in), body(body_in), body_regions(body_regions_in), sent_region(sent_region_in), first_bad_region(first_bad_region_in) {} std::shared_ptr<const NGHolder> sent; std::shared_ptr<const NGHolder> body; - std::unordered_map<NFAVertex, u32> body_regions; + std::unordered_map<NFAVertex, u32> body_regions; u32 sent_region; u32 first_bad_region; /* ~0U if it must cover the whole g */ }; @@ -86,7 +86,7 @@ struct SlotEntryEqual { }; struct SlotCache { - typedef std::unordered_set<SlotCacheEntry, SlotEntryHasher, + typedef std::unordered_set<SlotCacheEntry, SlotEntryHasher, SlotEntryEqual> CacheStore; void insert(const NGHolder &prefix, const CharReach &escapes, @@ -98,7 +98,7 @@ struct SlotCache { CacheStore store; std::unordered_set<std::shared_ptr<const NGHolder>, NGHolderHasher, - NGHolderEqual> initial_prefixes; + NGHolderEqual> initial_prefixes; std::vector<InitialResetInfo> initial_resets; }; diff --git a/contrib/libs/hyperscan/src/som/som.h b/contrib/libs/hyperscan/src/som/som.h index e759cf0a25..e3953311d2 100644 --- a/contrib/libs/hyperscan/src/som/som.h +++ b/contrib/libs/hyperscan/src/som/som.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, Intel Corporation + * Copyright (c) 2015-2017, Intel Corporation * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -26,22 +26,22 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/** - * \file +/** + * \file * \brief Common SOM definitions. */ #ifndef UE2_SOM_H #define UE2_SOM_H -namespace ue2 { - +namespace ue2 { + /** \brief Enumeration specifying a start of match behaviour. */ enum som_type { SOM_NONE, //!< No SOM required SOM_LEFT //!< Exact leftmost SOM }; -} // namespace ue2 - +} // namespace ue2 + #endif // UE2_SOM_H diff --git a/contrib/libs/hyperscan/src/som/som_operation.h b/contrib/libs/hyperscan/src/som/som_operation.h index d85ad2268e..72341adf85 100644 --- a/contrib/libs/hyperscan/src/som/som_operation.h +++ b/contrib/libs/hyperscan/src/som/som_operation.h @@ -1,84 +1,84 @@ -/* - * Copyright (c) 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. - */ - -/** - * \file - * \brief SOM runtime: data structures. - * - * Data structures used for SOM operations. - */ - -#ifndef SOM_OPERATION_H -#define SOM_OPERATION_H - -#include "ue2common.h" - -#define SOM_EXTERNAL_CALLBACK_REL 1 -#define SOM_INTERNAL_LOC_SET 2 -#define SOM_INTERNAL_LOC_SET_IF_UNSET 3 -#define SOM_INTERNAL_LOC_SET_IF_WRITABLE 4 -#define SOM_INTERNAL_LOC_SET_REV_NFA 5 -#define SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET 6 -#define SOM_INTERNAL_LOC_SET_REV_NFA_IF_WRITABLE 7 -#define SOM_INTERNAL_LOC_COPY 8 -#define SOM_INTERNAL_LOC_COPY_IF_WRITABLE 9 -#define SOM_INTERNAL_LOC_MAKE_WRITABLE 10 -#define SOM_EXTERNAL_CALLBACK_STORED 11 -#define SOM_EXTERNAL_CALLBACK_ABS 12 -#define SOM_EXTERNAL_CALLBACK_REV_NFA 13 -#define SOM_INTERNAL_LOC_SET_FROM 14 -#define SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE 15 - -struct som_operation { - /** \brief Report type, from the definitions above. */ - u8 type; - - /* \brief SOM loc to modify. */ - u32 onmatch; - - union { - /** \brief SOM distance value, use varies according to type. - * - * - for SOM_EXTERNAL_CALLBACK_REL, from-offset is this many bytes - * before the to-offset. - * - for SOM_EXTERNAL_CALLBACK_ABS, set from-offset to this value. - * - for SOM_INTERNAL_LOC_COPY*, som location read_from. - */ - u64a somDistance; - - /** \brief Index of the reverse nfa. - * - * Used by SOM_EXTERNAL_CALLBACK_REV_NFA and - * SOM_INTERNAL_LOC_SET_REV_NFA*. - */ - u64a revNfaIndex; - } aux; -}; - -#endif // SOM_OPERATION_H - +/* + * Copyright (c) 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. + */ + +/** + * \file + * \brief SOM runtime: data structures. + * + * Data structures used for SOM operations. + */ + +#ifndef SOM_OPERATION_H +#define SOM_OPERATION_H + +#include "ue2common.h" + +#define SOM_EXTERNAL_CALLBACK_REL 1 +#define SOM_INTERNAL_LOC_SET 2 +#define SOM_INTERNAL_LOC_SET_IF_UNSET 3 +#define SOM_INTERNAL_LOC_SET_IF_WRITABLE 4 +#define SOM_INTERNAL_LOC_SET_REV_NFA 5 +#define SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET 6 +#define SOM_INTERNAL_LOC_SET_REV_NFA_IF_WRITABLE 7 +#define SOM_INTERNAL_LOC_COPY 8 +#define SOM_INTERNAL_LOC_COPY_IF_WRITABLE 9 +#define SOM_INTERNAL_LOC_MAKE_WRITABLE 10 +#define SOM_EXTERNAL_CALLBACK_STORED 11 +#define SOM_EXTERNAL_CALLBACK_ABS 12 +#define SOM_EXTERNAL_CALLBACK_REV_NFA 13 +#define SOM_INTERNAL_LOC_SET_FROM 14 +#define SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE 15 + +struct som_operation { + /** \brief Report type, from the definitions above. */ + u8 type; + + /* \brief SOM loc to modify. */ + u32 onmatch; + + union { + /** \brief SOM distance value, use varies according to type. + * + * - for SOM_EXTERNAL_CALLBACK_REL, from-offset is this many bytes + * before the to-offset. + * - for SOM_EXTERNAL_CALLBACK_ABS, set from-offset to this value. + * - for SOM_INTERNAL_LOC_COPY*, som location read_from. + */ + u64a somDistance; + + /** \brief Index of the reverse nfa. + * + * Used by SOM_EXTERNAL_CALLBACK_REV_NFA and + * SOM_INTERNAL_LOC_SET_REV_NFA*. + */ + u64a revNfaIndex; + } aux; +}; + +#endif // SOM_OPERATION_H + diff --git a/contrib/libs/hyperscan/src/som/som_runtime.c b/contrib/libs/hyperscan/src/som/som_runtime.c index 1a868efc97..68fb96dfc9 100644 --- a/contrib/libs/hyperscan/src/som/som_runtime.c +++ b/contrib/libs/hyperscan/src/som/som_runtime.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, 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: @@ -39,7 +39,7 @@ */ #include "hs_internal.h" -#include "som_operation.h" +#include "som_operation.h" #include "som_runtime.h" #include "scratch.h" #include "ue2common.h" @@ -51,7 +51,7 @@ static really_inline void setSomLoc(struct fatbit *som_set_now, u64a *som_store, u32 som_store_count, - const struct som_operation *ri, u64a to_offset) { + const struct som_operation *ri, u64a to_offset) { /* validity handled by callers */ assert(to_offset >= ri->aux.somDistance); u64a start_offset = to_offset - ri->aux.somDistance; @@ -87,14 +87,14 @@ char ok_and_mark_if_unset(u8 *som_store_valid, struct fatbit *som_set_now, } static -int somRevCallback(UNUSED u64a start, u64a end, ReportID id, void *ctx) { - DEBUG_PRINTF("offset=%llu, id=%u\n", end, id); +int somRevCallback(UNUSED u64a start, u64a end, ReportID id, void *ctx) { + DEBUG_PRINTF("offset=%llu, id=%u\n", end, id); // We use the id to store the offset adjustment (for assertions like a // leading \b or multiline mode). assert(id <= 1); u64a *from_offset = ctx; - LIMIT_TO_AT_MOST(from_offset, end + id); + LIMIT_TO_AT_MOST(from_offset, end + id); return 1; // continue matching. } @@ -112,7 +112,7 @@ const struct NFA *getSomRevNFA(const struct RoseEngine *t, u32 i) { } static -void runRevNfa(struct hs_scratch *scratch, const struct som_operation *ri, +void runRevNfa(struct hs_scratch *scratch, const struct som_operation *ri, const u64a to_offset, u64a *from_offset) { struct core_info *ci = &scratch->core_info; @@ -151,7 +151,7 @@ void runRevNfa(struct hs_scratch *scratch, const struct som_operation *ri, *from_offset = to_offset; nfaBlockExecReverse(nfa, to_offset, buf, buf_bytes, hbuf, history_bytes, - somRevCallback, from_offset); + somRevCallback, from_offset); assert(*from_offset <= to_offset); } @@ -159,7 +159,7 @@ void runRevNfa(struct hs_scratch *scratch, const struct som_operation *ri, static really_inline void setSomLocRevNfa(struct hs_scratch *scratch, struct fatbit *som_set_now, u64a *som_store, u32 som_store_count, - const struct som_operation *ri, u64a to_offset) { + const struct som_operation *ri, u64a to_offset) { /* validity handled by callers */ u64a from_offset = 0; runRevNfa(scratch, ri, to_offset, &from_offset); @@ -178,7 +178,7 @@ void setSomLocRevNfa(struct hs_scratch *scratch, struct fatbit *som_set_now, } void handleSomInternal(struct hs_scratch *scratch, - const struct som_operation *ri, const u64a to_offset) { + const struct som_operation *ri, const u64a to_offset) { assert(scratch); assert(ri); DEBUG_PRINTF("-->som action required at %llu\n", to_offset); @@ -209,21 +209,21 @@ void handleSomInternal(struct hs_scratch *scratch, } switch (ri->type) { - case SOM_INTERNAL_LOC_SET: - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET\n"); + case SOM_INTERNAL_LOC_SET: + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET\n"); mmbit_set(som_store_valid, som_store_count, ri->onmatch); setSomLoc(som_set_now, som_store, som_store_count, ri, to_offset); return; - case SOM_INTERNAL_LOC_SET_IF_UNSET: - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_UNSET\n"); + case SOM_INTERNAL_LOC_SET_IF_UNSET: + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_UNSET\n"); if (ok_and_mark_if_unset(som_store_valid, som_set_now, som_store_count, ri->onmatch)) { setSomLoc(som_set_now, som_store, som_store_count, ri, to_offset); } return; - case SOM_INTERNAL_LOC_SET_IF_WRITABLE: { + case SOM_INTERNAL_LOC_SET_IF_WRITABLE: { u32 slot = ri->onmatch; - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_WRITABLE\n"); + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_WRITABLE\n"); if (ok_and_mark_if_write(som_store_valid, som_set_now, som_store_writable, som_store_count, slot)) { setSomLoc(som_set_now, som_store, som_store_count, ri, to_offset); @@ -245,23 +245,23 @@ void handleSomInternal(struct hs_scratch *scratch, } return; } - case SOM_INTERNAL_LOC_SET_REV_NFA: - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_REV_NFA\n"); + case SOM_INTERNAL_LOC_SET_REV_NFA: + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_REV_NFA\n"); mmbit_set(som_store_valid, som_store_count, ri->onmatch); setSomLocRevNfa(scratch, som_set_now, som_store, som_store_count, ri, to_offset); return; - case SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET: - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET\n"); + case SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET: + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_REV_NFA_IF_UNSET\n"); if (ok_and_mark_if_unset(som_store_valid, som_set_now, som_store_count, ri->onmatch)) { setSomLocRevNfa(scratch, som_set_now, som_store, som_store_count, ri, to_offset); } return; - case SOM_INTERNAL_LOC_SET_REV_NFA_IF_WRITABLE: { + case SOM_INTERNAL_LOC_SET_REV_NFA_IF_WRITABLE: { u32 slot = ri->onmatch; - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_WRITABLE\n"); + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_IF_WRITABLE\n"); if (ok_and_mark_if_write(som_store_valid, som_set_now, som_store_writable, som_store_count, slot)) { setSomLocRevNfa(scratch, som_set_now, som_store, som_store_count, @@ -285,10 +285,10 @@ void handleSomInternal(struct hs_scratch *scratch, } return; } - case SOM_INTERNAL_LOC_COPY: { + case SOM_INTERNAL_LOC_COPY: { u32 slot_in = ri->aux.somDistance; u32 slot_out = ri->onmatch; - DEBUG_PRINTF("SOM_INTERNAL_LOC_COPY S[%u] = S[%u]\n", slot_out, + DEBUG_PRINTF("SOM_INTERNAL_LOC_COPY S[%u] = S[%u]\n", slot_out, slot_in); assert(mmbit_isset(som_store_valid, som_store_count, slot_in)); mmbit_set(som_store_valid, som_store_count, slot_out); @@ -297,10 +297,10 @@ void handleSomInternal(struct hs_scratch *scratch, return; } - case SOM_INTERNAL_LOC_COPY_IF_WRITABLE: { + case SOM_INTERNAL_LOC_COPY_IF_WRITABLE: { u32 slot_in = ri->aux.somDistance; u32 slot_out = ri->onmatch; - DEBUG_PRINTF("SOM_INTERNAL_LOC_COPY_IF_WRITABLE S[%u] = S[%u]\n", + DEBUG_PRINTF("SOM_INTERNAL_LOC_COPY_IF_WRITABLE S[%u] = S[%u]\n", slot_out, slot_in); assert(mmbit_isset(som_store_valid, som_store_count, slot_in)); if (ok_and_mark_if_write(som_store_valid, som_set_now, @@ -322,9 +322,9 @@ void handleSomInternal(struct hs_scratch *scratch, } return; } - case SOM_INTERNAL_LOC_MAKE_WRITABLE: { + case SOM_INTERNAL_LOC_MAKE_WRITABLE: { u32 slot = ri->onmatch; - DEBUG_PRINTF("SOM_INTERNAL_LOC_MAKE_WRITABLE\n"); + DEBUG_PRINTF("SOM_INTERNAL_LOC_MAKE_WRITABLE\n"); /* if just written to the loc, ignore the racing escape */ if (fatbit_isset(som_set_now, som_store_count, slot)) { DEBUG_PRINTF("just written\n"); @@ -347,14 +347,14 @@ void handleSomInternal(struct hs_scratch *scratch, break; } - // All valid som_operation types should be handled and returned above. + // All valid som_operation types should be handled and returned above. assert(0); return; } // Returns the SOM offset. u64a handleSomExternal(struct hs_scratch *scratch, - const struct som_operation *ri, + const struct som_operation *ri, const u64a to_offset) { assert(scratch); assert(ri); @@ -368,20 +368,20 @@ u64a handleSomExternal(struct hs_scratch *scratch, assert(rose->hasSom); switch (ri->type) { - case SOM_EXTERNAL_CALLBACK_REL: - DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_REL: som is %llu chars back\n", + case SOM_EXTERNAL_CALLBACK_REL: + DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_REL: som is %llu chars back\n", ri->aux.somDistance); assert(to_offset >= ri->aux.somDistance); return to_offset - ri->aux.somDistance; - case SOM_EXTERNAL_CALLBACK_ABS: - DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_ABS: som is at %llu\n", + case SOM_EXTERNAL_CALLBACK_ABS: + DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_ABS: som is at %llu\n", ri->aux.somDistance); assert(to_offset >= ri->aux.somDistance); return ri->aux.somDistance; - case SOM_EXTERNAL_CALLBACK_STORED: { + case SOM_EXTERNAL_CALLBACK_STORED: { const u64a *som_store = scratch->som_store; u32 slot = ri->aux.somDistance; - DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_STORED: <- som_store[%u]=%llu\n", + DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_STORED: <- som_store[%u]=%llu\n", slot, som_store[slot]); UNUSED const u32 som_store_count = rose->somLocationCount; @@ -391,8 +391,8 @@ u64a handleSomExternal(struct hs_scratch *scratch, assert(mmbit_isset(som_store_valid, som_store_count, slot)); return som_store[slot]; } - case SOM_EXTERNAL_CALLBACK_REV_NFA: { - DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_REV_NFA\n"); + case SOM_EXTERNAL_CALLBACK_REV_NFA: { + DEBUG_PRINTF("SOM_EXTERNAL_CALLBACK_REV_NFA\n"); u64a from_offset = 0; runRevNfa(scratch, ri, to_offset, &from_offset); return from_offset; @@ -402,19 +402,19 @@ u64a handleSomExternal(struct hs_scratch *scratch, break; } - // All valid som_operation types should be handled and returned above. + // All valid som_operation types should be handled and returned above. assert(0); return 0; } void setSomFromSomAware(struct hs_scratch *scratch, - const struct som_operation *ri, u64a from_offset, + const struct som_operation *ri, u64a from_offset, u64a to_offset) { assert(scratch); assert(ri); assert(to_offset); - assert(ri->type == SOM_INTERNAL_LOC_SET_FROM - || ri->type == SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE); + assert(ri->type == SOM_INTERNAL_LOC_SET_FROM + || ri->type == SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE); struct core_info *ci = &scratch->core_info; const struct RoseEngine *rose = ci->rose; @@ -435,12 +435,12 @@ void setSomFromSomAware(struct hs_scratch *scratch, scratch->som_set_now_offset = to_offset; } - if (ri->type == SOM_INTERNAL_LOC_SET_FROM) { - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_FROM\n"); + if (ri->type == SOM_INTERNAL_LOC_SET_FROM) { + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_FROM\n"); mmbit_set(som_store_valid, som_store_count, ri->onmatch); setSomLoc(som_set_now, som_store, som_store_count, ri, from_offset); } else { - DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE\n"); + DEBUG_PRINTF("SOM_INTERNAL_LOC_SET_FROM_IF_WRITABLE\n"); if (ok_and_mark_if_write(som_store_valid, som_set_now, som_store_writable, som_store_count, ri->onmatch)) { @@ -487,7 +487,7 @@ int clearSomLog(struct hs_scratch *scratch, u64a offset, struct fatbit *log, int halt = ci->userCallback(onmatch, from_offset, offset, flags, ci->userContext); if (halt) { - ci->status |= STATUS_TERMINATED; + ci->status |= STATUS_TERMINATED; return 1; } } diff --git a/contrib/libs/hyperscan/src/som/som_runtime.h b/contrib/libs/hyperscan/src/som/som_runtime.h index 30c7ace8cb..898c2a51d7 100644 --- a/contrib/libs/hyperscan/src/som/som_runtime.h +++ b/contrib/libs/hyperscan/src/som/som_runtime.h @@ -26,8 +26,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/** - * \file +/** + * \file * \brief SOM runtime code. * * Runtime code for SOM handling called by the Rose callback adaptors. @@ -39,17 +39,17 @@ #include "scratch.h" #include "ue2common.h" -struct som_operation; +struct som_operation; void handleSomInternal(struct hs_scratch *scratch, - const struct som_operation *ri, const u64a to_offset); + const struct som_operation *ri, const u64a to_offset); // Returns the from_offset. u64a handleSomExternal(struct hs_scratch *scratch, - const struct som_operation *ri, const u64a to_offset); + const struct som_operation *ri, const u64a to_offset); void setSomFromSomAware(struct hs_scratch *scratch, - const struct som_operation *ri, u64a from_offset, + const struct som_operation *ri, u64a from_offset, u64a to_offset); int flushStoredSomMatches_i(struct hs_scratch *scratch, u64a offset); |