Build on Visual Studio 2015 Update 1

This commit is contained in:
yuslepukhin 2015-11-20 15:31:47 -08:00
parent 88e0527724
commit 047bd22aae
5 changed files with 52 additions and 17 deletions

View File

@ -14,6 +14,7 @@
# 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries. # 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries.
# See thirdparty.inc for more information. # See thirdparty.inc for more information.
# sample command: cmake -G "Visual Studio 12 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 .. # 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 # 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) # or simply /m ot use all avail cores)
# msbuild rocksdb.sln # msbuild rocksdb.sln

View File

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

View File

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

View File

@ -25,6 +25,7 @@
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <mutex> #include <mutex>
#include <limits>
#include <condition_variable> #include <condition_variable>
#include <stdint.h> #include <stdint.h>
@ -58,8 +59,6 @@ typedef SSIZE_T ssize_t;
#define ROCKSDB_PRIszt "Iu" #define ROCKSDB_PRIszt "Iu"
#endif #endif
#define ROCKSDB_NOEXCEPT
#define __attribute__(A) #define __attribute__(A)
#ifdef ZLIB #ifdef ZLIB
@ -96,17 +95,35 @@ std::string GetWindowsErrSz(DWORD err);
namespace port { 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 = 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 // For use at db/file_indexer.h kLevelMaxIndex
const int kMaxInt32 = INT32_MAX; const int kMaxInt32 = INT32_MAX;
const uint64_t kMaxUint64 = UINT64_MAX; const uint64_t kMaxUint64 = UINT64_MAX;
// std::numeric_limits<size_t>::max() is not constexpr just yet
// therefore, use the same limits
#ifdef _WIN64 #ifdef _WIN64
const size_t kMaxSizet = UINT64_MAX; const size_t kMaxSizet = UINT64_MAX;
#else #else
const size_t kMaxSizet = UINT_MAX; const size_t kMaxSizet = UINT_MAX;
#endif #endif
#endif //_MSC_VER
const bool kLittleEndian = true; const bool kLittleEndian = true;
class CondVar; class CondVar;
@ -207,8 +224,23 @@ class CondVar {
Mutex* mu_; 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)()); extern void InitOnce(OnceType* once, void (*initializer)());
#define CACHE_LINE_SIZE 64U #define CACHE_LINE_SIZE 64U
@ -280,4 +312,4 @@ using port::truncate;
} // namespace rocksdb } // namespace rocksdb
#endif // STORAGE_LEVELDB_PORT_PORT_POSIX_H_ #endif // STORAGE_LEVELDB_PORT_PORT_WIN_H_

View File

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