static
mstate_aux *getAux(NFA *n, dstate_id_t i) {
- const mcsheng *m = (mcsheng *)getMutableImplNfa(n);
- mstate_aux *aux_base = (mstate_aux *)((char *)n + m->aux_offset);
+ const mcsheng *m = reinterpret_cast<const mcsheng *>(getMutableImplNfa(n));
+ mstate_aux *aux_base = reinterpret_cast<mstate_aux *>(reinterpret_cast<u8 *>(n) + m->aux_offset);
mstate_aux *aux = aux_base + i;
- assert((const char *)aux < (const char *)n + m->length);
+ assert(reinterpret_cast<const char *>(aux) < reinterpret_cast<const char *>(n) + m->length);
return aux;
}
}
for (u32 i = 0; i < N_CHARS; i++) {
assert(info.alpha_remap[i] != info.alpha_remap[TOP]);
- memcpy((u8 *)&m->sheng_masks[i],
- (u8 *)masks[info.alpha_remap[i]].data(), sizeof(m128));
+ memcpy(reinterpret_cast<u8 *>(&m->sheng_masks[i]),
+ reinterpret_cast<u8 *>(masks[info.alpha_remap[i]].data()), sizeof(m128));
}
m->sheng_end = sheng_end;
m->sheng_accel_limit = sheng_end - 1;
nfa->type = MCSHENG_NFA_16;
}
- mcsheng *m = (mcsheng *)getMutableImplNfa(nfa);
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa));
for (u32 i = 0; i < 256; i++) {
m->remap[i] = verify_u8(info.alpha_remap[i]);
}
static
mstate_aux *getAux64(NFA *n, dstate_id_t i) {
- const mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(n);
- mstate_aux *aux_base = (mstate_aux *)((char *)n + m->aux_offset);
+ const mcsheng64 *m = reinterpret_cast<const mcsheng64 *>(getMutableImplNfa(n));
+ mstate_aux *aux_base = reinterpret_cast<mstate_aux *>(reinterpret_cast<u8 *>(n) + m->aux_offset);
mstate_aux *aux = aux_base + i;
- assert((const char *)aux < (const char *)n + m->length);
+ assert(reinterpret_cast<const char *>(aux) < reinterpret_cast<const char *>(n) + m->length);
return aux;
}
}
for (u32 i = 0; i < N_CHARS; i++) {
assert(info.alpha_remap[i] != info.alpha_remap[TOP]);
- memcpy((u8 *)&m->sheng_succ_masks[i],
- (u8 *)masks[info.alpha_remap[i]].data(), sizeof(m512));
+ memcpy(reinterpret_cast<u8 *>(&m->sheng_succ_masks[i]),
+ reinterpret_cast<u8 *>(masks[info.alpha_remap[i]].data()), sizeof(m512));
}
m->sheng_end = sheng_end;
m->sheng_accel_limit = sheng_end - 1;
nfa->type = MCSHENG_64_NFA_16;
}
- mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa);
+ mcsheng64 *m = reinterpret_cast<mcsheng64 *>(getMutableImplNfa(nfa));
for (u32 i = 0; i < 256; i++) {
m->remap[i] = verify_u8(info.alpha_remap[i]);
}
const vector<u32> &reports_eod,
u32 report_base_offset,
const raw_report_info &ri) {
- mcsheng *m = (mcsheng *)getMutableImplNfa(nfa);
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa));
vector<u32> reportOffsets;
assert(accel_offset <= accel_end_offset);
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
info.strat.buildAccel(i, accel_escape_info.at(i),
- (void *)((char *)m + this_aux->accel_offset));
+ reinterpret_cast<void *>(reinterpret_cast<char *>(m) + this_aux->accel_offset));
}
}
}
void fill_in_succ_table_16(NFA *nfa, const dfa_info &info,
dstate_id_t sheng_end,
UNUSED dstate_id_t sherman_base) {
- u16 *succ_table = (u16 *)((char *)nfa + sizeof(NFA) + sizeof(mcsheng));
+ u16 *succ_table = reinterpret_cast<u16 *>(reinterpret_cast<char *>(nfa) + sizeof(NFA) + sizeof(mcsheng));
u8 alphaShift = info.getAlphaShift();
assert(alphaShift <= 8);
const vector<u32> &reports_eod,
u32 report_base_offset,
const raw_report_info &ri) {
- mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa);
+ mcsheng64 *m = reinterpret_cast<mcsheng64 *>(getMutableImplNfa(nfa));
vector<u32> reportOffsets;
assert(accel_offset <= accel_end_offset);
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
info.strat.buildAccel(i, accel_escape_info.at(i),
- (void *)((char *)m + this_aux->accel_offset));
+ reinterpret_cast<void *>(reinterpret_cast<char *>(m) + this_aux->accel_offset));
}
}
}
void fill_in_succ_table_64_16(NFA *nfa, const dfa_info &info,
dstate_id_t sheng_end,
UNUSED dstate_id_t sherman_base) {
- u16 *succ_table = (u16 *)((char *)nfa + sizeof(NFA) + sizeof(mcsheng64));
+ u16 *succ_table = reinterpret_cast<u16 *>(reinterpret_cast<char *>(nfa) + sizeof(NFA) + sizeof(mcsheng64));
u8 alphaShift = info.getAlphaShift();
assert(alphaShift <= 8);
static
void fill_in_sherman(NFA *nfa, const dfa_info &info, UNUSED u16 sherman_limit) {
- char *nfa_base = (char *)nfa;
- mcsheng *m = (mcsheng *)getMutableImplNfa(nfa);
+ char *nfa_base = reinterpret_cast<char *>(nfa);
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa));
char *sherman_table = nfa_base + m->sherman_offset;
assert(ISALIGNED_16(sherman_table));
assert(len <= 9);
dstate_id_t d = info.states[i].daddy;
- *(u8 *)(curr_sherman_entry + SHERMAN_TYPE_OFFSET) = SHERMAN_STATE;
- *(u8 *)(curr_sherman_entry + SHERMAN_LEN_OFFSET) = len;
- *(u16 *)(curr_sherman_entry + SHERMAN_DADDY_OFFSET) = info.implId(d);
- u8 *chars = (u8 *)(curr_sherman_entry + SHERMAN_CHARS_OFFSET);
+ *(reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_TYPE_OFFSET)) = SHERMAN_STATE;
+ *(reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_LEN_OFFSET)) = len;
+ *(reinterpret_cast<u16 *>(curr_sherman_entry + SHERMAN_DADDY_OFFSET)) = info.implId(d);
+ u8 *chars = reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_CHARS_OFFSET);
for (u16 s = 0; s < info.impl_alpha_size; s++) {
if (info.states[i].next[s] != info.states[d].next[s]) {
}
}
- u16 *states = (u16 *)(curr_sherman_entry + SHERMAN_STATES_OFFSET(len));
+ u16 *states = reinterpret_cast<u16 *>(curr_sherman_entry + SHERMAN_STATES_OFFSET(len));
for (u16 s = 0; s < info.impl_alpha_size; s++) {
if (info.states[i].next[s] != info.states[d].next[s]) {
DEBUG_PRINTF("s overrider %hu dad %hu char next %hu\n", fs,
info.implId(info.states[i].next[s]));
u16 entry_val = info.implId(info.states[i].next[s]);
entry_val |= get_edge_flags(nfa, entry_val);
- unaligned_store_u16((u8 *)states++, entry_val);
+ unaligned_store_u16(reinterpret_cast<u8 *>(states++), entry_val);
}
}
}
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
- mcsheng *m = (mcsheng *)getMutableImplNfa(nfa.get());
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa.get()));
populateBasicInfo(sizeof(u16), info, total_size, aux_offset, accel_offset,
accel_escape_info.size(), arb, single, nfa.get());
static
void fill_in_succ_table_8(NFA *nfa, const dfa_info &info,
dstate_id_t sheng_end) {
- u8 *succ_table = (u8 *)nfa + sizeof(NFA) + sizeof(mcsheng);
+ u8 *succ_table = reinterpret_cast<u8 *>(reinterpret_cast<char *>(nfa) + sizeof(NFA) + sizeof(mcsheng));
u8 alphaShift = info.getAlphaShift();
assert(alphaShift <= 8);
static
void fill_in_sherman64(NFA *nfa, const dfa_info &info, UNUSED u16 sherman_limit) {
- char *nfa_base = (char *)nfa;
- mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa);
+ char *nfa_base = reinterpret_cast<char *>(nfa);
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa));
char *sherman_table = nfa_base + m->sherman_offset;
assert(ISALIGNED_16(sherman_table));
assert(len <= 9);
dstate_id_t d = info.states[i].daddy;
- *(u8 *)(curr_sherman_entry + SHERMAN_TYPE_OFFSET) = SHERMAN_STATE;
- *(u8 *)(curr_sherman_entry + SHERMAN_LEN_OFFSET) = len;
- *(u16 *)(curr_sherman_entry + SHERMAN_DADDY_OFFSET) = info.implId(d);
- u8 *chars = (u8 *)(curr_sherman_entry + SHERMAN_CHARS_OFFSET);
+ *(reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_TYPE_OFFSET)) = SHERMAN_STATE;
+ *(reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_LEN_OFFSET)) = len;
+ *(reinterpret_cast<u16 *>(curr_sherman_entry + SHERMAN_DADDY_OFFSET)) = info.implId(d);
+ u8 *chars = reinterpret_cast<u8 *>(curr_sherman_entry + SHERMAN_CHARS_OFFSET);
for (u16 s = 0; s < info.impl_alpha_size; s++) {
if (info.states[i].next[s] != info.states[d].next[s]) {
}
}
- u16 *states = (u16 *)(curr_sherman_entry + SHERMAN_STATES_OFFSET(len));
+ u16 *states = reinterpret_cast<u16 *>(curr_sherman_entry + SHERMAN_STATES_OFFSET(len));
for (u16 s = 0; s < info.impl_alpha_size; s++) {
if (info.states[i].next[s] != info.states[d].next[s]) {
DEBUG_PRINTF("s overrider %hu dad %hu char next %hu\n", fs,
info.implId(info.states[i].next[s]));
u16 entry_val = info.implId(info.states[i].next[s]);
entry_val |= get_edge_flags64(nfa, entry_val);
- unaligned_store_u16((u8 *)states++, entry_val);
+ unaligned_store_u16(reinterpret_cast<u8 *>(states++), entry_val);
}
}
}
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
- mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa.get());
+ mcsheng64 *m = reinterpret_cast<mcsheng64 *>(getMutableImplNfa(nfa.get()));
populateBasicInfo64(sizeof(u16), info, total_size, aux_offset, accel_offset,
accel_escape_info.size(), arb, single, nfa.get());
static
void fill_in_succ_table_64_8(NFA *nfa, const dfa_info &info,
dstate_id_t sheng_end) {
- u8 *succ_table = (u8 *)nfa + sizeof(NFA) + sizeof(mcsheng64);
+ u8 *succ_table = reinterpret_cast<u8 *>(reinterpret_cast<char *>(nfa) + sizeof(NFA) + sizeof(mcsheng));
u8 alphaShift = info.getAlphaShift();
assert(alphaShift <= 8);
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
- mcsheng *m = (mcsheng *)getMutableImplNfa(nfa.get());
+ mcsheng *m = reinterpret_cast<mcsheng *>(getMutableImplNfa(nfa.get()));
allocateImplId8(info, sheng_end, accel_escape_info, &m->accel_limit_8,
&m->accept_limit_8);
assert(ISALIGNED_N(accel_offset, alignof(union AccelAux)));
auto nfa = make_zeroed_bytecode_ptr<NFA>(total_size);
- mcsheng64 *m = (mcsheng64 *)getMutableImplNfa(nfa.get());
+ mcsheng64 *m = reinterpret_cast<mcsheng64 *>(getMutableImplNfa(nfa.get()));
allocateImplId8(info, sheng_end, accel_escape_info, &m->accel_limit_8,
&m->accept_limit_8);