wrap more memory mapping implementation details
This commit is contained in:
10
memory.c
10
memory.c
@ -24,7 +24,7 @@ int memory_unmap(void *ptr, size_t size) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int memory_protect(void *ptr, size_t size, int prot) {
|
||||
static int memory_protect_prot(void *ptr, size_t size, int prot) {
|
||||
int ret = mprotect(ptr, size, prot);
|
||||
if (unlikely(ret) && errno != ENOMEM) {
|
||||
fatal_error("non-ENOMEM mprotect failure");
|
||||
@ -32,6 +32,14 @@ int memory_protect(void *ptr, size_t size, int prot) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int memory_protect_rw(void *ptr, size_t size) {
|
||||
return memory_protect_prot(ptr, size, PROT_READ|PROT_WRITE);
|
||||
}
|
||||
|
||||
int memory_protect_ro(void *ptr, size_t size) {
|
||||
return memory_protect_prot(ptr, size, PROT_READ);
|
||||
}
|
||||
|
||||
int memory_remap_fixed(void *old, size_t old_size, void *new, size_t new_size) {
|
||||
void *ptr = mremap(old, old_size, new_size, MREMAP_MAYMOVE|MREMAP_FIXED, new);
|
||||
if (unlikely(ptr == MAP_FAILED)) {
|
||||
|
Reference in New Issue
Block a user