diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-01 06:16:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-01 06:16:24 +0000 |
commit | 4c5e15f7daa3c7a9a2df332e89f032c3003e660d (patch) | |
tree | c6321c187f979e31b81ca27e79acc1526264f205 /llvm/lib/System/Unix/Path.inc | |
parent | 4f6002c79af576c70d986dc2a32ee9a2bae29cd3 (diff) | |
download | bcm5719-llvm-4c5e15f7daa3c7a9a2df332e89f032c3003e660d.tar.gz bcm5719-llvm-4c5e15f7daa3c7a9a2df332e89f032c3003e660d.zip |
Implement Path::MapInFilePages/UnMapFilePages on unix, which
provides fast MappedFile::getFile for large files.
llvm-svn: 49034
Diffstat (limited to 'llvm/lib/System/Unix/Path.inc')
-rw-r--r-- | llvm/lib/System/Unix/Path.inc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/System/Unix/Path.inc b/llvm/lib/System/Unix/Path.inc index b0578dcdba4..0707de64583 100644 --- a/llvm/lib/System/Unix/Path.inc +++ b/llvm/lib/System/Unix/Path.inc @@ -745,14 +745,19 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) { return false; } -/// MapInFilePages - Not yet implemented on win32. const char *Path::MapInFilePages(int FD, uint64_t FileSize) { - return 0; + int Flags = MAP_PRIVATE; +#ifdef MAP_FILE + Flags |= MAP_FILE; +#endif + void *BasePtr = ::mmap(0, FileSize, PROT_READ, Flags, FD, 0); + if (BasePtr == MAP_FAILED) + return 0; + return BasePtr; } -/// MapInFilePages - Not yet implemented on win32. -void Path::UnMapFilePages(const char *Base, uint64_t FileSize) { - assert(0 && "NOT IMPLEMENTED"); +void Path::UnMapFilePages(const char *BasePtr, uint64_t FileSize) { + ::munmap(BasePtr, FileSize); } } // end llvm namespace |