mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Go ahead and get rid of the old page size interface and convert all the
users over to the new one. No sense maintaining this "compatibility" layer it seems. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171331 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
814afe91cc
commit
f5867ab717
@ -117,12 +117,6 @@ private:
|
|||||||
/// current executing process.
|
/// current executing process.
|
||||||
class Process {
|
class Process {
|
||||||
public:
|
public:
|
||||||
/// \brief Get the virtual memory page size
|
|
||||||
/// This static function will return the operating system's virtual memory
|
|
||||||
/// page size.
|
|
||||||
/// \returns The number of bytes in a virtual memory page.
|
|
||||||
static unsigned GetPageSize();
|
|
||||||
|
|
||||||
/// \brief Return process memory usage.
|
/// \brief Return process memory usage.
|
||||||
/// This static function will return the total amount of memory allocated
|
/// This static function will return the total amount of memory allocated
|
||||||
/// by the process. This only counts the memory allocated via the malloc,
|
/// by the process. This only counts the memory allocated via the malloc,
|
||||||
|
@ -187,7 +187,7 @@ public:
|
|||||||
: MemoryBufferMem(Buffer, RequiresNullTerminator) { }
|
: MemoryBufferMem(Buffer, RequiresNullTerminator) { }
|
||||||
|
|
||||||
~MemoryBufferMMapFile() {
|
~MemoryBufferMMapFile() {
|
||||||
static int PageSize = sys::Process::GetPageSize();
|
static int PageSize = sys::process::get_self()->page_size();
|
||||||
|
|
||||||
uintptr_t Start = reinterpret_cast<uintptr_t>(getBufferStart());
|
uintptr_t Start = reinterpret_cast<uintptr_t>(getBufferStart());
|
||||||
size_t Size = getBufferSize();
|
size_t Size = getBufferSize();
|
||||||
@ -309,7 +309,7 @@ error_code MemoryBuffer::getOpenFile(int FD, const char *Filename,
|
|||||||
uint64_t FileSize, uint64_t MapSize,
|
uint64_t FileSize, uint64_t MapSize,
|
||||||
int64_t Offset,
|
int64_t Offset,
|
||||||
bool RequiresNullTerminator) {
|
bool RequiresNullTerminator) {
|
||||||
static int PageSize = sys::Process::GetPageSize();
|
static int PageSize = sys::process::get_self()->page_size();
|
||||||
|
|
||||||
// Default is to map the full file.
|
// Default is to map the full file.
|
||||||
if (MapSize == uint64_t(-1)) {
|
if (MapSize == uint64_t(-1)) {
|
||||||
|
@ -55,14 +55,6 @@ self_process::~self_process() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
// Implementations of legacy functions in terms of the new self_process object.
|
|
||||||
|
|
||||||
unsigned Process::GetPageSize() {
|
|
||||||
return process::get_self()->page_size();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Include the platform-specific parts of this class.
|
// Include the platform-specific parts of this class.
|
||||||
#ifdef LLVM_ON_UNIX
|
#ifdef LLVM_ON_UNIX
|
||||||
#include "Unix/Process.inc"
|
#include "Unix/Process.inc"
|
||||||
|
@ -73,7 +73,7 @@ Memory::allocateMappedMemory(size_t NumBytes,
|
|||||||
if (NumBytes == 0)
|
if (NumBytes == 0)
|
||||||
return MemoryBlock();
|
return MemoryBlock();
|
||||||
|
|
||||||
static const size_t PageSize = Process::GetPageSize();
|
static const size_t PageSize = process::get_self()->page_size();
|
||||||
const size_t NumPages = (NumBytes+PageSize-1)/PageSize;
|
const size_t NumPages = (NumBytes+PageSize-1)/PageSize;
|
||||||
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
@ -166,8 +166,8 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
|
|||||||
std::string *ErrMsg) {
|
std::string *ErrMsg) {
|
||||||
if (NumBytes == 0) return MemoryBlock();
|
if (NumBytes == 0) return MemoryBlock();
|
||||||
|
|
||||||
size_t pageSize = Process::GetPageSize();
|
size_t PageSize = process::get_self()->page_size();
|
||||||
size_t NumPages = (NumBytes+pageSize-1)/pageSize;
|
size_t NumPages = (NumBytes+PageSize-1)/PageSize;
|
||||||
|
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
#ifdef NEED_DEV_ZERO_FOR_MMAP
|
#ifdef NEED_DEV_ZERO_FOR_MMAP
|
||||||
@ -191,10 +191,10 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
|
|||||||
NearBlock->size() : 0;
|
NearBlock->size() : 0;
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__arm__)
|
#if defined(__APPLE__) && defined(__arm__)
|
||||||
void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_EXEC,
|
void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_EXEC,
|
||||||
flags, fd, 0);
|
flags, fd, 0);
|
||||||
#else
|
#else
|
||||||
void *pa = ::mmap(start, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
|
void *pa = ::mmap(start, PageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
|
||||||
flags, fd, 0);
|
flags, fd, 0);
|
||||||
#endif
|
#endif
|
||||||
if (pa == MAP_FAILED) {
|
if (pa == MAP_FAILED) {
|
||||||
@ -207,7 +207,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
|
|||||||
|
|
||||||
#if defined(__APPLE__) && defined(__arm__)
|
#if defined(__APPLE__) && defined(__arm__)
|
||||||
kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)pa,
|
kern_return_t kr = vm_protect(mach_task_self(), (vm_address_t)pa,
|
||||||
(vm_size_t)(pageSize*NumPages), 0,
|
(vm_size_t)(PageSize*NumPages), 0,
|
||||||
VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
|
VM_PROT_READ | VM_PROT_EXECUTE | VM_PROT_COPY);
|
||||||
if (KERN_SUCCESS != kr) {
|
if (KERN_SUCCESS != kr) {
|
||||||
MakeErrMsg(ErrMsg, "vm_protect max RX failed");
|
MakeErrMsg(ErrMsg, "vm_protect max RX failed");
|
||||||
@ -215,7 +215,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
|
|||||||
}
|
}
|
||||||
|
|
||||||
kr = vm_protect(mach_task_self(), (vm_address_t)pa,
|
kr = vm_protect(mach_task_self(), (vm_address_t)pa,
|
||||||
(vm_size_t)(pageSize*NumPages), 0,
|
(vm_size_t)(PageSize*NumPages), 0,
|
||||||
VM_PROT_READ | VM_PROT_WRITE);
|
VM_PROT_READ | VM_PROT_WRITE);
|
||||||
if (KERN_SUCCESS != kr) {
|
if (KERN_SUCCESS != kr) {
|
||||||
MakeErrMsg(ErrMsg, "vm_protect RW failed");
|
MakeErrMsg(ErrMsg, "vm_protect RW failed");
|
||||||
@ -225,7 +225,7 @@ Memory::AllocateRWX(size_t NumBytes, const MemoryBlock* NearBlock,
|
|||||||
|
|
||||||
MemoryBlock result;
|
MemoryBlock result;
|
||||||
result.Address = pa;
|
result.Address = pa;
|
||||||
result.Size = NumPages*pageSize;
|
result.Size = NumPages*PageSize;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ const char *mapped_file_region::const_data() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mapped_file_region::alignment() {
|
int mapped_file_region::alignment() {
|
||||||
return Process::GetPageSize();
|
return process::get_self()->page_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code detail::directory_iterator_construct(detail::DirIterState &it,
|
error_code detail::directory_iterator_construct(detail::DirIterState &it,
|
||||||
|
@ -21,7 +21,7 @@ class MappedMemoryTest : public ::testing::TestWithParam<unsigned> {
|
|||||||
public:
|
public:
|
||||||
MappedMemoryTest() {
|
MappedMemoryTest() {
|
||||||
Flags = GetParam();
|
Flags = GetParam();
|
||||||
PageSize = sys::Process::GetPageSize();
|
PageSize = sys::process::get_self()->page_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
Reference in New Issue
Block a user