diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-06-21 13:59:01 +0000 |
commit | 3a0822f094b578157263e04114075ad7df81db41 (patch) | |
tree | bc48361fe2cd1ca5f93ac01b38b183774468fc79 /lib/Support/Windows | |
parent | 85d8b2bbe386bcfe669575d05b61482d7be07e5d (diff) |
Diffstat (limited to 'lib/Support/Windows')
-rw-r--r-- | lib/Support/Windows/Memory.inc | 10 | ||||
-rw-r--r-- | lib/Support/Windows/Program.inc | 3 |
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/Support/Windows/Memory.inc b/lib/Support/Windows/Memory.inc index ae8371abf5b3..4b2ff2e2d324 100644 --- a/lib/Support/Windows/Memory.inc +++ b/lib/Support/Windows/Memory.inc @@ -78,7 +78,15 @@ MemoryBlock Memory::allocateMappedMemory(size_t NumBytes, // While we'd be happy to allocate single pages, the Windows allocation // granularity may be larger than a single page (in practice, it is 64K) // so mapping less than that will create an unreachable fragment of memory. - static const size_t Granularity = getAllocationGranularity(); + // Avoid using one-time initialization of static locals here, since they + // aren't thread safe with MSVC. + static volatile size_t GranularityCached; + size_t Granularity = GranularityCached; + if (Granularity == 0) { + Granularity = getAllocationGranularity(); + GranularityCached = Granularity; + } + const size_t NumBlocks = (NumBytes+Granularity-1)/Granularity; uintptr_t Start = NearBlock ? reinterpret_cast<uintptr_t>(NearBlock->base()) + diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc index 75685de45547..c29d8729b1de 100644 --- a/lib/Support/Windows/Program.inc +++ b/lib/Support/Windows/Program.inc @@ -14,6 +14,7 @@ #include "WindowsSupport.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/ConvertUTF.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/WindowsError.h" #include "llvm/Support/raw_ostream.h" @@ -514,7 +515,7 @@ llvm::sys::writeFileWithEncoding(StringRef FileName, StringRef Contents, } if (OS.has_error()) - return std::make_error_code(std::errc::io_error); + return make_error_code(errc::io_error); return EC; } |