OSDN Git Service

[Win32] mapped_file_region: Fix a bug in CreateFileMapping() that Size must contain...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Thu, 22 Aug 2013 15:14:53 +0000 (15:14 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Thu, 22 Aug 2013 15:14:53 +0000 (15:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189021 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Windows/Path.inc
unittests/Support/MemoryBufferTest.cpp

index 95caaa5..645d523 100644 (file)
@@ -726,8 +726,8 @@ error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
   FileMappingHandle = ::CreateFileMapping(FileHandle,
                                           0,
                                           flprotect,
-                                          Size >> 32,
-                                          Size & 0xffffffff,
+                                          (Offset + Size) >> 32,
+                                          (Offset + Size) & 0xffffffff,
                                           0);
   if (FileMappingHandle == NULL) {
     error_code ec = windows_error(GetLastError());
index 252d2b5..d9102e0 100644 (file)
@@ -138,9 +138,6 @@ void MemoryBufferTest::testGetOpenFileSlice(bool Reopen) {
   EXPECT_EQ(BufData[9], '9');
 }
 
-#if !defined(_WIN32)
-// FIXME: Investigating since r188998.
-
 TEST_F(MemoryBufferTest, getOpenFileNoReopen) {
   testGetOpenFileSlice(false);
 }
@@ -149,6 +146,4 @@ TEST_F(MemoryBufferTest, getOpenFileReopened) {
   testGetOpenFileSlice(true);
 }
 
-#endif // _WIN32
-
 }