diff --git a/makefile b/makefile index 4ff31b9..4b51084 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,7 @@ #CXX=g++-8 #CC=gcc-8 PLATFORM=$(shell uname -i) -CXXFLAGS=-std=c++17 +CXXFLAGS=-std=c++11 CCFLAGS= ifeq ($(PLATFORM),x86_64) CXXFLAGS += -maes diff --git a/src/JitCompilerX86.cpp b/src/JitCompilerX86.cpp index 7212a57..9fb106a 100644 --- a/src/JitCompilerX86.cpp +++ b/src/JitCompilerX86.cpp @@ -24,12 +24,9 @@ along with RandomX. If not, see. #ifdef _WIN32 #include -#elif defined(__linux__) -#include -#include -#include #else -#error "Unsupported operating system" +#include +#include #endif namespace RandomX { @@ -204,16 +201,9 @@ namespace RandomX { if (code == nullptr) throw std::runtime_error("VirtualAlloc failed"); #else - auto pagesize = sysconf(_SC_PAGE_SIZE); - if (pagesize == -1) - throw std::runtime_error("sysconf failed"); - - code = (uint8_t*)memalign(pagesize, CodeSize); - if (code == nullptr) - throw std::runtime_error("memalign failed"); - - if (mprotect(code, CodeSize, PROT_READ | PROT_WRITE | PROT_EXEC) == -1) - throw std::runtime_error("mprotect failed"); + code = (uint8_t*)mmap(nullptr, CodeSize, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); + if (code == (uint8_t*)-1) + throw std::runtime_error("mmap failed"); #endif memcpy(code, prologue, sizeof(prologue)); if (startOffsetAligned - sizeof(prologue) > 4) {