]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
Remove enum typedef
authorMatthew Barr <matthew.barr@intel.com>
Mon, 25 Jul 2016 06:06:37 +0000 (16:06 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 10 Aug 2016 05:07:01 +0000 (15:07 +1000)
src/fdr/fdr_streaming_compile.cpp
src/fdr/fdr_streaming_internal.h
src/fdr/fdr_streaming_runtime.h

index f84e3ad6fe5792bee20a0537f90b332e7206b298..b2e1656c0e4016848a941cbc4460b808a851036a 100644 (file)
@@ -147,7 +147,7 @@ void analyzeLits(const vector<hwlmLiteral> &long_lits, size_t max_len,
     }
 
     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]++;
         }
@@ -162,7 +162,7 @@ void analyzeLits(const vector<hwlmLiteral> &long_lits, size_t max_len,
 
 #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],
@@ -173,7 +173,7 @@ void analyzeLits(const vector<hwlmLiteral> &long_lits, size_t max_len,
 }
 
 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);
 }
 
@@ -195,7 +195,7 @@ struct OffsetIDFromEndOrder {
 
 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;
@@ -412,7 +412,7 @@ fdrBuildTableStreaming(const vector<hwlmLiteral> &lits,
     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];
     }
 
index 26602ce13beaa6544aa3b23693af4b9ccebd5150..11b07b5624fabb1e78540fa1fffb326db1fe4ce8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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
@@ -91,12 +91,12 @@ struct FDRSHashEntry {
 };
 
 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];
 }
 
@@ -107,17 +107,17 @@ const struct FDRSLiteral * getLitTab(const struct FDRSTableHeader * h) {
 }
 
 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;
 }
 
@@ -127,7 +127,7 @@ u32 has_bit(const struct FDRSHashEntry * ent, u32 bit) {
 }
 
 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);
index fa5843c5d1d72aeb2b30a881267b9f990a7c5215..8e264c76d2a9f2842520359a37efc3fee3761868 100644 (file)
@@ -143,7 +143,7 @@ u32 fdrStreamStateActive(const struct FDR * fdr, const u8 * stream_state) {
 // 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);
@@ -175,7 +175,7 @@ void fdrUnpackStateMode(struct FDR_Runtime_Args *a,
                         const struct FDRSTableHeader *streamingTable,
                         const struct FDRSLiteral * litTab,
                         const u32 *state_table,
-                        const MODES m) {
+                        const enum Modes m) {
     if (!state_table[m]) {
         return;
     }
@@ -213,8 +213,9 @@ void fdrUnpackState(const struct FDR * fdr, struct FDR_Runtime_Args * a,
 }
 
 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;
@@ -279,7 +280,7 @@ void fdrFindStreamingHash(const struct FDR_Runtime_Args *a,
 
 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;
@@ -303,7 +304,7 @@ const struct FDRSHashEntry *getEnt(const struct FDRSTableHeader *streamingTable,
 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]);