diff --git a/include/oaknut/code_block.hpp b/include/oaknut/code_block.hpp index 5db4595..1c29ad0 100644 --- a/include/oaknut/code_block.hpp +++ b/include/oaknut/code_block.hpp @@ -12,11 +12,11 @@ # define NOMINMAX # include #elif defined(__APPLE__) +# include # include # include # include # include -# include #else # include #endif @@ -31,11 +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 +# if TARGET_OS_IPHONE m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); - #else +# else m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_JIT, -1, 0); - #endif +# endif #else m_memory = (std::uint32_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0); #endif @@ -69,22 +69,22 @@ public: void protect() { #if defined(__APPLE__) - #if TARGET_OS_IPHONE +# if TARGET_OS_IPHONE mprotect(m_memory, m_size, PROT_READ | PROT_EXEC); - #else +# else pthread_jit_write_protect_np(1); - #endif +# endif #endif } void unprotect() { #if defined(__APPLE__) - #if TARGET_OS_IPHONE +# if TARGET_OS_IPHONE mprotect(m_memory, m_size, PROT_READ | PROT_WRITE); - #else +# else pthread_jit_write_protect_np(0); - #endif +# endif #endif } diff --git a/include/oaknut/impl/enum.hpp b/include/oaknut/impl/enum.hpp index 154f099..89dc935 100644 --- a/include/oaknut/impl/enum.hpp +++ b/include/oaknut/impl/enum.hpp @@ -199,7 +199,7 @@ enum class TlbiOp { VALE1 = 0b000'0111'101, VAALE1 = 0b000'0111'111, IPAS2E1IS = 0b100'0000'001, - RIPAS2E1IS = 0b100'0000'010, // ARMv8.4-TLBI + RIPAS2E1IS = 0b100'0000'010, // ARMv8.4-TLBI IPAS2LE1IS = 0b100'0000'101, RIPAS2LE1IS = 0b100'0000'110, // ARMv8.4-TLBI ALLE2OS = 0b100'0001'000, // ARMv8.4-TLBI @@ -214,11 +214,11 @@ enum class TlbiOp { ALLE1IS = 0b100'0011'100, VALE2IS = 0b100'0011'101, VMALLS12E1IS = 0b100'0011'110, - IPAS2E1OS = 0b100'0100'000, // ARMv8.4-TLBI + IPAS2E1OS = 0b100'0100'000, // ARMv8.4-TLBI IPAS2E1 = 0b100'0100'001, - RIPAS2E1 = 0b100'0100'010, // ARMv8.4-TLBI - RIPAS2E1OS = 0b100'0100'011, // ARMv8.4-TLBI - IPAS2LE1OS = 0b100'0100'100, // ARMv8.4-TLBI + RIPAS2E1 = 0b100'0100'010, // ARMv8.4-TLBI + RIPAS2E1OS = 0b100'0100'011, // ARMv8.4-TLBI + IPAS2LE1OS = 0b100'0100'100, // ARMv8.4-TLBI IPAS2LE1 = 0b100'0100'101, RIPAS2LE1 = 0b100'0100'110, // ARMv8.4-TLBI RIPAS2LE1OS = 0b100'0100'111, // ARMv8.4-TLBI diff --git a/tests/basic.cpp b/tests/basic.cpp index e1d3c5e..7b401f6 100644 --- a/tests/basic.cpp +++ b/tests/basic.cpp @@ -187,9 +187,8 @@ TEST_CASE("MOVP2R") { CodeBlock mem{4096}; - for (int i = 0; i < 0x200'0000; i++) - { - const std::int64_t diff = RandInt(std::numeric_limits::min(), + for (int i = 0; i < 0x200'0000; i++) { + const std::int64_t diff = RandInt(std::numeric_limits::min(), std::numeric_limits::max()); const std::intptr_t value = reinterpret_cast(mem.ptr()) + diff;