Simplify apple silicon changes
This commit is contained in:
parent
ad315fd20d
commit
94d1f7c01a
@ -52,9 +52,11 @@ constexpr size_t FAR_CODE_OFFSET = 100 * 1024 * 1024;
|
||||
|
||||
#ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT
|
||||
void ProtectMemory(const void* base, size_t size, bool is_executable) {
|
||||
#ifdef _WIN32
|
||||
#if defined(_WIN32)
|
||||
DWORD oldProtect = 0;
|
||||
VirtualProtect(const_cast<void*>(base), size, is_executable ? PAGE_EXECUTE_READ : PAGE_READWRITE, &oldProtect);
|
||||
#elif defined(__APPLE__)
|
||||
pthread_jit_write_protect_np(is_executable);
|
||||
#else
|
||||
static const size_t pageSize = sysconf(_SC_PAGESIZE);
|
||||
const size_t iaddr = reinterpret_cast<size_t>(base);
|
||||
@ -90,18 +92,12 @@ void BlockOfCode::EnableWriting() {
|
||||
#ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT
|
||||
ProtectMemory(GetCodePtr(), TOTAL_CODE_SIZE, false);
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
pthread_jit_write_protect_np(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BlockOfCode::DisableWriting() {
|
||||
#ifdef DYNARMIC_ENABLE_NO_EXECUTE_SUPPORT
|
||||
ProtectMemory(GetCodePtr(), TOTAL_CODE_SIZE, true);
|
||||
#endif
|
||||
#ifdef __APPLE__
|
||||
pthread_jit_write_protect_np(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BlockOfCode::ClearCache() {
|
||||
|
@ -366,12 +366,10 @@ void ARM64XEmitter::FlushIcacheSection(const u8* start, const u8* end) {
|
||||
if (start == end)
|
||||
return;
|
||||
|
||||
#if defined(IOS)
|
||||
#if defined(__APPLE__)
|
||||
// Header file says this is equivalent to: sys_icache_invalidate(start, end -
|
||||
// start);
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, start, end - start);
|
||||
#elif defined(__APPLE__)
|
||||
sys_icache_invalidate(const_cast<u8*>(start), end - start);
|
||||
sys_cache_control(kCacheFunctionPrepareForExecution, const_cast<u8*>(start), end - start);
|
||||
#else
|
||||
// Don't rely on GCC's __clear_cache implementation, as it caches
|
||||
// icache/dcache cache line sizes, that can vary between cores on
|
||||
|
Loading…
x
Reference in New Issue
Block a user