示例#1
0
void *uae_vm_commit(void *address, uae_u32 size, int protect)
{
	uae_log("VM: Commit   0x%-8x bytes at %p (%s)\n",
			size, address, protect_description(protect));
#ifdef _WIN32
	int va_type = MEM_COMMIT ;
	int va_protect = protect_to_native(protect);
	address = VirtualAlloc(address, size, va_type, va_protect);
#else
#ifdef CLEAR_MEMORY_ON_COMMIT
	do_protect(address, size, UAE_VM_READ_WRITE);
	memset(address, 0, size);
#endif
	do_protect(address, size, protect);
#endif
	return address;
}
示例#2
0
bool uae_vm_decommit(void *address, uae_u32 size)
{
	uae_log("VM: Decommit 0x%-8x bytes at %p\n", size, address);
#ifdef _WIN32
	return VirtualFree (address, size, MEM_DECOMMIT) != 0;
#else
    /* Re-map the memory so we get fresh unused pages (and the old ones can be
     * released and physical memory reclaimed). We also assume that the new
     * pages will be zero-initialized (tested on Linux and OS X). */
    void *result = mmap(address, size, PROT_NONE,
                        MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
    if (result == MAP_FAILED) {
        uae_log("VM: Warning - could not re-map with MAP_FIXED at %p\n",
                address);
        do_protect(address, size, UAE_VM_NO_ACCESS);
    }
    return result != MAP_FAILED;
#endif
}
示例#3
0
文件: vm.cpp 项目: jens-maus/fs-uae
bool uae_vm_decommit(void *address, uae_u32 size)
{
	uae_log("VM: Decommit 0x%-8x bytes at %p\n", size, address);
#ifdef _WIN32
	return VirtualFree (address, size, MEM_DECOMMIT) != 0;
#else
#if 0
	/* FIXME: perhaps we can unmmap and mmap the memory region again to
	 * allow the operating system to throw away the (unused) pages. Of
	 * course, we have problem if re-mmaping it fails. If we do this,
	 * we may be able to remove the memory clear operation in
	 * uae_vm_commit. We might also be able to use mmap with MAP_FIXED
	 * to more "safely" overwrite the old mapping. */
	munmap(address, size);
	mmap(...);
#endif
	return do_protect(address, size, UAE_VM_NO_ACCESS);
#endif
}
示例#4
0
bool uae_vm_protect(void *address, int size, int protect)
{
	return do_protect(address, size, protect);
}