diff --git a/CMakeLists.txt b/CMakeLists.txt index 25fbe7987..354f831f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -804,9 +804,13 @@ if(WIN32) port/win/env_win.cc port/win/env_default.cc port/win/port_win.cc - port/win/win_logger.cc - port/win/win_thread.cc) - + port/win/win_logger.cc) + if(NOT MINGW) + # Mingw only supports std::thread when using + # posix threads. + list(APPEND SOURCES + port/win/win_thread.cc) + endif() if(WITH_XPRESS) list(APPEND SOURCES port/win/xpress_win.cc) diff --git a/port/win/env_win.cc b/port/win/env_win.cc index 6e4524097..9c6a0208f 100644 --- a/port/win/env_win.cc +++ b/port/win/env_win.cc @@ -14,7 +14,6 @@ #include #include -#include // _getpid #include // _access #include // _rmdir, _mkdir, _getcwd #include @@ -906,7 +905,7 @@ Status WinEnvIO::GetTestDirectory(std::string* result) { CreateDir(output); output.append("\\testrocksdb-"); - output.append(std::to_string(_getpid())); + output.append(std::to_string(GetCurrentProcessId())); CreateDir(output); diff --git a/port/win/port_win.h b/port/win/port_win.h index 3dbcb825b..a3ffd559c 100644 --- a/port/win/port_win.h +++ b/port/win/port_win.h @@ -18,12 +18,14 @@ #include #include +#include #include #include #include #include #include #include +#include #include @@ -217,9 +219,14 @@ class CondVar { Mutex* mu_; }; + +#ifdef _POSIX_THREADS +using Thread = std::thread; +#else // Wrapper around the platform efficient // or otherwise preferrable implementation using Thread = WindowsThread; +#endif // OnceInit type helps emulate // Posix semantics with initialization