[llvm-commits] [llvm] r49034 - in /llvm/trunk/lib/System/Unix: MappedFile.inc Path.inc
Chris Lattner
sabre at nondot.org
Mon Mar 31 23:16:24 PDT 2008
Author: lattner
Date: Tue Apr 1 01:16:24 2008
New Revision: 49034
URL: http://llvm.org/viewvc/llvm-project?rev=49034&view=rev
Log:
Implement Path::MapInFilePages/UnMapFilePages on unix, which
provides fast MappedFile::getFile for large files.
Modified:
llvm/trunk/lib/System/Unix/MappedFile.inc
llvm/trunk/lib/System/Unix/Path.inc
Modified: llvm/trunk/lib/System/Unix/MappedFile.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/MappedFile.inc?rev=49034&r1=49033&r2=49034&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/MappedFile.inc (original)
+++ llvm/trunk/lib/System/Unix/MappedFile.inc Tue Apr 1 01:16:24 2008
@@ -75,7 +75,6 @@
assert(MapInfo && "MappedFile not initialized");
if (isMapped()) return BasePtr;
- int prot = PROT_READ;
int flags = MAP_PRIVATE;
#ifdef MAP_FILE
flags |= MAP_FILE;
@@ -83,7 +82,7 @@
size_t PageSize = Process::GetPageSize();
size_t map_size = ((MapInfo->Size / PageSize)+1) * PageSize;
- BasePtr = ::mmap(0, map_size, prot, flags, MapInfo->FD, 0);
+ BasePtr = ::mmap(0, map_size, PROT_READ, flags, MapInfo->FD, 0);
if (BasePtr == MAP_FAILED) {
MakeErrMsg(ErrMsg, "Can't map file:" + Path.toString());
return 0;
Modified: llvm/trunk/lib/System/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=49034&r1=49033&r2=49034&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Path.inc (original)
+++ llvm/trunk/lib/System/Unix/Path.inc Tue Apr 1 01:16:24 2008
@@ -745,14 +745,19 @@
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
More information about the llvm-commits
mailing list