OLD | NEW |
1 //===--- MemoryBuffer.cpp - Memory Buffer implementation ------------------===// | 1 //===--- MemoryBuffer.cpp - Memory Buffer implementation ------------------===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the MemoryBuffer interface. | 10 // This file implements the MemoryBuffer interface. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 ErrorOr<std::unique_ptr<MemoryBuffer>> Ret = | 266 ErrorOr<std::unique_ptr<MemoryBuffer>> Ret = |
267 getOpenFileImpl(FD, Filename, FileSize, MapSize, Offset, | 267 getOpenFileImpl(FD, Filename, FileSize, MapSize, Offset, |
268 RequiresNullTerminator, IsVolatileSize); | 268 RequiresNullTerminator, IsVolatileSize); |
269 close(FD); | 269 close(FD); |
270 return Ret; | 270 return Ret; |
271 } | 271 } |
272 | 272 |
273 static bool shouldUseMmap(int FD, | 273 static bool shouldUseMmap(int FD, |
274 size_t FileSize, | 274 size_t FileSize, |
275 size_t MapSize, | 275 size_t MapSize, |
276 off_t Offset, | 276 int64_t Offset, // @LOCALMOD (?) |
277 bool RequiresNullTerminator, | 277 bool RequiresNullTerminator, |
278 int PageSize, | 278 int PageSize, |
279 bool IsVolatileSize) { | 279 bool IsVolatileSize) { |
| 280 |
| 281 // @LOCALMOD-BEGIN |
| 282 // Post 3.3-merge there seems to be a problem using mmap on cygwin. In the |
| 283 // meantime, as a LOCALMOD, we disable usage of mmap in MemoryBuffer. The |
| 284 // effect of this on the Windows/Cygwin toolchain can be a slightly slower |
| 285 // developer-side linkage time. |
| 286 #if defined(__CYGWIN__) |
| 287 return false; |
| 288 #endif |
| 289 // @LOCALMOD-END |
| 290 |
280 // mmap may leave the buffer without null terminator if the file size changed | 291 // mmap may leave the buffer without null terminator if the file size changed |
281 // by the time the last page is mapped in, so avoid it if the file size is | 292 // by the time the last page is mapped in, so avoid it if the file size is |
282 // likely to change. | 293 // likely to change. |
283 if (IsVolatileSize) | 294 if (IsVolatileSize) |
284 return false; | 295 return false; |
285 | 296 |
286 // We don't use mmap for small files because this can severely fragment our | 297 // We don't use mmap for small files because this can severely fragment our |
287 // address space. | 298 // address space. |
288 if (MapSize < 4 * 4096 || MapSize < (unsigned)PageSize) | 299 if (MapSize < 4 * 4096 || MapSize < (unsigned)PageSize) |
289 return false; | 300 return false; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 sys::ChangeStdinToBinary(); | 438 sys::ChangeStdinToBinary(); |
428 | 439 |
429 return getMemoryBufferForStream(0, "<stdin>"); | 440 return getMemoryBufferForStream(0, "<stdin>"); |
430 } | 441 } |
431 | 442 |
432 MemoryBufferRef MemoryBuffer::getMemBufferRef() const { | 443 MemoryBufferRef MemoryBuffer::getMemBufferRef() const { |
433 StringRef Data = getBuffer(); | 444 StringRef Data = getBuffer(); |
434 StringRef Identifier = getBufferIdentifier(); | 445 StringRef Identifier = getBufferIdentifier(); |
435 return MemoryBufferRef(Data, Identifier); | 446 return MemoryBufferRef(Data, Identifier); |
436 } | 447 } |
OLD | NEW |