mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-21 02:59:15 +00:00
Implement Path::MapInFilePages/UnMapFilePages on unix, which
provides fast MappedFile::getFile for large files. llvm-svn: 49034
This commit is contained in:
parent
7f88d9043f
commit
3e9e5f498e
@ -75,7 +75,6 @@ const void* MappedFile::map(std::string* ErrMsg) {
|
||||
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 @@ const void* MappedFile::map(std::string* ErrMsg) {
|
||||
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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user