mirror of
https://github.com/azahar-emu/dynarmic.git
synced 2026-04-26 06:33:39 +02:00
Squashed 'externals/oaknut/' changes from 816481f10..c24f918e5
c24f918e5 oaknut: 1.1.6 3a70cd40a oaknut: Run clang-format dc54784b8 oaknut: Add support for iOS memory protection. 14207278a oaknut: 1.1.5 841f9b693 oaknut: throw OaknutException instead of plain C string git-subtree-dir: externals/oaknut git-subtree-split: c24f918e52e629fc315c6e4bca4ea62def8b55e8
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
# define NOMINMAX
|
||||
# include <windows.h>
|
||||
#elif defined(__APPLE__)
|
||||
# include <TargetConditionals.h>
|
||||
# include <libkern/OSCacheControl.h>
|
||||
# include <pthread.h>
|
||||
# include <sys/mman.h>
|
||||
@@ -30,7 +31,11 @@ public:
|
||||
#if defined(_WIN32)
|
||||
m_memory = (std::uint32_t*)VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||
#elif defined(__APPLE__)
|
||||
# if TARGET_OS_IPHONE
|
||||
m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
# else
|
||||
m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0);
|
||||
# endif
|
||||
#else
|
||||
m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
#endif
|
||||
@@ -64,14 +69,22 @@ public:
|
||||
void protect()
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
# if TARGET_OS_IPHONE
|
||||
mprotect(m_memory, m_size, PROT_READ | PROT_EXEC);
|
||||
# else
|
||||
pthread_jit_write_protect_np(1);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void unprotect()
|
||||
{
|
||||
#if defined(__APPLE__)
|
||||
# if TARGET_OS_IPHONE
|
||||
mprotect(m_memory, m_size, PROT_READ | PROT_WRITE);
|
||||
# else
|
||||
pthread_jit_write_protect_np(0);
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user