Build on Visual Studio 2015 Update 1

main
yuslepukhin 9 years ago
parent 88e0527724
commit 047bd22aae
  1. 1
      CMakeLists.txt
  2. 4
      db/db_test.cc
  3. 2
      port/win/port_win.cc
  4. 46
      port/win/port_win.h
  5. 16
      util/thread_local_test.cc

@ -14,6 +14,7 @@
# 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries.
# See thirdparty.inc for more information.
# sample command: cmake -G "Visual Studio 12 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 ..
# OR for VS Studio 15 cmake -G "Visual Studio 12 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 ..
# 4. Then build the project in debug mode (you may want to add /m[:<N>] flag to run msbuild in <N> parallel threads
# or simply /m ot use all avail cores)
# msbuild rocksdb.sln

@ -8758,7 +8758,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
for (int pass = 1; pass <= 3; pass++) {
WriteBatch batch;
size_t write_size = 1024 * 1024 * (5 + i);
fprintf(stderr, "prepare: %ld MB, pass:%d\n", (write_size / 1024 / 1024),
fprintf(stderr, "prepare: %" ROCKSDB_PRIszt " MB, pass:%d\n", (write_size / 1024 / 1024),
pass);
for (;;) {
std::string data(3000, j++ % 127 + 20);
@ -8768,7 +8768,7 @@ TEST_F(DBTest, LargeBatchWithColumnFamilies) {
break;
}
}
fprintf(stderr, "write: %ld MB\n", (batch.GetDataSize() / 1024 / 1024));
fprintf(stderr, "write: %" ROCKSDB_PRIszt " MB\n", (batch.GetDataSize() / 1024 / 1024));
ASSERT_OK(dbfull()->Write(WriteOptions(), &batch));
fprintf(stderr, "done\n");
}

@ -100,7 +100,7 @@ void CondVar::Signal() { cv_.notify_one(); }
void CondVar::SignalAll() { cv_.notify_all(); }
void InitOnce(OnceType* once, void (*initializer)()) {
std::call_once(*once, initializer);
std::call_once(once->flag_, initializer);
}
// Private structure, exposed only by pointer

@ -25,6 +25,7 @@
#include <string>
#include <string.h>
#include <mutex>
#include <limits>
#include <condition_variable>
#include <stdint.h>
@ -58,8 +59,6 @@ typedef SSIZE_T ssize_t;
#define ROCKSDB_PRIszt "Iu"
#endif
#define ROCKSDB_NOEXCEPT
#define __attribute__(A)
#ifdef ZLIB
@ -96,17 +95,35 @@ std::string GetWindowsErrSz(DWORD err);
namespace port {
// VS 15
#if (defined _MSC_VER) && (_MSC_VER >= 1900)
#define ROCKSDB_NOEXCEPT noexcept
// For use at db/file_indexer.h kLevelMaxIndex
const int kMaxInt32 = INT32_MAX;
const uint64_t kMaxUint64 = UINT64_MAX;
const int kMaxInt32 = std::numeric_limits<int>::max();
const uint64_t kMaxUint64 = std::numeric_limits<uint64_t>::max();
const size_t kMaxSizet = std::numeric_limits<size_t>::max();
#else //_MSC_VER
#define ROCKSDB_NOEXCEPT
// std::numeric_limits<size_t>::max() is not constexpr just yet
// therefore, use the same limits
// For use at db/file_indexer.h kLevelMaxIndex
const int kMaxInt32 = INT32_MAX;
const uint64_t kMaxUint64 = UINT64_MAX;
#ifdef _WIN64
const size_t kMaxSizet = UINT64_MAX;
#else
const size_t kMaxSizet = UINT_MAX;
#endif
#endif //_MSC_VER
const bool kLittleEndian = true;
class CondVar;
@ -207,8 +224,23 @@ class CondVar {
Mutex* mu_;
};
typedef std::once_flag OnceType;
#define LEVELDB_ONCE_INIT std::once_flag::once_flag();
// OnceInit type helps emulate
// Posix semantics with initialization
// adopted in the project
struct OnceType {
struct Init {};
OnceType() {}
OnceType(const Init&) {}
OnceType(const OnceType&) = delete;
OnceType& operator=(const OnceType&) = delete;
std::once_flag flag_;
};
#define LEVELDB_ONCE_INIT port::OnceType::Init()
extern void InitOnce(OnceType* once, void (*initializer)());
#define CACHE_LINE_SIZE 64U
@ -280,4 +312,4 @@ using port::truncate;
} // namespace rocksdb
#endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_
#endif // STORAGE_LEVELDB_PORT_PORT_WIN_H_

@ -165,7 +165,9 @@ TEST_F(ThreadLocalTest, ConcurrentReadWriteTest) {
auto& p = *static_cast<Params*>(ptr);
p.mu->Lock();
int own = ++(p.started);
// Size_T switches size along with the ptr size
// we want to cast to.
size_t own = ++(p.started);
p.cv->SignalAll();
while (p.started != p.total) {
p.cv->Wait();
@ -183,16 +185,16 @@ TEST_F(ThreadLocalTest, ConcurrentReadWriteTest) {
auto* env = Env::Default();
auto start = env->NowMicros();
p.tls1.Reset(reinterpret_cast<int*>(own));
p.tls2->Reset(reinterpret_cast<int*>(own + 1));
p.tls1.Reset(reinterpret_cast<size_t*>(own));
p.tls2->Reset(reinterpret_cast<size_t*>(own + 1));
// Loop for 1 second
while (env->NowMicros() - start < 1000 * 1000) {
for (int iter = 0; iter < 100000; ++iter) {
ASSERT_TRUE(p.tls1.Get() == reinterpret_cast<int*>(own));
ASSERT_TRUE(p.tls2->Get() == reinterpret_cast<int*>(own + 1));
ASSERT_TRUE(p.tls1.Get() == reinterpret_cast<size_t*>(own));
ASSERT_TRUE(p.tls2->Get() == reinterpret_cast<size_t*>(own + 1));
if (p.doWrite) {
p.tls1.Reset(reinterpret_cast<int*>(own));
p.tls2->Reset(reinterpret_cast<int*>(own + 1));
p.tls1.Reset(reinterpret_cast<size_t*>(own));
p.tls2->Reset(reinterpret_cast<size_t*>(own + 1));
}
}
}

Loading…
Cancel
Save