MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.
[oota-llvm.git] / lib / Support / MemoryBuffer.cpp
index 5f4b7daae53d162affc9dd71d9cccaba140b4312..522c365f3d526a0d0bcfdf3c0dd7e6cdc4ba5d3d 100644 (file)
@@ -305,6 +305,14 @@ static bool shouldUseMmap(int FD,
   if ((FileSize & (PageSize -1)) == 0)
     return false;
 
+#if defined(__CYGWIN__)
+  // Don't try to map files that are exactly a multiple of the physical page size
+  // if we need a null terminator.
+  // FIXME: We should reorganize again getPageSize() on Win32.
+  if ((FileSize & (4096 - 1)) == 0)
+    return false;
+#endif
+
   return true;
 }