mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Add support for MemoryBuffers that are not null terminated and add
support for creating buffers that cover only a part of a file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127409 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -869,18 +869,18 @@ Path::makeUnique(bool reuse_current, std::string* ErrMsg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *Path::MapInFilePages(int FD, uint64_t FileSize) {
|
||||
const char *Path::MapInFilePages(int FD, size_t FileSize, off_t Offset) {
|
||||
int Flags = MAP_PRIVATE;
|
||||
#ifdef MAP_FILE
|
||||
Flags |= MAP_FILE;
|
||||
#endif
|
||||
void *BasePtr = ::mmap(0, FileSize, PROT_READ, Flags, FD, 0);
|
||||
void *BasePtr = ::mmap(0, FileSize, PROT_READ, Flags, FD, Offset);
|
||||
if (BasePtr == MAP_FAILED)
|
||||
return 0;
|
||||
return (const char*)BasePtr;
|
||||
}
|
||||
|
||||
void Path::UnMapFilePages(const char *BasePtr, uint64_t FileSize) {
|
||||
void Path::UnMapFilePages(const char *BasePtr, size_t FileSize) {
|
||||
::munmap((void*)BasePtr, FileSize);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user