Use long long for the 64-bit fingerprint table
[folly.git] / folly / build / GenerateFingerprintTables.cpp
index 28018fd686faae0065d891f12cb51630a4e99afc..da21e1716bec83b0b9c9c79fa6dfa3cead5f446f 100644 (file)
@@ -18,8 +18,8 @@
 #define __STDC_FORMAT_MACROS 1
 #endif
 
-#include <cstdio>
 #include <cinttypes>
+#include <cstdio>
 
 #include <string>
 
@@ -71,9 +71,9 @@ void computeTables(FILE* file, const FingerprintPolynomial<DEG>& poly) {
   // where k is the number of bits in the fingerprint (and deg(P)) and
   // Q(X) = q7*X^7 + q6*X^6 + ... + q1*X + q0 is a degree-7 polyonomial
   // whose coefficients are the bits of q.
-  for (int x = 0; x < 256; x++) {
+  for (uint16_t x = 0; x < 256; x++) {
     FingerprintPolynomial<DEG> t;
-    t.setHigh8Bits(x);
+    t.setHigh8Bits(uint8_t(x));
     for (int i = 0; i < 8; i++) {
       t.mulXkmod(8, poly);
       t.write(&(table[i][x][0]));
@@ -89,7 +89,7 @@ void computeTables(FILE* file, const FingerprintPolynomial<DEG>& poly) {
       "const uint64_t FingerprintTable<%d>::poly[%d] = {",
       DEG+1, FingerprintPolynomial<DEG>::size()));
   for (int j = 0; j < FingerprintPolynomial<DEG>::size(); j++) {
-    CHECK_ERR(fprintf(file, "%s%" PRIu64 "LU", j ? ", " : "", poly_val[j]));
+    CHECK_ERR(fprintf(file, "%s%" PRIu64 "LLU", j ? ", " : "", poly_val[j]));
   }
   CHECK_ERR(fprintf(file, "};\n\n"));
 
@@ -106,8 +106,8 @@ void computeTables(FILE* file, const FingerprintPolynomial<DEG>& poly) {
     for (int x = 0; x < 256; x++) {
       CHECK_ERR(fprintf(file, "    {"));
       for (int j = 0; j < FingerprintPolynomial<DEG>::size(); j++) {
-        CHECK_ERR(fprintf(
-          file, "%s%" PRIu64 "LU", (j ? ", " : ""), table[i][x][j]));
+        CHECK_ERR(
+            fprintf(file, "%s%" PRIu64 "LLU", (j ? ", " : ""), table[i][x][j]));
       }
       CHECK_ERR(fprintf(file, "},\n"));
     }