}
for (const auto &lit : long_lits) {
- MODES m = lit.nocase ? CASELESS : CASEFUL;
+ Modes m = lit.nocase ? CASELESS : CASEFUL;
for (u32 j = 1; j < lit.s.size() - max_len + 1; j++) {
hashedPositions[m]++;
}
#ifdef DEBUG_COMPILE
printf("analyzeLits:\n");
- for (MODES m = CASEFUL; m < MAX_MODES; m++) {
+ for (Modes m = CASEFUL; m < MAX_MODES; m++) {
printf("mode %s boundary %d positions %d hashedPositions %d "
"hashEntries %d\n",
(m == CASEFUL) ? "caseful" : "caseless", boundaries[m],
}
static
-u32 hashLit(const hwlmLiteral &l, u32 offset, size_t max_len, MODES m) {
+u32 hashLit(const hwlmLiteral &l, u32 offset, size_t max_len, Modes m) {
return streaming_hash((const u8 *)l.s.c_str() + offset, max_len, m);
}
static
void fillHashes(const vector<hwlmLiteral> &long_lits, size_t max_len,
- FDRSHashEntry *tab, size_t numEntries, MODES mode,
+ FDRSHashEntry *tab, size_t numEntries, Modes mode,
map<u32, u32> &litToOffsetVal) {
const u32 nbits = lg2(numEntries);
map<u32, deque<pair<u32, u32> > > bucketToLitOffPairs;
ptr = secondaryTable.get() + htOffset[CASEFUL];
for (u32 m = CASEFUL; m < MAX_MODES; ++m) {
fillHashes(long_lits, max_len, (FDRSHashEntry *)ptr, hashEntries[m],
- (MODES)m, litToOffsetVal);
+ (Modes)m, litToOffsetVal);
ptr += htSize[m];
}
/*
- * Copyright (c) 2015, 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:
// hash table (caseful) (FDRSHashEntry)
// hash table (caseless) (FDRSHashEntry)
-typedef enum {
+enum Modes {
CASEFUL = 0,
CASELESS = 1,
MAX_MODES = 2
-} MODES;
+};
// We have one of these structures hanging off the 'link' of our secondary
// FDR table that handles streaming strings
};
static really_inline
-u32 get_start_lit_idx(const struct FDRSTableHeader * h, MODES m) {
+u32 get_start_lit_idx(const struct FDRSTableHeader * h, enum Modes m) {
return m == CASEFUL ? 0 : h->boundary[m-1];
}
static really_inline
-u32 get_end_lit_idx(const struct FDRSTableHeader * h, MODES m) {
+u32 get_end_lit_idx(const struct FDRSTableHeader * h, enum Modes m) {
return h->boundary[m];
}
}
static really_inline
-u32 getBaseOffsetOfLits(const struct FDRSTableHeader * h, MODES m) {
+u32 getBaseOffsetOfLits(const struct FDRSTableHeader * h, enum Modes m) {
return getLitTab(h)[get_start_lit_idx(h, m)].offset;
}
static really_inline
-u32 packStateVal(const struct FDRSTableHeader * h, MODES m, u32 v) {
+u32 packStateVal(const struct FDRSTableHeader * h, enum Modes m, u32 v) {
return v - getBaseOffsetOfLits(h, m) + 1;
}
static really_inline
-u32 unpackStateVal(const struct FDRSTableHeader * h, MODES m, u32 v) {
+u32 unpackStateVal(const struct FDRSTableHeader * h, enum Modes m, u32 v) {
return v + getBaseOffsetOfLits(h, m) - 1;
}
}
static really_inline
-u32 streaming_hash(const u8 *ptr, UNUSED size_t len, MODES mode) {
+u32 streaming_hash(const u8 *ptr, UNUSED size_t len, enum Modes mode) {
const u64a CASEMASK = 0xdfdfdfdfdfdfdfdfULL;
const u64a MULTIPLIER = 0x0b4e0ef37bc32127ULL;
assert(len >= 32);
// binary search for the literal index that contains the current state
static really_inline
u32 findLitTabEntry(const struct FDRSTableHeader * streamingTable,
- u32 stateValue, MODES m) {
+ u32 stateValue, enum Modes m) {
const struct FDRSLiteral * litTab = getLitTab(streamingTable);
u32 lo = get_start_lit_idx(streamingTable, m);
u32 hi = get_end_lit_idx(streamingTable, m);
const struct FDRSTableHeader *streamingTable,
const struct FDRSLiteral * litTab,
const u32 *state_table,
- const MODES m) {
+ const enum Modes m) {
if (!state_table[m]) {
return;
}
}
static really_inline
-u32 do_single_confirm(const struct FDRSTableHeader * streamingTable,
- const struct FDR_Runtime_Args * a, u32 hashState, MODES m) {
+u32 do_single_confirm(const struct FDRSTableHeader *streamingTable,
+ const struct FDR_Runtime_Args *a, u32 hashState,
+ enum Modes m) {
const struct FDRSLiteral * litTab = getLitTab(streamingTable);
u32 idx = findLitTabEntry(streamingTable, hashState, m);
size_t found_offset = litTab[idx].offset;
static really_inline
const struct FDRSHashEntry *getEnt(const struct FDRSTableHeader *streamingTable,
- u32 h, const MODES m) {
+ u32 h, const enum Modes m) {
u32 nbits = streamingTable->hashNBits[m];
if (!nbits) {
return NULL;
static really_inline
void fdrPackStateMode(u32 *state_table, const struct FDR_Runtime_Args *a,
const struct FDRSTableHeader *streamingTable,
- const struct FDRSHashEntry *ent, const MODES m) {
+ const struct FDRSHashEntry *ent, const enum Modes m) {
assert(ent);
assert(streamingTable->hashNBits[m]);