mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-11-15 17:02:14 +03:00
Merge branch 'develop' into wip-cppcheck271-part2
This commit is contained in:
@@ -298,7 +298,7 @@ void get_conf_stride_4(const u8 *itPtr, UNUSED const u8 *start_ptr,
|
||||
static really_inline
|
||||
void do_confirm_fdr(u64a *conf, u8 offset, hwlmcb_rv_t *control,
|
||||
const u32 *confBase, const struct FDR_Runtime_Args *a,
|
||||
const u8 *ptr, u32 *last_match_id, struct zone *z) {
|
||||
const u8 *ptr, u32 *last_match_id, const struct zone *z) {
|
||||
const u8 bucket = 8;
|
||||
|
||||
if (likely(!*conf)) {
|
||||
@@ -333,7 +333,7 @@ void do_confirm_fdr(u64a *conf, u8 offset, hwlmcb_rv_t *control,
|
||||
}
|
||||
|
||||
static really_inline
|
||||
void dumpZoneInfo(UNUSED struct zone *z, UNUSED size_t zone_id) {
|
||||
void dumpZoneInfo(UNUSED const struct zone *z, UNUSED size_t zone_id) {
|
||||
#ifdef DEBUG
|
||||
DEBUG_PRINTF("zone: zone=%zu, bufPtr=%p\n", zone_id, z->buf);
|
||||
DEBUG_PRINTF("zone: startPtr=%p, endPtr=%p, shift=%u\n",
|
||||
|
||||
@@ -127,7 +127,7 @@ void andMask(u8 *dest, const u8 *a, const u8 *b, u32 num_bytes) {
|
||||
}
|
||||
|
||||
void FDRCompiler::createInitialState(FDR *fdr) {
|
||||
u8 *start = (u8 *)&fdr->start;
|
||||
u8 *start = reinterpret_cast<u8 *>(&fdr->start);
|
||||
|
||||
/* initial state should to be 1 in each slot in the bucket up to bucket
|
||||
* minlen - 1, and 0 thereafter */
|
||||
@@ -176,7 +176,7 @@ bytecode_ptr<FDR> FDRCompiler::setupFDR() {
|
||||
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
||||
assert(fdr); // otherwise would have thrown std::bad_alloc
|
||||
|
||||
u8 *fdr_base = (u8 *)fdr.get();
|
||||
u8 *fdr_base = reinterpret_cast<u8 *>(fdr.get());
|
||||
|
||||
// Write header.
|
||||
fdr->size = size;
|
||||
|
||||
@@ -58,7 +58,7 @@ u64a make_u64a_mask(const vector<u8> &v) {
|
||||
u64a mask = 0;
|
||||
size_t vlen = v.size();
|
||||
size_t len = std::min(vlen, sizeof(mask));
|
||||
unsigned char *m = (unsigned char *)&mask;
|
||||
u8 *m = reinterpret_cast<u8 *>(&mask);
|
||||
memcpy(m + sizeof(mask) - len, &v[vlen - len], len);
|
||||
return mask;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
||||
map<u32, vector<LiteralIndex> > res2lits;
|
||||
hwlm_group_t gm = 0;
|
||||
for (LiteralIndex i = 0; i < lits.size(); i++) {
|
||||
LitInfo & li = tmpLitInfo[i];
|
||||
const LitInfo & li = tmpLitInfo[i];
|
||||
u32 hash = CONF_HASH_CALL(li.v, andmsk, mult, nBits);
|
||||
DEBUG_PRINTF("%016llx --> %u\n", li.v, hash);
|
||||
res2lits[hash].emplace_back(i);
|
||||
@@ -245,10 +245,10 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
||||
fdrc->groups = gm;
|
||||
|
||||
// After the FDRConfirm, we have the lit index array.
|
||||
u8 *fdrc_base = (u8 *)fdrc.get();
|
||||
u8 *fdrc_base = reinterpret_cast<u8 *>(fdrc.get());
|
||||
u8 *ptr = fdrc_base + sizeof(*fdrc);
|
||||
ptr = ROUNDUP_PTR(ptr, alignof(u32));
|
||||
u32 *bitsToLitIndex = (u32 *)ptr;
|
||||
u32 *bitsToLitIndex = reinterpret_cast<u32 *>(ptr);
|
||||
ptr += bitsToLitIndexSize;
|
||||
|
||||
// After the lit index array, we have the LitInfo structures themselves,
|
||||
@@ -265,7 +265,7 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
||||
LiteralIndex litIdx = *i;
|
||||
|
||||
// Write LitInfo header.
|
||||
LitInfo &finalLI = *(LitInfo *)ptr;
|
||||
LitInfo &finalLI = *(reinterpret_cast<LitInfo *>(ptr));
|
||||
finalLI = tmpLitInfo[litIdx];
|
||||
|
||||
ptr += sizeof(LitInfo); // String starts directly after LitInfo.
|
||||
@@ -294,9 +294,6 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
|
||||
const EngineDescription &eng,
|
||||
const map<BucketIndex, vector<LiteralIndex>> &bucketToLits,
|
||||
bool make_small) {
|
||||
unique_ptr<TeddyEngineDescription> teddyDescr =
|
||||
getTeddyDescription(eng.getID());
|
||||
|
||||
BC2CONF bc2Conf;
|
||||
u32 totalConfirmSize = 0;
|
||||
for (BucketIndex b = 0; b < eng.getNumBuckets(); b++) {
|
||||
@@ -321,7 +318,7 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
|
||||
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 64);
|
||||
assert(buf); // otherwise would have thrown std::bad_alloc
|
||||
|
||||
u32 *confBase = (u32 *)buf.get();
|
||||
u32 *confBase = reinterpret_cast<u32 *>(buf.get());
|
||||
u8 *ptr = buf.get() + totalConfSwitchSize;
|
||||
assert(ISALIGNED_CL(ptr));
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ u32 findDesiredStride(size_t num_lits, size_t min_len, size_t min_len_count) {
|
||||
} else if (num_lits < 5000) {
|
||||
// for larger but not huge sizes, go to stride 2 only if we have at
|
||||
// least minlen 3
|
||||
desiredStride = MIN(min_len - 1, 2);
|
||||
desiredStride = std::min(min_len - 1, 2UL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,8 @@ bytecode_ptr<u8> setupFDRFloodControl(const vector<hwlmLiteral> &lits,
|
||||
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 16);
|
||||
assert(buf); // otherwise would have thrown std::bad_alloc
|
||||
|
||||
u32 *floodHeader = (u32 *)buf.get();
|
||||
FDRFlood *layoutFlood = (FDRFlood *)(buf.get() + floodHeaderSize);
|
||||
u32 *floodHeader = reinterpret_cast<u32 *>(buf.get());
|
||||
FDRFlood *layoutFlood = reinterpret_cast<FDRFlood *>(buf.get() + floodHeaderSize);
|
||||
|
||||
u32 currentFloodIndex = 0;
|
||||
for (const auto &m : flood2chars) {
|
||||
|
||||
@@ -328,7 +328,7 @@ bool pack(const vector<hwlmLiteral> &lits,
|
||||
|
||||
static
|
||||
void initReinforcedTable(u8 *rmsk) {
|
||||
u64a *mask = (u64a *)rmsk;
|
||||
u64a *mask = reinterpret_cast<u64a *>(rmsk);
|
||||
fill_n(mask, N_CHARS, 0x00ffffffffffffffULL);
|
||||
}
|
||||
|
||||
@@ -576,8 +576,8 @@ bytecode_ptr<FDR> TeddyCompiler::build() {
|
||||
|
||||
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
||||
assert(fdr); // otherwise would have thrown std::bad_alloc
|
||||
Teddy *teddy = (Teddy *)fdr.get(); // ugly
|
||||
u8 *teddy_base = (u8 *)teddy;
|
||||
Teddy *teddy = reinterpret_cast<Teddy *>(fdr.get()); // ugly
|
||||
u8 *teddy_base = reinterpret_cast<u8 *>(teddy);
|
||||
|
||||
// Write header.
|
||||
teddy->size = size;
|
||||
@@ -622,7 +622,7 @@ bytecode_ptr<FDR> TeddyCompiler::build() {
|
||||
static
|
||||
bool assignStringsToBuckets(
|
||||
const vector<hwlmLiteral> &lits,
|
||||
TeddyEngineDescription &eng,
|
||||
const TeddyEngineDescription &eng,
|
||||
map<BucketIndex, vector<LiteralIndex>> &bucketToLits) {
|
||||
assert(eng.numMasks <= MAX_NUM_MASKS);
|
||||
if (lits.size() > eng.getNumBuckets() * TEDDY_BUCKET_LOAD) {
|
||||
|
||||
@@ -52,14 +52,14 @@ u32 TeddyEngineDescription::getDefaultFloodSuffixLength() const {
|
||||
|
||||
void getTeddyDescriptions(vector<TeddyEngineDescription> *out) {
|
||||
static const TeddyEngineDef defns[] = {
|
||||
{ 3, 0 | HS_CPU_FEATURES_AVX2, 1, 16, false },
|
||||
{ 4, 0 | HS_CPU_FEATURES_AVX2, 1, 16, true },
|
||||
{ 5, 0 | HS_CPU_FEATURES_AVX2, 2, 16, false },
|
||||
{ 6, 0 | HS_CPU_FEATURES_AVX2, 2, 16, true },
|
||||
{ 7, 0 | HS_CPU_FEATURES_AVX2, 3, 16, false },
|
||||
{ 8, 0 | HS_CPU_FEATURES_AVX2, 3, 16, true },
|
||||
{ 9, 0 | HS_CPU_FEATURES_AVX2, 4, 16, false },
|
||||
{ 10, 0 | HS_CPU_FEATURES_AVX2, 4, 16, true },
|
||||
{ 3, HS_CPU_FEATURES_AVX2, 1, 16, false },
|
||||
{ 4, HS_CPU_FEATURES_AVX2, 1, 16, true },
|
||||
{ 5, HS_CPU_FEATURES_AVX2, 2, 16, false },
|
||||
{ 6, HS_CPU_FEATURES_AVX2, 2, 16, true },
|
||||
{ 7, HS_CPU_FEATURES_AVX2, 3, 16, false },
|
||||
{ 8, HS_CPU_FEATURES_AVX2, 3, 16, true },
|
||||
{ 9, HS_CPU_FEATURES_AVX2, 4, 16, false },
|
||||
{ 10, HS_CPU_FEATURES_AVX2, 4, 16, true },
|
||||
{ 11, 0, 1, 8, false },
|
||||
{ 12, 0, 1, 8, true },
|
||||
{ 13, 0, 2, 8, false },
|
||||
|
||||
Reference in New Issue
Block a user