Fix oss build
[folly.git] / folly / build / GenerateFingerprintTables.cpp
index 3b330f2a4a3c0e93c448238e7f7fa3b26039d004..cc3dce6adb48f55c2cdb84c172d38511f63ea960 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2013 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * limitations under the License.
  */
 
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS 1
+#endif
+
+#include <cinttypes>
 #include <cstdio>
 
 #include <string>
 
 #include <glog/logging.h>
-#include <gflags/gflags.h>
 
-#include "folly/Format.h"
+#include <folly/Portability.h>
+#include <folly/portability/GFlags.h>
 
-#include "folly/detail/FingerprintPolynomial.h"
+#include <folly/detail/FingerprintPolynomial.h>
 
 using namespace folly;
 using namespace folly::detail;
@@ -66,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]));
@@ -84,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%luLU", j ? ", " : "", poly_val[j]));
+    CHECK_ERR(fprintf(file, "%s%" PRIu64 "LLU", j ? ", " : "", poly_val[j]));
   }
   CHECK_ERR(fprintf(file, "};\n\n"));
 
@@ -101,7 +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%luLU", (j ? ", " : ""), table[i][x][j]));
+        CHECK_ERR(
+            fprintf(file, "%s%" PRIu64 "LLU", (j ? ", " : ""), table[i][x][j]));
       }
       CHECK_ERR(fprintf(file, "},\n"));
     }
@@ -110,14 +116,13 @@ void computeTables(FILE* file, const FingerprintPolynomial<DEG>& poly) {
   CHECK_ERR(fprintf(file, "\n};\n\n"));
 }
 
-}  // namespace
+} // namespace
 
 int main(int argc, char *argv[]) {
-  google::ParseCommandLineFlags(&argc, &argv, true);
+  gflags::ParseCommandLineFlags(&argc, &argv, true);
   google::InitGoogleLogging(argv[0]);
 
-  std::string name = folly::format("{}/{}", FLAGS_install_dir,
-                                   "FingerprintTables.cpp").str();
+  std::string name = FLAGS_install_dir + "/" + "FingerprintTables.cpp";
   FILE* file = fopen(name.c_str(), "w");
   PCHECK(file);
 
@@ -128,7 +133,7 @@ int main(int argc, char *argv[]) {
       " * AUTOMATICALLY GENERATED.  DO NOT EDIT.\n"
       " */\n"
       "\n"
-      "#include \"folly/Fingerprint.h\"\n"
+      "#include <folly/Fingerprint.h>\n"
       "\n"
       "namespace folly {\n"
       "namespace detail {\n"