mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
Fix C-style casts
This commit is contained in:
parent
db92a42681
commit
e819cb1100
@ -106,8 +106,7 @@ struct FiveTuple {
|
|||||||
dstAddr = iphdr->ip_dst.s_addr;
|
dstAddr = iphdr->ip_dst.s_addr;
|
||||||
|
|
||||||
// UDP/TCP ports
|
// UDP/TCP ports
|
||||||
const struct udphdr *uh =
|
const struct udphdr *uh = reinterpret_cast<const struct udphdr *>(iphdr) + (iphdr->ip_hl * 4);
|
||||||
(const struct udphdr *)(((const char *)iphdr) + (iphdr->ip_hl * 4));
|
|
||||||
srcPort = uh->uh_sport;
|
srcPort = uh->uh_sport;
|
||||||
dstPort = uh->uh_dport;
|
dstPort = uh->uh_dport;
|
||||||
}
|
}
|
||||||
@ -136,7 +135,7 @@ static
|
|||||||
int onMatch(unsigned int id, unsigned long long from, unsigned long long to,
|
int onMatch(unsigned int id, unsigned long long from, unsigned long long to,
|
||||||
unsigned int flags, void *ctx) {
|
unsigned int flags, void *ctx) {
|
||||||
// Our context points to a size_t storing the match count
|
// Our context points to a size_t storing the match count
|
||||||
size_t *matches = (size_t *)ctx;
|
size_t *matches = static_cast<size_t *>(ctx);
|
||||||
(*matches)++;
|
(*matches)++;
|
||||||
return 0; // continue matching
|
return 0; // continue matching
|
||||||
}
|
}
|
||||||
@ -232,9 +231,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Valid TCP or UDP packet
|
// Valid TCP or UDP packet
|
||||||
const struct ip *iphdr = (const struct ip *)(pktData
|
const struct ip *iphdr = reinterpret_cast<const struct ip *>(pktData) + sizeof(struct ether_header);
|
||||||
+ sizeof(struct ether_header));
|
const char *payload = reinterpret_cast<const char *>(pktData) + offset;
|
||||||
const char *payload = (const char *)pktData + offset;
|
|
||||||
|
|
||||||
size_t id = stream_map.insert(std::make_pair(FiveTuple(iphdr),
|
size_t id = stream_map.insert(std::make_pair(FiveTuple(iphdr),
|
||||||
stream_map.size())).first->second;
|
stream_map.size())).first->second;
|
||||||
@ -574,7 +572,7 @@ int main(int argc, char **argv) {
|
|||||||
*/
|
*/
|
||||||
static bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
|
static bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
|
||||||
unsigned int *length) {
|
unsigned int *length) {
|
||||||
const ip *iph = (const ip *)(pkt_data + sizeof(ether_header));
|
const ip *iph = reinterpret_cast<const ip *>(pkt_data) + sizeof(ether_header);
|
||||||
const tcphdr *th = nullptr;
|
const tcphdr *th = nullptr;
|
||||||
|
|
||||||
// Ignore packets that aren't IPv4
|
// Ignore packets that aren't IPv4
|
||||||
@ -593,7 +591,7 @@ static bool payloadOffset(const unsigned char *pkt_data, unsigned int *offset,
|
|||||||
|
|
||||||
switch (iph->ip_p) {
|
switch (iph->ip_p) {
|
||||||
case IPPROTO_TCP:
|
case IPPROTO_TCP:
|
||||||
th = (const tcphdr *)((const char *)iph + ihlen);
|
th = reinterpret_cast<const tcphdr *>(iph) + ihlen;
|
||||||
thlen = th->th_off * 4;
|
thlen = th->th_off * 4;
|
||||||
break;
|
break;
|
||||||
case IPPROTO_UDP:
|
case IPPROTO_UDP:
|
||||||
|
@ -478,7 +478,7 @@ hs_database_t *dbCreate(const char *in_bytecode, size_t len, u64a platform) {
|
|||||||
DEBUG_PRINTF("db size %zu\n", db_len);
|
DEBUG_PRINTF("db size %zu\n", db_len);
|
||||||
DEBUG_PRINTF("db platform %llx\n", platform);
|
DEBUG_PRINTF("db platform %llx\n", platform);
|
||||||
|
|
||||||
struct hs_database *db = (struct hs_database *)hs_database_alloc(db_len);
|
struct hs_database *db = static_cast<struct hs_database *>(hs_database_alloc(db_len));
|
||||||
if (hs_check_alloc(db) != HS_SUCCESS) {
|
if (hs_check_alloc(db) != HS_SUCCESS) {
|
||||||
hs_database_free(db);
|
hs_database_free(db);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -492,7 +492,7 @@ hs_database_t *dbCreate(const char *in_bytecode, size_t len, u64a platform) {
|
|||||||
DEBUG_PRINTF("shift is %zu\n", shift);
|
DEBUG_PRINTF("shift is %zu\n", shift);
|
||||||
|
|
||||||
db->bytecode = offsetof(struct hs_database, bytes) - shift;
|
db->bytecode = offsetof(struct hs_database, bytes) - shift;
|
||||||
char *bytecode = (char *)db + db->bytecode;
|
char *bytecode = reinterpret_cast<char *>(db) + db->bytecode;
|
||||||
assert(ISALIGNED_CL(bytecode));
|
assert(ISALIGNED_CL(bytecode));
|
||||||
|
|
||||||
db->magic = HS_DB_MAGIC;
|
db->magic = HS_DB_MAGIC;
|
||||||
@ -525,7 +525,7 @@ struct hs_database *build(NG &ng, unsigned int *length, u8 pureFlag) {
|
|||||||
throw CompileError("Internal error.");
|
throw CompileError("Internal error.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *bytecode = (const char *)(rose.get());
|
const char *bytecode = reinterpret_cast<const char *>(rose.get());
|
||||||
const platform_t p = target_to_platform(ng.cc.target_info);
|
const platform_t p = target_to_platform(ng.cc.target_info);
|
||||||
struct hs_database *db = dbCreate(bytecode, *length, p);
|
struct hs_database *db = dbCreate(bytecode, *length, p);
|
||||||
if (!db) {
|
if (!db) {
|
||||||
|
@ -57,15 +57,14 @@ extern const hs_compile_error_t hs_badalloc = {
|
|||||||
namespace ue2 {
|
namespace ue2 {
|
||||||
|
|
||||||
hs_compile_error_t *generateCompileError(const string &err, int expression) {
|
hs_compile_error_t *generateCompileError(const string &err, int expression) {
|
||||||
hs_compile_error_t *ret =
|
hs_compile_error_t *ret = static_cast<struct hs_compile_error *>(hs_misc_alloc(sizeof(hs_compile_error_t)));
|
||||||
(struct hs_compile_error *)hs_misc_alloc(sizeof(hs_compile_error_t));
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
hs_error_t e = hs_check_alloc(ret);
|
hs_error_t e = hs_check_alloc(ret);
|
||||||
if (e != HS_SUCCESS) {
|
if (e != HS_SUCCESS) {
|
||||||
hs_misc_free(ret);
|
hs_misc_free(ret);
|
||||||
return const_cast<hs_compile_error_t *>(&hs_badalloc);
|
return const_cast<hs_compile_error_t *>(&hs_badalloc);
|
||||||
}
|
}
|
||||||
char *msg = (char *)hs_misc_alloc(err.size() + 1);
|
char *msg = static_cast<char *>(hs_misc_alloc(err.size() + 1));
|
||||||
if (msg) {
|
if (msg) {
|
||||||
e = hs_check_alloc(msg);
|
e = hs_check_alloc(msg);
|
||||||
if (e != HS_SUCCESS) {
|
if (e != HS_SUCCESS) {
|
||||||
|
@ -127,7 +127,7 @@ void andMask(u8 *dest, const u8 *a, const u8 *b, u32 num_bytes) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FDRCompiler::createInitialState(FDR *fdr) {
|
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
|
/* initial state should to be 1 in each slot in the bucket up to bucket
|
||||||
* minlen - 1, and 0 thereafter */
|
* minlen - 1, and 0 thereafter */
|
||||||
@ -175,7 +175,7 @@ bytecode_ptr<FDR> FDRCompiler::setupFDR() {
|
|||||||
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
||||||
assert(fdr); // otherwise would have thrown std::bad_alloc
|
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.
|
// Write header.
|
||||||
fdr->size = size;
|
fdr->size = size;
|
||||||
|
@ -58,7 +58,7 @@ u64a make_u64a_mask(const vector<u8> &v) {
|
|||||||
u64a mask = 0;
|
u64a mask = 0;
|
||||||
size_t vlen = v.size();
|
size_t vlen = v.size();
|
||||||
size_t len = std::min(vlen, sizeof(mask));
|
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);
|
memcpy(m + sizeof(mask) - len, &v[vlen - len], len);
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
@ -245,10 +245,10 @@ bytecode_ptr<FDRConfirm> getFDRConfirm(const vector<hwlmLiteral> &lits,
|
|||||||
fdrc->groups = gm;
|
fdrc->groups = gm;
|
||||||
|
|
||||||
// After the FDRConfirm, we have the lit index array.
|
// 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);
|
u8 *ptr = fdrc_base + sizeof(*fdrc);
|
||||||
ptr = ROUNDUP_PTR(ptr, alignof(u32));
|
ptr = ROUNDUP_PTR(ptr, alignof(u32));
|
||||||
u32 *bitsToLitIndex = (u32 *)ptr;
|
u32 *bitsToLitIndex = reinterpret_cast<u32 *>(ptr);
|
||||||
ptr += bitsToLitIndexSize;
|
ptr += bitsToLitIndexSize;
|
||||||
|
|
||||||
// After the lit index array, we have the LitInfo structures themselves,
|
// 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;
|
LiteralIndex litIdx = *i;
|
||||||
|
|
||||||
// Write LitInfo header.
|
// Write LitInfo header.
|
||||||
LitInfo &finalLI = *(LitInfo *)ptr;
|
LitInfo &finalLI = *(reinterpret_cast<LitInfo *>(ptr));
|
||||||
finalLI = tmpLitInfo[litIdx];
|
finalLI = tmpLitInfo[litIdx];
|
||||||
|
|
||||||
ptr += sizeof(LitInfo); // String starts directly after LitInfo.
|
ptr += sizeof(LitInfo); // String starts directly after LitInfo.
|
||||||
@ -317,7 +317,7 @@ setupFullConfs(const vector<hwlmLiteral> &lits,
|
|||||||
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 64);
|
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 64);
|
||||||
assert(buf); // otherwise would have thrown std::bad_alloc
|
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;
|
u8 *ptr = buf.get() + totalConfSwitchSize;
|
||||||
assert(ISALIGNED_CL(ptr));
|
assert(ISALIGNED_CL(ptr));
|
||||||
|
|
||||||
|
@ -208,8 +208,8 @@ bytecode_ptr<u8> setupFDRFloodControl(const vector<hwlmLiteral> &lits,
|
|||||||
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 16);
|
auto buf = make_zeroed_bytecode_ptr<u8>(totalSize, 16);
|
||||||
assert(buf); // otherwise would have thrown std::bad_alloc
|
assert(buf); // otherwise would have thrown std::bad_alloc
|
||||||
|
|
||||||
u32 *floodHeader = (u32 *)buf.get();
|
u32 *floodHeader = reinterpret_cast<u32 *>(buf.get());
|
||||||
FDRFlood *layoutFlood = (FDRFlood *)(buf.get() + floodHeaderSize);
|
FDRFlood *layoutFlood = reinterpret_cast<FDRFlood *>(buf.get() + floodHeaderSize);
|
||||||
|
|
||||||
u32 currentFloodIndex = 0;
|
u32 currentFloodIndex = 0;
|
||||||
for (const auto &m : flood2chars) {
|
for (const auto &m : flood2chars) {
|
||||||
|
@ -328,7 +328,7 @@ bool pack(const vector<hwlmLiteral> &lits,
|
|||||||
|
|
||||||
static
|
static
|
||||||
void initReinforcedTable(u8 *rmsk) {
|
void initReinforcedTable(u8 *rmsk) {
|
||||||
u64a *mask = (u64a *)rmsk;
|
u64a *mask = reinterpret_cast<u64a *>(rmsk);
|
||||||
fill_n(mask, N_CHARS, 0x00ffffffffffffffULL);
|
fill_n(mask, N_CHARS, 0x00ffffffffffffffULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,8 +576,8 @@ bytecode_ptr<FDR> TeddyCompiler::build() {
|
|||||||
|
|
||||||
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
auto fdr = make_zeroed_bytecode_ptr<FDR>(size, 64);
|
||||||
assert(fdr); // otherwise would have thrown std::bad_alloc
|
assert(fdr); // otherwise would have thrown std::bad_alloc
|
||||||
Teddy *teddy = (Teddy *)fdr.get(); // ugly
|
Teddy *teddy = reinterpret_cast<Teddy *>(fdr.get()); // ugly
|
||||||
u8 *teddy_base = (u8 *)teddy;
|
u8 *teddy_base = reinterpret_cast<u8 *>(teddy);
|
||||||
|
|
||||||
// Write header.
|
// Write header.
|
||||||
teddy->size = size;
|
teddy->size = size;
|
||||||
|
@ -589,7 +589,7 @@ hs_error_t hs_expression_info_int(const char *expression, unsigned int flags,
|
|||||||
return HS_COMPILER_ERROR;
|
return HS_COMPILER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
hs_expr_info *rv = (hs_expr_info *)hs_misc_alloc(sizeof(*rv));
|
hs_expr_info *rv = static_cast<hs_expr_info *>(hs_misc_alloc(sizeof(*rv)));
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
*error = const_cast<hs_compile_error_t *>(&hs_enomem);
|
*error = const_cast<hs_compile_error_t *>(&hs_enomem);
|
||||||
return HS_COMPILER_ERROR;
|
return HS_COMPILER_ERROR;
|
||||||
|
@ -155,6 +155,7 @@ bytecode_ptr<HWLM> hwlmBuild(const HWLMProto &proto, const CompileContext &cc,
|
|||||||
auto h = make_zeroed_bytecode_ptr<HWLM>(hwlm_len, 64);
|
auto h = make_zeroed_bytecode_ptr<HWLM>(hwlm_len, 64);
|
||||||
|
|
||||||
h->type = proto.engType;
|
h->type = proto.engType;
|
||||||
|
// cppcheck-suppress cstyleCast
|
||||||
memcpy(HWLM_DATA(h.get()), eng.get(), engSize);
|
memcpy(HWLM_DATA(h.get()), eng.get(), engSize);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
@ -218,10 +219,12 @@ size_t hwlmSize(const HWLM *h) {
|
|||||||
|
|
||||||
switch (h->type) {
|
switch (h->type) {
|
||||||
case HWLM_ENGINE_NOOD:
|
case HWLM_ENGINE_NOOD:
|
||||||
engSize = noodSize((const noodTable *)HWLM_C_DATA(h));
|
// cppcheck-suppress cstyleCast
|
||||||
|
engSize = noodSize(reinterpret_cast<const noodTable *>(HWLM_C_DATA(h)));
|
||||||
break;
|
break;
|
||||||
case HWLM_ENGINE_FDR:
|
case HWLM_ENGINE_FDR:
|
||||||
engSize = fdrSize((const FDR *)HWLM_C_DATA(h));
|
// cppcheck-suppress cstyleCast
|
||||||
|
engSize = fdrSize(reinterpret_cast<const FDR *>(HWLM_C_DATA(h)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ u64a make_u64a_mask(const vector<u8> &v) {
|
|||||||
|
|
||||||
u64a mask = 0;
|
u64a mask = 0;
|
||||||
size_t len = v.size();
|
size_t len = v.size();
|
||||||
unsigned char *m = (unsigned char *)&mask;
|
u8 *m = reinterpret_cast<u8 *>(&mask);
|
||||||
DEBUG_PRINTF("making mask len %zu\n", len);
|
DEBUG_PRINTF("making mask len %zu\n", len);
|
||||||
memcpy(m, &v[0], len);
|
memcpy(m, &v[0], len);
|
||||||
return mask;
|
return mask;
|
||||||
|
@ -426,7 +426,7 @@ void
|
|||||||
accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
||||||
const AccelScheme &info,
|
const AccelScheme &info,
|
||||||
void *accel_out) {
|
void *accel_out) {
|
||||||
AccelAux *accel = (AccelAux *)accel_out;
|
AccelAux *accel = reinterpret_cast<AccelAux *>(accel_out);
|
||||||
|
|
||||||
DEBUG_PRINTF("accelerations scheme has offset s%u/d%u\n", info.offset,
|
DEBUG_PRINTF("accelerations scheme has offset s%u/d%u\n", info.offset,
|
||||||
info.double_offset);
|
info.double_offset);
|
||||||
@ -473,7 +473,8 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
u8 c1 = info.double_byte.begin()->first & m1;
|
u8 c1 = info.double_byte.begin()->first & m1;
|
||||||
u8 c2 = info.double_byte.begin()->second & m2;
|
u8 c2 = info.double_byte.begin()->second & m2;
|
||||||
#ifdef HAVE_SVE2
|
#ifdef HAVE_SVE2
|
||||||
if (vermicelliDoubleMasked16Build(c1, c2, m1, m2, (u8 *)&accel->mdverm16.mask)) {
|
if (vermicelliDoubleMasked16Build(c1, c2, m1, m2,
|
||||||
|
reinterpret_cast<u8 *>(&accel->mdverm16.mask))) {
|
||||||
accel->accel_type = ACCEL_DVERM16_MASKED;
|
accel->accel_type = ACCEL_DVERM16_MASKED;
|
||||||
accel->mdverm16.offset = verify_u8(info.double_offset);
|
accel->mdverm16.offset = verify_u8(info.double_offset);
|
||||||
accel->mdverm16.c1 = c1;
|
accel->mdverm16.c1 = c1;
|
||||||
@ -482,8 +483,9 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
c1, c2);
|
c1, c2);
|
||||||
return;
|
return;
|
||||||
} else if (info.double_byte.size() <= 8 &&
|
} else if (info.double_byte.size() <= 8 &&
|
||||||
vermicelliDouble16Build(info.double_byte, (u8 *)&accel->dverm16.mask,
|
vermicelliDouble16Build(info.double_byte,
|
||||||
(u8 *)&accel->dverm16.firsts)) {
|
reinterpret_cast<u8 *>(&accel->dverm16.mask),
|
||||||
|
reinterpret_cast<u8 *>(&accel->dverm16.firsts))) {
|
||||||
accel->accel_type = ACCEL_DVERM16;
|
accel->accel_type = ACCEL_DVERM16;
|
||||||
accel->dverm16.offset = verify_u8(info.double_offset);
|
accel->dverm16.offset = verify_u8(info.double_offset);
|
||||||
DEBUG_PRINTF("building double16-vermicelli\n");
|
DEBUG_PRINTF("building double16-vermicelli\n");
|
||||||
@ -503,8 +505,9 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
}
|
}
|
||||||
#ifdef HAVE_SVE2
|
#ifdef HAVE_SVE2
|
||||||
if (info.double_byte.size() <= 8 &&
|
if (info.double_byte.size() <= 8 &&
|
||||||
vermicelliDouble16Build(info.double_byte, (u8 *)&accel->dverm16.mask,
|
vermicelliDouble16Build(info.double_byte,
|
||||||
(u8 *)&accel->dverm16.firsts)) {
|
reinterpret_cast<u8 *>(&accel->dverm16.mask),
|
||||||
|
reinterpret_cast<u8 *>(&accel->dverm16.firsts))) {
|
||||||
accel->accel_type = ACCEL_DVERM16;
|
accel->accel_type = ACCEL_DVERM16;
|
||||||
accel->dverm16.offset = verify_u8(info.double_offset);
|
accel->dverm16.offset = verify_u8(info.double_offset);
|
||||||
DEBUG_PRINTF("building double16-vermicelli\n");
|
DEBUG_PRINTF("building double16-vermicelli\n");
|
||||||
@ -515,9 +518,11 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
|
|
||||||
if (double_byte_ok(info) &&
|
if (double_byte_ok(info) &&
|
||||||
shuftiBuildDoubleMasks(
|
shuftiBuildDoubleMasks(
|
||||||
info.double_cr, info.double_byte, (u8 *)&accel->dshufti.lo1,
|
info.double_cr, info.double_byte,
|
||||||
(u8 *)&accel->dshufti.hi1, (u8 *)&accel->dshufti.lo2,
|
reinterpret_cast<u8 *>(&accel->dshufti.lo1),
|
||||||
(u8 *)&accel->dshufti.hi2)) {
|
reinterpret_cast<u8 *>(&accel->dshufti.hi1),
|
||||||
|
reinterpret_cast<u8 *>(&accel->dshufti.lo2),
|
||||||
|
reinterpret_cast<u8 *>(&accel->dshufti.hi2))) {
|
||||||
accel->accel_type = ACCEL_DSHUFTI;
|
accel->accel_type = ACCEL_DSHUFTI;
|
||||||
accel->dshufti.offset = verify_u8(info.double_offset);
|
accel->dshufti.offset = verify_u8(info.double_offset);
|
||||||
DEBUG_PRINTF("state %hu is double shufti\n", this_idx);
|
DEBUG_PRINTF("state %hu is double shufti\n", this_idx);
|
||||||
@ -549,7 +554,7 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
#ifdef HAVE_SVE2
|
#ifdef HAVE_SVE2
|
||||||
if (info.cr.count() <= 16) {
|
if (info.cr.count() <= 16) {
|
||||||
accel->accel_type = ACCEL_VERM16;
|
accel->accel_type = ACCEL_VERM16;
|
||||||
vermicelli16Build(info.cr, (u8 *)&accel->verm16.mask);
|
vermicelli16Build(info.cr, reinterpret_cast<u8 *>(&accel->verm16.mask));
|
||||||
DEBUG_PRINTF("state %hu is vermicelli16\n", this_idx);
|
DEBUG_PRINTF("state %hu is vermicelli16\n", this_idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -562,16 +567,18 @@ accel_dfa_build_strat::buildAccel(UNUSED dstate_id_t this_idx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
accel->accel_type = ACCEL_SHUFTI;
|
accel->accel_type = ACCEL_SHUFTI;
|
||||||
if (-1 != shuftiBuildMasks(info.cr, (u8 *)&accel->shufti.lo,
|
if (-1 != shuftiBuildMasks(info.cr,
|
||||||
(u8 *)&accel->shufti.hi)) {
|
reinterpret_cast<u8 *>(&accel->shufti.lo),
|
||||||
|
reinterpret_cast<u8 *>(&accel->shufti.hi))) {
|
||||||
DEBUG_PRINTF("state %hu is shufti\n", this_idx);
|
DEBUG_PRINTF("state %hu is shufti\n", this_idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!info.cr.none());
|
assert(!info.cr.none());
|
||||||
accel->accel_type = ACCEL_TRUFFLE;
|
accel->accel_type = ACCEL_TRUFFLE;
|
||||||
truffleBuildMasks(info.cr, (u8 *)&accel->truffle.mask1,
|
truffleBuildMasks(info.cr,
|
||||||
(u8 *)&accel->truffle.mask2);
|
reinterpret_cast<u8 *>(&accel->truffle.mask1),
|
||||||
|
reinterpret_cast<u8 *>(&accel->truffle.mask2));
|
||||||
DEBUG_PRINTF("state %hu is truffle\n", this_idx);
|
DEBUG_PRINTF("state %hu is truffle\n", this_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +84,9 @@ void buildAccelSingle(const AccelInfo &info, AccelAux *aux) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
DEBUG_PRINTF("attempting shufti for %zu chars\n", outs);
|
DEBUG_PRINTF("attempting shufti for %zu chars\n", outs);
|
||||||
if (-1 != shuftiBuildMasks(info.single_stops, (u8 *)&aux->shufti.lo,
|
if (-1 != shuftiBuildMasks(info.single_stops,
|
||||||
(u8 *)&aux->shufti.hi)) {
|
reinterpret_cast<u8 *>(&aux->shufti.lo),
|
||||||
|
reinterpret_cast<u8 *>(&aux->shufti.hi))) {
|
||||||
aux->accel_type = ACCEL_SHUFTI;
|
aux->accel_type = ACCEL_SHUFTI;
|
||||||
aux->shufti.offset = offset;
|
aux->shufti.offset = offset;
|
||||||
DEBUG_PRINTF("shufti built OK\n");
|
DEBUG_PRINTF("shufti built OK\n");
|
||||||
@ -98,8 +99,9 @@ void buildAccelSingle(const AccelInfo &info, AccelAux *aux) {
|
|||||||
DEBUG_PRINTF("building Truffle for %zu chars\n", outs);
|
DEBUG_PRINTF("building Truffle for %zu chars\n", outs);
|
||||||
aux->accel_type = ACCEL_TRUFFLE;
|
aux->accel_type = ACCEL_TRUFFLE;
|
||||||
aux->truffle.offset = offset;
|
aux->truffle.offset = offset;
|
||||||
truffleBuildMasks(info.single_stops, (u8 *)&aux->truffle.mask1,
|
truffleBuildMasks(info.single_stops,
|
||||||
(u8 *)&aux->truffle.mask2);
|
reinterpret_cast<u8 *>(&aux->truffle.mask1),
|
||||||
|
reinterpret_cast<u8 *>(&aux->truffle.mask2));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +221,9 @@ void buildAccelDouble(const AccelInfo &info, AccelAux *aux) {
|
|||||||
c1, c2);
|
c1, c2);
|
||||||
return;
|
return;
|
||||||
} else if (outs2 <= 8 &&
|
} else if (outs2 <= 8 &&
|
||||||
vermicelliDouble16Build(info.double_stop2, (u8 *)&aux->dverm16.mask,
|
vermicelliDouble16Build(info.double_stop2,
|
||||||
(u8 *)&aux->dverm16.firsts)) {
|
reinterpret_cast<u8 *>(&aux->dverm16.mask),
|
||||||
|
reinterpret_cast<u8 *>(&aux->dverm16.firsts))) {
|
||||||
aux->accel_type = ACCEL_DVERM16;
|
aux->accel_type = ACCEL_DVERM16;
|
||||||
aux->dverm16.offset = offset;
|
aux->dverm16.offset = offset;
|
||||||
DEBUG_PRINTF("building double16-vermicelli\n");
|
DEBUG_PRINTF("building double16-vermicelli\n");
|
||||||
@ -254,9 +257,11 @@ void buildAccelDouble(const AccelInfo &info, AccelAux *aux) {
|
|||||||
aux->accel_type = ACCEL_DSHUFTI;
|
aux->accel_type = ACCEL_DSHUFTI;
|
||||||
aux->dshufti.offset = offset;
|
aux->dshufti.offset = offset;
|
||||||
if (shuftiBuildDoubleMasks(
|
if (shuftiBuildDoubleMasks(
|
||||||
info.double_stop1, info.double_stop2, (u8 *)&aux->dshufti.lo1,
|
info.double_stop1, info.double_stop2,
|
||||||
(u8 *)&aux->dshufti.hi1, (u8 *)&aux->dshufti.lo2,
|
reinterpret_cast<u8 *>(&aux->dshufti.lo1),
|
||||||
(u8 *)&aux->dshufti.hi2)) {
|
reinterpret_cast<u8 *>(&aux->dshufti.hi1),
|
||||||
|
reinterpret_cast<u8 *>(&aux->dshufti.lo2),
|
||||||
|
reinterpret_cast<u8 *>(&aux->dshufti.hi2))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,25 +106,27 @@ void writeCastleScanEngine(const CharReach &cr, Castle *c) {
|
|||||||
#ifdef HAVE_SVE2
|
#ifdef HAVE_SVE2
|
||||||
if (cr.count() <= 16) {
|
if (cr.count() <= 16) {
|
||||||
c->type = CASTLE_NVERM16;
|
c->type = CASTLE_NVERM16;
|
||||||
vermicelli16Build(cr, (u8 *)&c->u.verm16.mask);
|
vermicelli16Build(cr, reinterpret_cast<u8 *>(&c->u.verm16.mask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (negated.count() <= 16) {
|
if (negated.count() <= 16) {
|
||||||
c->type = CASTLE_VERM16;
|
c->type = CASTLE_VERM16;
|
||||||
vermicelli16Build(negated, (u8 *)&c->u.verm16.mask);
|
vermicelli16Build(negated, reinterpret_cast<u8 *>(&c->u.verm16.mask));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif // HAVE_SVE2
|
#endif // HAVE_SVE2
|
||||||
|
|
||||||
if (shuftiBuildMasks(negated, (u8 *)&c->u.shuf.mask_lo,
|
if (shuftiBuildMasks(negated,
|
||||||
(u8 *)&c->u.shuf.mask_hi) != -1) {
|
reinterpret_cast<u8 *>(&c->u.shuf.mask_lo),
|
||||||
|
reinterpret_cast<u8 *>(&c->u.shuf.mask_hi)) != -1) {
|
||||||
c->type = CASTLE_SHUFTI;
|
c->type = CASTLE_SHUFTI;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->type = CASTLE_TRUFFLE;
|
c->type = CASTLE_TRUFFLE;
|
||||||
truffleBuildMasks(negated, (u8 *)(u8 *)&c->u.truffle.mask1,
|
truffleBuildMasks(negated,
|
||||||
(u8 *)&c->u.truffle.mask2);
|
reinterpret_cast<u8 *>(&c->u.truffle.mask1),
|
||||||
|
reinterpret_cast<u8 *>(&c->u.truffle.mask2));
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
@ -602,9 +604,9 @@ buildCastle(const CastleProto &proto,
|
|||||||
nfa->minWidth = verify_u32(minWidth);
|
nfa->minWidth = verify_u32(minWidth);
|
||||||
nfa->maxWidth = maxWidth.is_finite() ? verify_u32(maxWidth) : 0;
|
nfa->maxWidth = maxWidth.is_finite() ? verify_u32(maxWidth) : 0;
|
||||||
|
|
||||||
char * const base_ptr = (char *)nfa.get() + sizeof(NFA);
|
char * const base_ptr = reinterpret_cast<char *>(nfa.get()) + sizeof(NFA);
|
||||||
char *ptr = base_ptr;
|
char *ptr = base_ptr;
|
||||||
Castle *c = (Castle *)ptr;
|
Castle *c = reinterpret_cast<Castle *>(ptr);
|
||||||
c->numRepeats = verify_u32(subs.size());
|
c->numRepeats = verify_u32(subs.size());
|
||||||
c->numGroups = exclusiveInfo.numGroups;
|
c->numGroups = exclusiveInfo.numGroups;
|
||||||
c->exclusive = verify_s8(exclusive);
|
c->exclusive = verify_s8(exclusive);
|
||||||
@ -615,7 +617,7 @@ buildCastle(const CastleProto &proto,
|
|||||||
writeCastleScanEngine(cr, c);
|
writeCastleScanEngine(cr, c);
|
||||||
|
|
||||||
ptr += sizeof(Castle);
|
ptr += sizeof(Castle);
|
||||||
SubCastle *subCastles = ((SubCastle *)(ROUNDUP_PTR(ptr, alignof(u32))));
|
SubCastle *subCastles = reinterpret_cast<SubCastle *>(ROUNDUP_PTR(ptr, alignof(u32)));
|
||||||
copy(subs.begin(), subs.end(), subCastles);
|
copy(subs.begin(), subs.end(), subCastles);
|
||||||
|
|
||||||
u32 length = 0;
|
u32 length = 0;
|
||||||
@ -625,16 +627,16 @@ buildCastle(const CastleProto &proto,
|
|||||||
SubCastle *sub = &subCastles[i];
|
SubCastle *sub = &subCastles[i];
|
||||||
sub->repeatInfoOffset = offset;
|
sub->repeatInfoOffset = offset;
|
||||||
|
|
||||||
ptr = (char *)sub + offset;
|
ptr = reinterpret_cast<char *>(sub) + offset;
|
||||||
memcpy(ptr, &infos[i], sizeof(RepeatInfo));
|
memcpy(ptr, &infos[i], sizeof(RepeatInfo));
|
||||||
|
|
||||||
if (patchSize[i]) {
|
if (patchSize[i]) {
|
||||||
RepeatInfo *info = (RepeatInfo *)ptr;
|
RepeatInfo *info = reinterpret_cast<RepeatInfo *>(ptr);
|
||||||
u64a *table = ((u64a *)(ROUNDUP_PTR(((char *)(info) +
|
u64a *table = reinterpret_cast<u64a *>(ROUNDUP_PTR(info +
|
||||||
sizeof(*info)), alignof(u64a))));
|
sizeof(*info), alignof(u64a)));
|
||||||
copy(tables.begin() + tableIdx,
|
copy(tables.begin() + tableIdx,
|
||||||
tables.begin() + tableIdx + patchSize[i], table);
|
tables.begin() + tableIdx + patchSize[i], table);
|
||||||
u32 diff = (char *)table - (char *)info +
|
u32 diff = reinterpret_cast<ptrdiff_t>(table) - reinterpret_cast<ptrdiff_t>(info) +
|
||||||
sizeof(u64a) * patchSize[i];
|
sizeof(u64a) * patchSize[i];
|
||||||
info->length = diff;
|
info->length = diff;
|
||||||
length += diff;
|
length += diff;
|
||||||
@ -657,8 +659,6 @@ buildCastle(const CastleProto &proto,
|
|||||||
if (!stale_iter.empty()) {
|
if (!stale_iter.empty()) {
|
||||||
c->staleIterOffset = verify_u32(ptr - base_ptr);
|
c->staleIterOffset = verify_u32(ptr - base_ptr);
|
||||||
copy_bytes(ptr, stale_iter);
|
copy_bytes(ptr, stale_iter);
|
||||||
// Removed unused increment operation
|
|
||||||
// ptr += byte_length(stale_iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nfa;
|
return nfa;
|
||||||
|
@ -1077,8 +1077,9 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
|
|||||||
return bytecode_ptr<NFA>(nullptr);
|
return bytecode_ptr<NFA>(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 alphaShift
|
// cppcheck-suppress cstyleCast
|
||||||
= ((const mcclellan *)getImplNfa(basic_dfa.get()))->alphaShift;
|
const auto nfa = static_cast<const mcclellan *>(getImplNfa(basic_dfa.get()));
|
||||||
|
u8 alphaShift = nfa->alphaShift;
|
||||||
u32 edge_count = (1U << alphaShift) * raw.states.size();
|
u32 edge_count = (1U << alphaShift) * raw.states.size();
|
||||||
|
|
||||||
u32 curr_offset = ROUNDUP_N(basic_dfa->length, 4);
|
u32 curr_offset = ROUNDUP_N(basic_dfa->length, 4);
|
||||||
@ -1119,8 +1120,8 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
|
|||||||
u32 gough_size = ROUNDUP_N(curr_offset, 16);
|
u32 gough_size = ROUNDUP_N(curr_offset, 16);
|
||||||
auto gough_dfa = make_zeroed_bytecode_ptr<NFA>(gough_size);
|
auto gough_dfa = make_zeroed_bytecode_ptr<NFA>(gough_size);
|
||||||
|
|
||||||
memcpy(gough_dfa.get(), basic_dfa.get(), basic_dfa->length);
|
memcpy(reinterpret_cast<char *>(gough_dfa.get()), basic_dfa.get(), basic_dfa->length);
|
||||||
memcpy((char *)gough_dfa.get() + haig_offset, &gi, sizeof(gi));
|
memcpy(reinterpret_cast<char *>(gough_dfa.get()) + haig_offset, &gi, sizeof(gi));
|
||||||
if (gough_dfa->type == MCCLELLAN_NFA_16) {
|
if (gough_dfa->type == MCCLELLAN_NFA_16) {
|
||||||
gough_dfa->type = GOUGH_NFA_16;
|
gough_dfa->type = GOUGH_NFA_16;
|
||||||
} else {
|
} else {
|
||||||
@ -1133,18 +1134,19 @@ bytecode_ptr<NFA> goughCompile(raw_som_dfa &raw, u8 somPrecision,
|
|||||||
gough_dfa->streamStateSize = base_state_size + slot_count * somPrecision;
|
gough_dfa->streamStateSize = base_state_size + slot_count * somPrecision;
|
||||||
gough_dfa->scratchStateSize = (u32)(16 + scratch_slot_count * sizeof(u64a));
|
gough_dfa->scratchStateSize = (u32)(16 + scratch_slot_count * sizeof(u64a));
|
||||||
|
|
||||||
mcclellan *m = (mcclellan *)getMutableImplNfa(gough_dfa.get());
|
// cppcheck-suppress cstyleCast
|
||||||
|
auto *m = reinterpret_cast<mcclellan *>(getMutableImplNfa(gough_dfa.get()));
|
||||||
m->haig_offset = haig_offset;
|
m->haig_offset = haig_offset;
|
||||||
|
|
||||||
/* update nfa length, haig_info offset (leave mcclellan length alone) */
|
/* update nfa length, haig_info offset (leave mcclellan length alone) */
|
||||||
gough_dfa->length = gough_size;
|
gough_dfa->length = gough_size;
|
||||||
|
|
||||||
/* copy in blocks */
|
/* copy in blocks */
|
||||||
copy_bytes((u8 *)gough_dfa.get() + edge_prog_offset, edge_blocks);
|
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + edge_prog_offset, edge_blocks);
|
||||||
if (top_prog_offset) {
|
if (top_prog_offset) {
|
||||||
copy_bytes((u8 *)gough_dfa.get() + top_prog_offset, top_blocks);
|
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + top_prog_offset, top_blocks);
|
||||||
}
|
}
|
||||||
copy_bytes((u8 *)gough_dfa.get() + prog_base_offset, temp_blocks);
|
copy_bytes(reinterpret_cast<u8 *>(gough_dfa.get()) + prog_base_offset, temp_blocks);
|
||||||
|
|
||||||
return gough_dfa;
|
return gough_dfa;
|
||||||
}
|
}
|
||||||
@ -1177,7 +1179,7 @@ AccelScheme gough_build_strat::find_escape_strings(dstate_id_t this_idx) const {
|
|||||||
void gough_build_strat::buildAccel(dstate_id_t this_idx, const AccelScheme &info,
|
void gough_build_strat::buildAccel(dstate_id_t this_idx, const AccelScheme &info,
|
||||||
void *accel_out) {
|
void *accel_out) {
|
||||||
assert(mcclellan_build_strat::accelSize() == sizeof(AccelAux));
|
assert(mcclellan_build_strat::accelSize() == sizeof(AccelAux));
|
||||||
gough_accel *accel = (gough_accel *)accel_out;
|
gough_accel *accel = reinterpret_cast<gough_accel *>(accel_out);
|
||||||
/* build a plain accelaux so we can work out where we can get to */
|
/* build a plain accelaux so we can work out where we can get to */
|
||||||
mcclellan_build_strat::buildAccel(this_idx, info, &accel->accel);
|
mcclellan_build_strat::buildAccel(this_idx, info, &accel->accel);
|
||||||
DEBUG_PRINTF("state %hu is accel with type %hhu\n", this_idx,
|
DEBUG_PRINTF("state %hu is accel with type %hhu\n", this_idx,
|
||||||
@ -1315,7 +1317,8 @@ void raw_gough_report_info_impl::fillReportLists(NFA *n, size_t base_offset,
|
|||||||
for (const raw_gough_report_list &r : rl) {
|
for (const raw_gough_report_list &r : rl) {
|
||||||
ro.emplace_back(base_offset);
|
ro.emplace_back(base_offset);
|
||||||
|
|
||||||
gough_report_list *p = (gough_report_list *)((char *)n + base_offset);
|
u8 * n_ptr = reinterpret_cast<u8 *>(n);
|
||||||
|
gough_report_list *p = reinterpret_cast<gough_report_list *>(n_ptr + base_offset);
|
||||||
u32 i = 0;
|
u32 i = 0;
|
||||||
|
|
||||||
for (const som_report &sr : r.reports) {
|
for (const som_report &sr : r.reports) {
|
||||||
|
@ -194,7 +194,7 @@ void handle_pending_vars(GoughSSAVar *def, const GoughGraph &g,
|
|||||||
if (contains(aux.containing_v, var)) {
|
if (contains(aux.containing_v, var)) {
|
||||||
/* def is used by join vertex, value only needs to be live on some
|
/* def is used by join vertex, value only needs to be live on some
|
||||||
* incoming edges */
|
* incoming edges */
|
||||||
const GoughSSAVarJoin *vj = (GoughSSAVarJoin *)var;
|
const GoughSSAVarJoin *vj = reinterpret_cast<const GoughSSAVarJoin *>(var);
|
||||||
const flat_set<GoughEdge> &live_edges
|
const flat_set<GoughEdge> &live_edges
|
||||||
= vj->get_edges_for_input(def);
|
= vj->get_edges_for_input(def);
|
||||||
for (const auto &e : live_edges) {
|
for (const auto &e : live_edges) {
|
||||||
|
@ -264,7 +264,7 @@ const u8 *shuftiDoubleExecReal(m128 mask1_lo, m128 mask1_hi, m128 mask2_lo, m128
|
|||||||
const u8 *shuftiExec(m128 mask_lo, m128 mask_hi, const u8 *buf,
|
const u8 *shuftiExec(m128 mask_lo, m128 mask_hi, const u8 *buf,
|
||||||
const u8 *buf_end) {
|
const u8 *buf_end) {
|
||||||
if (buf_end - buf < VECTORSIZE) {
|
if (buf_end - buf < VECTORSIZE) {
|
||||||
return shuftiFwdSlow((const u8 *)&mask_lo, (const u8 *)&mask_hi, buf, buf_end);
|
return shuftiFwdSlow(reinterpret_cast<const u8 *>(&mask_lo), reinterpret_cast<const u8 *>(&mask_hi), buf, buf_end);
|
||||||
}
|
}
|
||||||
return shuftiExecReal<VECTORSIZE>(mask_lo, mask_hi, buf, buf_end);
|
return shuftiExecReal<VECTORSIZE>(mask_lo, mask_hi, buf, buf_end);
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ const u8 *shuftiExec(m128 mask_lo, m128 mask_hi, const u8 *buf,
|
|||||||
const u8 *rshuftiExec(m128 mask_lo, m128 mask_hi, const u8 *buf,
|
const u8 *rshuftiExec(m128 mask_lo, m128 mask_hi, const u8 *buf,
|
||||||
const u8 *buf_end) {
|
const u8 *buf_end) {
|
||||||
if (buf_end - buf < VECTORSIZE) {
|
if (buf_end - buf < VECTORSIZE) {
|
||||||
return shuftiRevSlow((const u8 *)&mask_lo, (const u8 *)&mask_hi, buf, buf_end);
|
return shuftiRevSlow(reinterpret_cast<const u8 *>(&mask_lo), reinterpret_cast<const u8 *>(&mask_hi), buf, buf_end);
|
||||||
}
|
}
|
||||||
return rshuftiExecReal<VECTORSIZE>(mask_lo, mask_hi, buf, buf_end);
|
return rshuftiExecReal<VECTORSIZE>(mask_lo, mask_hi, buf, buf_end);
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ u8 decodeCtrl(char raw) {
|
|||||||
|
|
||||||
static
|
static
|
||||||
unichar readUtf8CodePoint2c(const char *s) {
|
unichar readUtf8CodePoint2c(const char *s) {
|
||||||
auto *ts = (const u8 *)s;
|
auto *ts = reinterpret_cast<const u8 *>(s);
|
||||||
assert(ts[0] >= 0xc0 && ts[0] < 0xe0);
|
assert(ts[0] >= 0xc0 && ts[0] < 0xe0);
|
||||||
assert(ts[1] >= 0x80 && ts[1] < 0xc0);
|
assert(ts[1] >= 0x80 && ts[1] < 0xc0);
|
||||||
unichar val = ts[0] & 0x1f;
|
unichar val = ts[0] & 0x1f;
|
||||||
|
@ -68,6 +68,7 @@ namespace ue2 {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *aligned_malloc_internal(size_t size, size_t align) {
|
void *aligned_malloc_internal(size_t size, size_t align) {
|
||||||
|
// cppcheck-suppress cstyleCast
|
||||||
void *mem= nullptr;;
|
void *mem= nullptr;;
|
||||||
int rv = posix_memalign(&mem, align, size);
|
int rv = posix_memalign(&mem, align, size);
|
||||||
if (rv != 0) {
|
if (rv != 0) {
|
||||||
@ -104,17 +105,17 @@ void *aligned_zmalloc(size_t size) {
|
|||||||
|
|
||||||
const size_t alloc_size = size + HACK_OFFSET;
|
const size_t alloc_size = size + HACK_OFFSET;
|
||||||
|
|
||||||
void *mem = aligned_malloc_internal(alloc_size, 64);
|
char *mem = static_cast<char *>(aligned_malloc_internal(alloc_size, 64));
|
||||||
if (!mem) {
|
if (!mem) {
|
||||||
DEBUG_PRINTF("unable to allocate %zu bytes\n", alloc_size);
|
DEBUG_PRINTF("unable to allocate %zu bytes\n", alloc_size);
|
||||||
throw std::bad_alloc();
|
throw std::bad_alloc();
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_PRINTF("alloced %p reporting %p\n", mem, (char *)mem + HACK_OFFSET);
|
DEBUG_PRINTF("alloced %p reporting %p\n", mem, mem + HACK_OFFSET);
|
||||||
assert(ISALIGNED_N(mem, 64));
|
assert(ISALIGNED_N(mem, 64));
|
||||||
|
|
||||||
memset(mem, 0, alloc_size);
|
memset(mem, 0, alloc_size);
|
||||||
return (void *)((char *)mem + HACK_OFFSET);
|
return reinterpret_cast<void *>(mem + HACK_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Free a pointer allocated with \ref aligned_zmalloc. */
|
/** \brief Free a pointer allocated with \ref aligned_zmalloc. */
|
||||||
@ -123,7 +124,7 @@ void aligned_free(void *ptr) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *addr = (void *)((char *)ptr - HACK_OFFSET);
|
ptrdiff_t *addr = static_cast<ptrdiff_t *>(ptr) - HACK_OFFSET;
|
||||||
DEBUG_PRINTF("asked to free %p freeing %p\n", ptr, addr);
|
DEBUG_PRINTF("asked to free %p freeing %p\n", ptr, addr);
|
||||||
|
|
||||||
assert(ISALIGNED_N(addr, 64));
|
assert(ISALIGNED_N(addr, 64));
|
||||||
|
@ -511,7 +511,7 @@ really_inline SuperVector<16> SuperVector<16>::Ones_vshl(uint8_t const N)
|
|||||||
template <>
|
template <>
|
||||||
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
|
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
|
||||||
{
|
{
|
||||||
return {SuperVector<16>(vld1q_s32((const int32_t *)ptr))};
|
return {SuperVector<16>(vld1q_s32(reinterpret_cast<const int32_t *>(ptr)))};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -519,7 +519,7 @@ really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
|
|||||||
{
|
{
|
||||||
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
|
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
|
||||||
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
|
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
|
||||||
return {SuperVector<16>(vld1q_s32((const int32_t *)ptr))};
|
return {SuperVector<16>(vld1q_s32(reinterpret_cast<const int32_t *>(ptr)))};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@ -508,7 +508,7 @@ really_inline SuperVector<16> SuperVector<16>::Ones_vshl(uint8_t const N)
|
|||||||
template <>
|
template <>
|
||||||
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
|
really_inline SuperVector<16> SuperVector<16>::loadu(void const *ptr)
|
||||||
{
|
{
|
||||||
return SuperVector<16>(_mm_loadu_si128((const m128 *)ptr));
|
return SuperVector<16>(_mm_loadu_si128(reinterpret_cast<const m128 *>(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
@ -516,14 +516,14 @@ really_inline SuperVector<16> SuperVector<16>::load(void const *ptr)
|
|||||||
{
|
{
|
||||||
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
|
assert(ISALIGNED_N(ptr, alignof(SuperVector::size)));
|
||||||
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
|
ptr = vectorscan_assume_aligned(ptr, SuperVector::size);
|
||||||
return SuperVector<16>(_mm_load_si128((const m128 *)ptr));
|
return SuperVector<16>(_mm_load_si128(reinterpret_cast<const m128 *>(ptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
really_inline SuperVector<16> SuperVector<16>::loadu_maskz(void const *ptr, uint8_t const len)
|
really_inline SuperVector<16> SuperVector<16>::loadu_maskz(void const *ptr, uint8_t const len)
|
||||||
{
|
{
|
||||||
SuperVector mask = Ones_vshr(16 -len);
|
SuperVector mask = Ones_vshr(16 -len);
|
||||||
SuperVector v = SuperVector<16>(_mm_loadu_si128((const m128 *)ptr));
|
SuperVector v = SuperVector<16>(_mm_loadu_si128(reinterpret_cast<const m128 *>(ptr)));
|
||||||
return mask & v;
|
return mask & v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user