From 879998b3690d7b925953ccfe62bcd6b0c5f6d7d3 Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Fri, 14 Sep 2018 20:49:20 -0700 Subject: [PATCH] Adjust c test and fix windows compilation issues Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/4369 Differential Revision: D9844200 Pulled By: sagar0 fbshipit-source-id: 0d9f5f73b28234eaac55d3551ce4e2dc177af138 --- db/c_test.c | 19 ++++++++++++++----- tools/trace_analyzer_tool.h | 10 ++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/db/c_test.c b/db/c_test.c index 1a7264c61..4f1c0da9f 100644 --- a/db/c_test.c +++ b/db/c_test.c @@ -19,11 +19,8 @@ // Can not use port/port.h macros as this is a c file #ifdef OS_WIN - #include -#define snprintf _snprintf - // Ok for uniqueness int geteuid() { int result = 0; @@ -34,6 +31,11 @@ int geteuid() { return result; } +// VS < 2015 +#if defined(_MSC_VER) && (_MSC_VER < 1900) +#define snprintf _snprintf +#endif + #endif const char* phase = ""; @@ -47,12 +49,19 @@ static void StartPhase(const char* name) { fprintf(stderr, "=== Test %s\n", name); phase = name; } +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning (disable: 4996) // getenv security warning +#endif static const char* GetTempDir(void) { const char* ret = getenv("TEST_TMPDIR"); if (ret == NULL || ret[0] == '\0') ret = "/tmp"; return ret; } +#ifdef _MSC_VER +#pragma warning(pop) +#endif #define CheckNoError(err) \ if ((err) != NULL) { \ @@ -643,7 +652,7 @@ int main(int argc, char** argv) { rocksdb_sstfilewriter_t* writer = rocksdb_sstfilewriter_create(env_opt, io_options); - unlink(sstfilename); + remove(sstfilename); rocksdb_sstfilewriter_open(writer, sstfilename, &err); CheckNoError(err); rocksdb_sstfilewriter_put(writer, "sstk1", 5, "v1", 2, &err); @@ -664,7 +673,7 @@ int main(int argc, char** argv) { CheckGet(db, roptions, "sstk2", "v2"); CheckGet(db, roptions, "sstk3", "v3"); - unlink(sstfilename); + remove(sstfilename); rocksdb_sstfilewriter_open(writer, sstfilename, &err); CheckNoError(err); rocksdb_sstfilewriter_put(writer, "sstk2", 5, "v4", 2, &err); diff --git a/tools/trace_analyzer_tool.h b/tools/trace_analyzer_tool.h index 12a002084..ac9f42f1c 100644 --- a/tools/trace_analyzer_tool.h +++ b/tools/trace_analyzer_tool.h @@ -128,6 +128,10 @@ struct TraceStats { TraceStats(); ~TraceStats(); + TraceStats(const TraceStats&) = delete; + TraceStats& operator=(const TraceStats&) = delete; + TraceStats(TraceStats&&) = default; + TraceStats& operator=(TraceStats&&) = default; }; struct TypeUnit { @@ -137,6 +141,12 @@ struct TypeUnit { uint64_t total_access; uint64_t total_succ_access; std::map stats; + TypeUnit() = default; + ~TypeUnit() = default; + TypeUnit(const TypeUnit&) = delete; + TypeUnit& operator=(const TypeUnit&) = delete; + TypeUnit(TypeUnit&&) = default; + TypeUnit& operator=(TypeUnit&&) = default; }; struct CfUnit {